Common Software Interrupt Services (MS-DOS)
Operating system software service routines are handled in the same way as
hardware interrupt service rountines except that an instruction is used to
generate the interrupt for software services.
8088 INTERRUPTS
-
Interrupts are a method of accessing operating system services
without the requirement of knowing where in memory the
specific service needed is located. Access is though a table
of addresses of operating system service routines called the
"Interrupt Vector Table" kept in a fixed, reserved part of memory.
Each address stored in the table is 2 words or 4 bytes
long (a 2 byte IP offset address followed by a 2 byte CS segment
address - the Little register is stored first).
-
The Interrupt Vector Table is always located in low memory at absolute
addresses 00000h to 003FFh inclusive. This allows for a
maximum of 100h (256d) interrupt service routines. Each
service routine is assigned an interrupt number between 00h and FFh.
-
Interrupts may be generated by external devices (external
hardware interrupts) or by the CPU (processor interrupts).
-
Processor interrupts may be caused by processing errors
(internal hardware interrupts) such as an attempt to divide by
zero or by an INT instruction (software interrupt).
For example, "INT 4" tells the CPU to pick up interrupt vector table item 4h
and go to that new CS:IP address.
Since each interrupt vector address is 4 bytes long, "INT 4" is located
at offset 4h*4h=10h or 0000:0010 or real address 00010h.
"INT 15" is located at 15h*4h=54h or 0000:0054 or real address 00054h.
(Make sure you do your multiplication in hexadecimal, not decimal!)
"MS-DOS" (high-level) Services
"DOS Services" (as opposed to low-level or hardware-level services) are
provided through software interrupt number 21(hex.); the specific service being
requested is indicated by pre-setting the AH register with a code before
performing the "int 21h". The following is a list of a few of the common
services available (do not memorize the numbers in this list):
- AH = 01h : KEYBOARD INPUT AND DISPLAY
- Wait for keyboard character; echo character on display; return ASCII code
for character in AL. Terminate program if Ctrl-C or Ctrl-Break is typed.
- AH = 07h : KEYBOARD INPUT WITH NO ECHO
- Wait for keyboard character; returns ASCII code for character in AL. Does
not check for Ctrl-C or Ctrl-Break.
- AH = 0Bh : KEYBOARD STATUS
- If a character is available from the keyboard, returns FFh in AL; otherwise
returns 00h in AL.
- AH = 02h : DISPLAY CHARACTER
- Display character with ASCII code pre-stored in DL.
- AH = 09h : DISPLAY STRING
- Display string of characters found in memory starting at the address given
by [DS:DX] and ending with a "$" (an ASCII$ string); the "$" character is not
displayed.
- AH = 4Ch : TERMINATE PROGRAM WITH ERRORLEVEL
- Terminate program execution and return an "errorlevel" code equal to the
value in the AL register; a value of 00h normally is used to indicate a normal
(non-abort) program termination. For .COM-style programs (only) an alternate
method of program termination is with a different interrupt, "int 20h"; note
that this method only works properly with .COM programs and does not allow
for a return code value.
(Do not memorize the numbers in the above list.)
Note the "keyboard" and "display" services described above really apply
to "standard input" and "standard output" and thus allow for "piping" to/from
other programs or "redirection" to/from files.