Software interrupts are a set of procedures thats are accessible to the programmer. These procedures are contained within the kernels of the BIOS and DOS. In the case of DOS, the code is contained within the conventional memory of the computer, where DOS is loaded. In the case of BIOS, some code is contained in conventional memory and some in the upper memory. The upper memory code is the extensions to ROM which are found on each extension card inserted into the computer.
Software interrupts are numbered 10h-FFh.
Software interrupts usually provide much more than one function to the programmer. In order to specify what function to use, the interrupts normally check the value of the AH register. For example, the Video Interrupt (10h) will set the cursor position if AH=2.
Hardware interrupts are a set of procedures that the CPU can call automatically when certain events take place. These cannot and should not be called by the programmer. Hardware interrupts are part of the BIOS and are located in similar places in memory.
Hardware interrupts are numbered 0-0Fh.
The 8086 CPU has a number of physical inputs (through its microchip pins) which are called Interrupt Request Lines (IRQs). A number of hardware devices require regular background servicing and they are each allocated an IRQ number (eg. mouse port uses IRQ4). The IRQ numbers range from 0-15. When the device needs to be serviced, it sends a signal to the CPU on its unique IRQ line. The CPU in turn, stops everything that it is doing (hence the word, interrupt), unless it is servicing another interrupt, and calls the relevant hardware interrupt procedure.
For example, consider the keyboard. When you press a key, the keyboard interface hardware sends an interrupt signal (IRQ1) to the CPU. The CPU then stops everything it is doing and runs the relevant keyboard hardware interrupt routine - interrupt 9. Interrupt 9 will check up on the keyboard using hardware commands (IN/OUT) and find put what key was pressed. Then it will store this key in the keyboard buffer as defined by the BIOS. When the interrupt completes with the IRET statement, control is returned to the program that was executing. The user is totally unaware of the background processing that is being done every time a key is pressed. Now, when a program requires input, the keyboard is not checked at all. Instead, the keyboard buffer in memory is looked up and if there is a key there, it is returned.
The obvious question to ask would be: why such an elaborate scheme ? Why not just check the keyboard whenever a keystroke is required ? The reason why this cannot be done is that the computer would lose a lot of keystrokes if it were not for the buffer. Consider the situation where you are using a word-processor that is quite slow. When you press a key, you would have to wait until the key appears on the screen before pressing another key; and if the word-processor is not ready for you, your keystroke would not be registered and you would have to press the key again. The buffer solves this problem but it requires that the saving and retrieving of keystrokes be done independant of each other. Hence the scheme of using interrupts.
Hardware interrupts are also used to service the floppy drive, hard drive, serial ports, parallel ports and any other devices that may need periodic or otherwise implicit servicing. Hardware interrupts are not of much use to the person writing standard assembly language (or other high-level language) programs; their primary use is when writing drivers, tsrs and other low-level programs.
The procedural code that services any such interrupt is called an Interrupt Service Routine (ISR).
Int 10/00 - Set Video Mode
Set:
AH=0h
AL=Display Mode
Comments:
Sets the video mode and clears the video screen. To prevent the screen from clearing, set bit 7 of AL to 1. Look up a reference manual for the display codes.
Int 10/01 - Set Cursor Type
Set:
AH=01h
CH=Start scan line in bits 0-4
CL=Stop scan line in bits 0-4
Comments:
Sets the size of the cursor by specifying the top and bottom lines of the cursor. Color mode cursor scan lines range from 0-7 while monochrome cursor scan lines range from 0-0Ch.
Int 10/02 - Set Cursor Position
Set:
AH=02h
BH=Page number (normally 0)
DH=Row
DL=Column
Comments:
Moves the cursor to the specified position on the screen. The top left coordinates are (0,0) and the bottom are either (79,24) or (39,24) depending on the current video mode (text or graphics).
Int 10/03 - Read Current Cursor Position/Config
Set:
AH=03h
BH=Page number (normally 0)
Returns:
BH=Page number
CH=Start scan line for cursor
CL=Stop scan line for cursor
DH=Row
DL=Column
Comments:
Retrieves information about the current size and position of the cursor.
Int 10/08 - Read Character and Attribute
Set:
AH=08h
BH=Page number (normally 0)
Returns:
AH=Attribute byte
AL=ASCII character
Comments:
Reads the character at the current position of the cursor and returns its ASCII value and colour attribute.
Int 10/09 - Write Character and Attribute
Set:
AH=09h
AL=ASCII value
BH=Page number (normally 0)
BL=Attribute of character
CX=No of characters to write
Comments:
Copies the character with its attribute to the current cursor position. This function can write up to 65535 characters.
Int 10/0C - Write Graphics Pixel
Set:
AH=0Ch
AL=Color value
BH=Page number (normally 0)
CX=Column
DX=Row
Comments:
Lights up a single pixel on the screen. Will only work if the screen is in one of the graphics modes. The effect of this function may vary depending on the particular mode being used.
Int 10/0D - Read Graphics Pixel
Set:
AH=0Dh
BH=Page number (normally 0)
CX=Column
DX=Row
Returns:
AL=Color value
Comments:
Reads the color value of a pixel at a particular position on the screen. Only works in graphics mode.
Int 10/0F - Get Display Mode
Set:
AH=0Fh
Returns:
AH=Number of columns on screen
AL=Display mode
BH=Active page number
Comments:
Checks up the current display mode. Look up a reference manual for the meaning of the display codes returned in AL.
Int 11 - Get Equipment Status
Returns:
AX=Equipment status word
Comments:
Returns information about the type of hardware connected in the computer.
bit 0 - disk drive installed
bit 1 - math coprocessor installed
bit 4-5 - initial video mode
(01=40x25 colour, 10=80x25 colour, 11=80x25 mono)
bit 6-7 - no of disk drives attached
(00=1, 01=2, 10=3, 11=4)
bit 9-11 - no of serial cards attached
bit 12 - game adapter installed
bit 14-15 - no of printers attached
Int 12 - Get Memory Size
Returns:
AX=Number of 1 kilobyte blocks
Comments:
Returns the size of memory in contiguous 1k blocks.
Int 13/02 - Read Floppy Disk
Set:
AH=02h
AL=Number of sectors to transfer
ES:BX=pointer to memory buffer
CH=track number
CL=sector number
DH=head number
DL=drive number
Returns:
Carry flag clear if successful
(AL=no of sectors transferred)
Carry flag set if error
(AL=error code)
Comments:
Reads a number of sectors from a floppy disk and stores the data in memory. Be very careful with this function !
Int 13/03 - Write Floppy Disk
Set:
AH=03h
AL=Number of sectors to transfer
ES:BX=pointer to memory buffer
CH=track number
CL=sector number
DH=head number
DL=drive number
Returns:
Carry flag clear if successful
(AH=0, AL=no of sectors transferred)
Carry flag set if error
(AL=error code)
Comments:
Writes a number of sectors from memory to a floppy disk. Be very careful with this function !
Int 15/84 - Joystick Support
Set:
AH=84h
DX=00h to read switch settings
DX=01h to read joystick position
Returns:
if DX=00 on calling,
(AL=switch settings in bits 4-7)
if DX=01 on calling,
(AX=X-value[1], BX=Y-value[1])
(CX=X=value[2], DX=Y-value[2])
Comments:
Retieves information about the joystick.
Int 15/88 - Get Extended Memory Size
Set:
AH=88h
Returns:
AX=Number of contiguous 1 kilobyte blocks above 100000h
Int 16/00 - Read Keyboard
Set:
AH=00h
Returns:
AH=Keyboard scan code
AL=ASCII character code
Comments:
Waits for and reads a single character from the keyboard.
Int 16/01 - Read Keyboard Status
Set:
AH=01h
Returns:
Zero flag clear (keystroke waiting)
(AH=scan code, AL=ASCII code)
Zero flag set (no key waiting)
Comments:
Checks if a key is waiting in the keyboard buffer, and if so, returns the information about the key.
Int 16/02 - Read Keyboard Flags
Set:
AH=02h
Returns:
AL=ROM BIOS keyboard flags byte
Comments:
Returns the status of the shift keys on the keyboard.
bit 0 - right shift key
bit 1 - left shift key
bit 2 - ctrl key
bit 3 - alt key
bit 4 - scroll lock key
bit 5 - num lock key
bit 6 - caps lock key
bit 7 - insert key
Int 17/00 - Write Character to Printer
Set:
AH=00h
AL=ASCII character
DX=Printer number (0-2)
Returns:
AH=Printer status
Comments:
Writes the character to the printer port.
Int 19 - Warm Boot
Comments:
Reboots the system by performing a warm-boot.
Int 1A/00 - Get Clock Counter
Set:
AH=00h
Returns:
AL=Midnight flag (set if 24 hours have passed)
CX:DX=clock count
Comments:
Returns the value of the system clock, which increments 18.2065 times per second.
Int 1C/00 - Timer Tick Interrupt
Comments:
This interrupt is called 18.2 times per second by the hardware timer interrupt routine. In order to write a timer-driven TSR, it can be hooked to this interrupt.
Int 21/01 - Keyboard Input with echo
Set:
AH=01h
Returns:
AL=character code
Comments:
Reads in a single character from the keyboard and echoes it to the screen.
Int 21/02 - Display Output
Set:
AH=02h
DL=character code
Comments:
Outputs a single character to the screen.
Int 21/09 - Display String
Set:
AH=09h
DS:DX=address of string
Comments:
Outputs a string terminated with a $ to the screen.
Int 21/0A - Buffered Input
Set:
AH=0Ah
DS:DX=address of memory buffer
Comments:
Inputs a string into a pre-formatted memory buffer. The format of the memory buffer is as follows:
offset 0 - maximum number of bytes to read
offset 1 - actual number of bytes read
offset 2 -> actual bytes read
Int 21/25 - Set Interrupt Vector
Set:
AH=25h
AL=interrupt number
DS:DX=address of interrupt service routine
Comments:
Associates the interrupt with the specified procedure.
Int 21/31 - Terminate and Stay Resident
Set:
AH=31h
AL=return code
DX=number of memory blocks to reserve (in paragraphs)
Comments:
Terminates a program but leaves the specified number of memory blocks resident in memory.
Int 21/35 - Get Interrupt Vector
Set:
AH=35h
AL=interrupt number
Returns:
ES:BX=address of interrupt service routine
Comments:
Retrieves the address of the interrupt procedure associated with a particular interrupt.
Int 21/4C - Exit Program
Set:
AH=4Ch
AL=return code
Comments:
Returns immediately to the executing program, returning the code in AL.