BIOS Interrupts 

Interrupt types 0 to 1Fh are known as BIOS interrupts. This is because most of these service routines are BIOS routines residing in the ROM.

Interrupt Types 0-7

Interrupt types 0-7 are reserved by Intel, with types 0-4 being predefined. IBM uses type 5 for print screen. Types 6 and 7 are not used.

Interrupt 0 -- Divide Overflow

A type 0 interrupt is generated when a DIV or IDIV operation produces an overflow. This occurs when the quotient can not fit in the destination register. The interrupt 0 routine displays the message "DIVIDE OVERFLOW" and returns control to DOS.

Interrupt 1 -- Single Step

Single-stepping is a useful debugging tool to observe the behavior of a program instruction by instruction. A type 1 interrupt is generated when the Trap Flag (TF) is set. The ISR for a type 1 interrupt can be used to display relevant information about the state of the program. For example, the contents of all registers can be displayed. To end single-stepping, the TF should be cleared. Note that there are dedicated instructions for setting and clearing the TF.

Interrupt 2 -- Non-Maskable Interrupt

Interrupt 2 is the hardware interrupt that cannot be masked out by clearing the TF. The IBM PC uses this interrupt to signal memory and I/O parity errors that indicate bad chips.

Interrupt 3 -- Breakpoint

The INT 3 instruction is the only single-byte interrupt instruction (opcode: CCh); other interrupt instructions are two-byte instructions. Inserting a breakpoint in a program involves replacing the program code byte by CCh while saving the program byte for later restoration to remove the breakpoint. Inserting breakpoints is used by program debuggers.

Interrupt 4 -- Overflow

A type 4 interrupt is generated by the instruction INTO (interrupt if overflow) when the OF is set. Programmers may write their own routines to handle unexpected overflows. Note that executing the instruction INT 4 will invoke the ISR for this interrupt type unconditionally while INTO invokes it conditionally on the OF. INTO is not used normally as the overflow condition is usually detected and processed using the instructions JO and JNO.

Interrupt 5 -- Print Screen

The BIOS interrupt 5 routine sends the video screen information to the printer. An INT 5 instruction is generated by the keyboard interrupt routine (interrupt type 9) when the PrtSC (print screen) key is pressed.

Interrupt Types 8h-Fh

The 8086 has only one pin, INTR pin, for maskable hardware interrupt signals. To allow more devices to interrupt the 8086, IBM uses an interrupt controller, the Intel 8259 Programmable Interrupt Controller chip, which can interface up to eight devices. Interrupt types 8h-Fh are generated by hardware devices connected to the 8259 chip. The original version of the PC uses only interrupts 8, 9, and Eh.

Interrupt 8 -- Timer

The IBM PC contains a timer circuit that generates an interrupt once every 54.92 milliseconds (about 18.2 times per second). The BIOS interrupt 8 routine services the timer circuit. It uses the timer signals (ticks) to keep track of the time of the day.

Interrupt 9 -- Keyboard

The interrupt 9 is generated by the keyboard each time a key is pressed or released. The BIOS interrupt 9 routine reads a scan code and stores it in the keyboard buffer. In addition, it also identifies special key combinations such ctrl-break. The keyboard buffer has the capacity to store up to 15 keys. When the buffer is full, pressing a key causes the BIOS to beep, indicating that the key stroke is lost.

The keyboard controller supplies the key identity by means of a scan code. The scan code of a key is simply an identification number given to the key based on its location in the keyboard. The scan code has no relation to the ASCII code. The interrupt 9 routine receives the scan code and generates the equivalent ASCII code, if there is one. Both the scan code and the ASCII code are placed in the keyboard buffer.

Interrupt E -- Diskette Error

The BIOS interrupt Eh handles diskette errors.

Interrupt Types 10h-1Fh

The interrupt routines 10h-1Fh can be called by application programs to perform various I/O operations and status checking.

Interrupt 10h -- Video

The BIOS interrupt 10h routine is the video driver. Associated with each I/O device. There is a device controller or I/O controller that acts as a hardware interface between the processor and the I/O device. The device controller performs many of the low-level tasks specific to the I/O device. This allows the CPU to interact with the device at higher level. For each device controller, there is a software interface that provides a clean interface to access the device. This software interface is called the device driver.

Interrupt 11h -- Equipment Check

The BIOS interrupt 11h routine returns the equipment configuration of the particular PC. The return code is placed in register AX.

Interrupt 12h -- Memory Size

