When i have the following code for JWASM in DOS:
MOV AH, 02h
INT 21h
Is it then guaranteed that INT 21h will never change the content of AH?
I ask because of this:
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
If some forum members write "sure, go ahead!", will you delete that line when writing a mission critical software?
Hi,
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.
Regards,
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?
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.
Quote from: _japheth on November 29, 2022, 03:20:22 AMI see virtually no difference in insulting someone and ridicule or slur someone.
IMHO none of these habits are beneficial for a programming forum.
Quote from: HSE on November 29, 2022, 02:50:42 AM
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?
No. In early MS-DOS versions INT 21H return errors in AX. You can assume same thing in later versions.
The best way would be Ralp Browns Interrupt listings (MS-DOS era). There is what goes in the registers, and what comes out to registers and flags. No need to guess values.
Hi,
I checked some documentation. MS-DOS 1.x returns
error codes in AL, a zero means no error. MS-DOS 2+
returns with the carry bit set on to indicate an error. Then
AX contains the error number. Just a rough rule of thumb
though.
Cheers,
Steve
from an old Reference (About 1991):
- Register AX may be altered, its contents are not guaranteed.
- If an error occurs, CF is set to 1 and AX contains a simple error code.
- Int 21, 59 can be used to determine the cause.
- Most Int 21 functions do not restore the flags to pre-interrupt state to allow returning of information via the flags register.
Thanks to you all for the clarification. Then i will keep that extra MOV AH, 02h
line.