The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: vasant on April 02, 2006, 12:04:55 PM

Title: Commandline Problem
Post by: vasant on April 02, 2006, 12:04:55 PM
mov si,82h
Mov ah,2
mov dl,[si]
int 21h

mov ah,4ch
int 21h

End

Why? if run

ex a  ;first time
Output: a
but
ex      ;second time
Output a
It not blank?
Title: Re: Commandline Problem
Post by: MichaelW on April 02, 2006, 02:00:46 PM
Is your program an EXE or a COM? If an EXE, are you using a .STARTUP directive or loading DS with something like:

mov  ax,@data
mov  ds,ax

If yes, then you need to use an ES override to access anything in the PSP:

mov dl,es:[si]


Title: PSP in .Com
Post by: vasant on April 05, 2006, 11:05:54 PM
How to use PSP in .Com File?
.Com must Define ORG 100h?

Thank you.
Title: Re: Commandline Problem
Post by: MichaelW on April 05, 2006, 11:39:40 PM
For a COM file the loader sets CS = DS = SS = ES = segment address of PSP, so your code would work correctly without a segment override:

mov si,82h
Mov ah,2
mov dl,[si]  ; <== OK
int 21h


Without an override, the segment register for MOV, and most other instructions that access data, is DS.