Reputation: 51
I am new to Assembly Language programming.
I wanted to know that is it true that interrupts should be moved to Ah register?
Is it wrong to move any interrupts to AL registers?
Upvotes: 0
Views: 1257
Reputation: 364088
Read https://en.wikipedia.org/wiki/DOS_API, and other documentation: http://spike.scu.edu.au/~barry/interrupts.html
(Also Ralf Brown's interrupt list has details about many other int
numbers: http://www.ctyme.com/rbrown.htm. The standard convention is still a "function code" in AH
that selects which system call you want out of that group over services.)
The DOS "kernel" code in the interrupt handler is going to read AH
to find out what function you want. Then reads whatever other registers, depending on which code runs.
You can think of int 21h
as a fancy call
into the DOS kernel, to a dispatcher that uses AH
to index a table of function pointers to dispatch to the real function. Then that function uses args in other registers.
A few of those do take an arg in AL
, but many take an arg in DL
(like a character to print). Some of them don't read AL
on input, but most write it as an output.
For functions where AL
is not an input, you can have whatever you want in AL
when int 21h
runs. So sure, you could have another copy of the call number in AL
as well as AH
; it will do no harm. But you must have the right values in the documented registers.
System call mechanisms for most other OSes are similar: put args in registers then invoke a trap instruction. e.g. Linux puts call number in EAX
, and uses int 0x80
(32-bit) or syscall
(64-bit). Only a few (like 32-bit FreeBSD / MacOS) pass system call args on the stack.
OSes other than DOS do not support int 21h
. e.g. a 32-bit Windows executable will just crash (itself, not the whole machine) if it executes an int 21h
.
Upvotes: 2