Miscellaneous > 16 bit DOS Programming

JWASM: Do "MOV AH, 02h" and "INT 21h" never change the content of AH?

(1/2) > >>

When i have the following code for JWASM in DOS:

--- Code: ---MOV AH, 02h
INT 21h

--- End code ---

Is it then guaranteed that INT 21h will never change the content of AH?

I ask because of this:

--- Code: ---MOV DL, 0Dh ; Output CR
MOV AH, 02h
INT 21h
MOV DL, 0Ah ; Output  LF
MOV AH, 02h          <---- If INT 21h does not change AH, then i won't need that line. One operation less.
INT 21h

--- End code ---

If some forum members write "sure, go ahead!", will you delete that line when writing a mission critical software?


   Yes, in general, MS-DOS does seem to preserve AH across
an Int 21H function call.  But I cannot find this documented
anywhere.  Also function 59H "Get Extended Error" is
documented to change all registers except SS:SP and CS:IP.
So I won't make any recommendation in this situation.


Steve N.


--- Quote from: bugthis on November 29, 2022, 12:15:00 AM ---Is it then guaranteed that INT 21h will never change the content of AH?

--- End quote ---

No. In early MS-DOS versions INT 21H return errors in AX. You can assume same thing in later versions. 


> Some members can't live without insulting others. It tells us a lot about them.

Since you used the little word "us": What is it supposed to tell me?

Because, psychologically, I see virtually no difference in insulting someone and ridicule or slur someone. The purpose is always to daunt the opponent - and I suppose that quite common (and healthy  :bgrin: ) human nature.


[0] Message Index

[#] Next page

Go to full version