The BIOS interrupt 12h routine returns in register AX the amount of conventional memory a computer has. Conventional memory refers to memory circuits with addresses below 640 KByte. The unit for the return value is in Kbytes.

Interrupt 13h -- Disk I/O

The BIOS interrupt 13h routine is the disk driver. It allows application programs to do disk I/O.

Interrupt 14h -- Communications

The BIOS interrupt 14h routine is the communications driver that interacts with the serial ports.

Interrupt 15h -- Cassette

This interrupt was used by the original PC for cassette interface.

Interrupt 16h -- Keyboard I/O

The BIOS interrupt 16h routine is the keyboard driver. BIOS provides keyboard service routines under INT 16H. We list here some examples.

To read a character from the keyboard, function 0 in AH is used as follows:

Function 00H -- Read a character from the keyboard
Input:		AH=00H
Returns:	if AL<>0 then
		   AL = ASCII code of the key entered
		   AH = Scan code of the key entered
		if AL = 0
		   AH = Scan code of the extended key entered

This BIOS function can be used to read a character from the keyboard. If the keyboard buffer is empty, it waits for a character to be entered. The value returned in AL determines if the key represents an ASCII character or an extended key character. In both cases, the scan code is placed in the AH register and the ASCII and scan codes are removed from the keyboard buffer.

To check if the keyboard buffer is empty or not, we can use function 1 as follows:

Function 01H -- Check keyboard buffer
Input:		AH=01H
Returns:	ZF= 1 if the keyboard buffer is empty
		ZF= 0 if there is at least one character available.
		In this case, the ASCII and scan codes are placed 
		in the AL and AH registers as in function 00. The 
		codes, however, are not removed from the buffer.

Function 2 can be used to check keyboard status with regard to shift and toggle keys.
Function 02H -- Check keyboard status
Input:		AH=02H
Returns:	AL= status of the shift and toggle keys

The following table indicates the bit assignment for shift and toggle keys. A bit with a value of 1 indicates the presence of a condition.

Bits in ALKey Assignment
7Ins lock switch is on
6 Caps lock switch is on
5 Num lock switch is on
4 Scroll lock switch is on
3 Alt key depressed
2 Ctrl key depressed
1 Left shift key depressed
0 Right shift key depressed

Interrupt 17h -- Printer I/O

The BIOS interrupt 17h routine is the printer driver. The routine supports three functions: 0-2.
Function 0 writes a character to a printer; input values are AH=0, AL=character to be printed, DX=printer number (0=LPT1, 1=LPT2, 3=LPT3).
Function 1 initializes a printer port; input values are AH=1, DX=printer number.
Function 2 gets printer status; input values are AH=2, DX= printer number.

For all functions the status is returned in AH. The following table shows the meaning of the bits returned in AH:

Bits in AHMeaning
7 = 1 printer not busy
6 = 1 print acknowledge
5 = 1 out of paper
4 = 1 printer online
3 = 1 I/O error
2 = 1 not used
1 = 1 not used
0 = 1 printer timed-out

Next, we show an example for printing character 0 on the printer. Because printers contain buffers for data, the 0 will not be printed until a carriage return or line feed character is sent.

Example: Print a 0 on the printer.
	MOV AH, 0	; function 0, print character 
	MOV AL, '0'	; character to be printed in AL
	MOV DX, 0	; Printer 0 (LPT1)
	INT 17H		; AH contains return code
	MOV AH, 0	; function 0, print character 
	MOV AL, 0AH	; line feed
	INT 17H		

Interrupt 18h -- BASIC

The BIOS interrupt 18h routine transfers control to ROM BASIC.

Interrupt 19h -- Bootstrap

The BIOS interrupt 19h routine reboots the system.

Interrupt 1Ah -- Time of Day

The BIOS interrupt 1Ah routine allows a program to get and set the timer tick count.

Interrupt 1Bh -- Ctrl Break

This interrupt is called by the INT 9 routine when the Ctrl-break key is pressed. The BIOS interrupt 1Bh routine contains only an IRET instruction. Users may write their own routine to handle the Ctrl-break key.

Interrupt 1Ch -- Timer Tick

Interrupt 1Ch is called by the INT 8 routine each time the timer circuit interrupts. The BIOS interrupt 1Ch routine contains only an IRET instruction. Users may write their own service routine to perform timing operations.

Interrupts 1Dh-1Fh

These interrupt vectors point to data instead of instructions. The interrupt 1Dh, 1Eh, and 1Fh point to video initialization parameters, diskette parameters, and video graphics characters, respectively.