Reputation: 3756
Just a precaution. I'm a complete noob on assembly. My only question is that only the following commands in DOS:
MOV AH, 09
INT 21
MOV AX, 4C01
INT 21
Does the second interrupt still have the parameter 09
meaning display screen or does the AX
change that in some way?
Upvotes: 4
Views: 604
Reputation: 882336
You need to search for Ralf Brown's Interrupt List, it's the definitive guide to these old DOS/Windows interrupts.
Calling INT 21h with AH = 09H outputs a $
-terminated string located at DS:DX
to the console.
Calling INT 21H with AH = 4cH exits your program with the return code in AL
(01H in this case).
The second call will not have AH
set to 09H
simply because AH
is simply the upper 8 bits of AX
. The second MOV
sets AH
to 4cH
as part of setting AX
:
In more detail (from Wikipedia):
This register-made-from-other-registers has a long history at Intel with:
ax
being made up of ah
and al
;eax
being made up from 16 bits plus the other 16 from ax
;rax
being made up of 32 bits plus the other 32 from eax
.along with similar approaches for the other general purpose registers and special registers like index or base registers, and the stack pointer.
Interestingly enough, they didn't duplicate the ability to access the high halves of the expanded registers, such as with eax
being made up of eah
and eal
(both mythical, but the latter being an alias for ax
).
That would have given us a large cache of extra small registers in higher modes, though I'm not sure what the cost would have been (no doubt Intel/AMD do know the cost and it was probably deemed too expensive).
Upvotes: 3
Reputation: 225142
AH
and AL
are the high and low halves of AX
, respectively. So yes, setting AX
changes AH
.
4C
is "exit program".
Upvotes: 3