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". Each address is 2 words or 4 bytes
long (a 2 byte offset address followed by a 2 byte segment
address).
-
The Interrupt Vector Table is always located at absolute
addresses 00000 to 003FFh inclusive. This allows for a
maximum of 100h (256d) interrupt service routines. Each
service routine is assigned an interrupt type 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).
"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:
- 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.
(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.