int
software interrupt
instructions. The int
instruction uses the following syntax:int
instruction
will cause the 80x86 to transfer control to one of 256 different interrupt
handlers. The interrupt vector table, starting at physical memory location
0:0, holds the addresses of these interrupt handlers. Each address is a
full segmented address, requiring four bytes, so there are 400h bytes in
the interrupt vector table -- one segmented address for each of the 256
possible software interrupts. For example, int 0
transfers
control to the routine whose address is at location 0:0, int 1
transfers
control to the routine whose address is at 0:4, int 2 via 0:8, int
3
via 0:C, and int 4
via 0:10.int
instruction, control transfers
to the appropriate BIOS code. int
instruction as nothing more than a special
call
instruction. int 5
, and int 10h
..
int 1ah
instructions provide the interface to BIOS. The following
table summarizes the BIOS services: Most of these routines require various parameters in the 80x86's registers. Some require additional parameters in certain memory locations. The following sections describe the exact operation of many of the BIOS routine.
Instruction: int 5h BIOS Operation: Print the current text screen. Parameters: NoneIf you execute the
int 5h
instruction, the PC will send a copy
of the screen image to the printer exactly as though you'd pressed the PrtSc
key on the keyboard. In fact, the BIOS issues an int 5
instruction
when you press the PrtSc, so the two operations are absolutely identical
(other than one is under software control rather than manual control). Note
that the 80286 and later also uses int 5
for the BOUNDS trap.Instruction: int 10h BIOS Operation: Video I/O Services Parameters: Several, passed in ax, bx, cx, dx, and es:bp registers.The
int 10h
instruction does several video display related
functions. You can use it to initialize the video display, set the cursor
size and position, read the cursor position, manipulate a light pen, read
or write the current display page, scroll the data in the screen up or down,
read and write characters, read and write pixels in a graphics display mode,
and write strings to the display. You select the particular function to
execute by passing a value in the ah
register. Name: Write char to screen in TTY mode Parameters ah = 0Eh, al = ASCII code (In graphics mode, bl = Page number)This routine writes a single character to the display. MS-DOS calls this routine to display characters on the screen. The UCR Standard Library also provides a call which lets you write characters directly to the display using BIOS calls.
AH | Input Parameters | Output Parameters | Description |
---|---|---|---|
0 | al=mode | Sets the video display mode. | |
1 | ch - Starting line.cl - ending line | Sets the shape of the cursor.
Line values are in the range 0..15. You can make the cursor disappear by
loading ch with 20h. | |
2 | bh - pagedh - y coordinatedl - x coordinate | Position cursor to location (x,y) on the screen. Generally you would specify page zero. BIOS maintains a separate cursor for each page. | |
3 | bh - page | ch -
starting linecl - ending linedl - x coordinatedh - y coordinate | Get cursor position and shape. |
4 | Obsolete (Get Light Pen Position). | ||
5 | al - display page | Set display page. Switches the text display page to the specified page number. Page zero is the standard text page. Most color adapters support up to eight text pages (0..7). | |
6 | al- Number of lines to scroll.bh- Screen attribute for cleared area.cl - x coordinate ULch - y coordinate ULdl - x coordinate LRdh - y coordinate LR | Clear or scroll up. If al
contains zero, this function clears the rectangular portion of the screen
specified by cl/ch (the upper left hand corner) and dl/dh
(the lower right hand corner). If al contains any other value,
this service will scroll that rectangular window up the number of lines
specified in al . | |
7 | al- Number of lines
to scroll.bh- Screen attribute for cleared area.cl - x coordinate ULch - y coordinate ULdl - x coordinate LRdh - y coordinate LR | Clear or scroll down. If al
contains zero, this function clears the rectangular portion of the screen
specified by cl/ch (the upper left hand corner) and dl/dh
(the lower right hand corner). If al contains any other value,
this service will scroll that rectangular window down the number of lines
specified in al . | |
8 | bh - display page | al -
char readah - char attribute | Read character's ASCII code and attribute byte from current screen position. |
9 | al- characterbh - pagebl - attributecx - # of times to replicate character | This call
writes cx copies of the character and attribute in al/bl starting
at the current cursor position on the screen. It does not change the cursor's
position. | |
0Ah | al- characterbh - page | Writes character in al to the current screen position using the existing attribute. Does not change cursor position. | |
0Bh | bh - 0bl - color | Sets the border color for the text display. | |
0Eh | al - characterbh - page | Write a character to the screen. Uses existing attribute and repositions cursor after write. | |
0Fh | ah -
# columnsal - display modebh - page | Get video mode |
Instruction: int 11h BIOS Operation: Return an equipment list Parameters: On entry: None, on exit: AX contains equipment listOn return from
int 11h
, the AX register contains a bit-encoded
equipment list with the following values:Bit 0 Floppy disk drive installed Bit 1 Math coprocessor installed Bits 2,3 System board RAM installed (obsolete) Bits 4,5 Initial video mode 00- none 01- 40x25 color 10- 80x25 color 11- 80x25 b/w Bits 6,7 Number of disk drives Bit 8 DMA present Bits 9,10,11 Number of RS-232 serial cards installed Bit 12 Game I/O card installed Bit 13 Serial printer attached Bits 14,15 Number of printers attached.Note that this BIOS service was designed around the original IBM PC with its very limited hardware expansion capabilities. The bits returned by this call are almost meaningless today.
Instruction: int 12h BIOS Operation:Determine memory size Parameters: Memory size returned in AXBack in the days when IBM PCs came with up to 64K memory installed on the motherboard, this call had some meaning. However, PCs today can handle up to 64 megabytes or more. Obviously this BIOS call is a little out of date. Some PCs use this call for different purposes, but you cannot rely on such calls working on any machine.
Instruction: int 13h BIOS Operation: Diskette Services Parameters: ax, es:bx, cx, dx (see below)The
int 13h
function provides several different low-level disk
services to PC programs: Reset the diskette system, get the diskette status,
read diskette sectors, write diskette sectors, verify diskette sectors,
and format a diskette track and many more. This is another example of a
BIOS routine which has changed over the years. When this routine was first
developed, a 10 megabyte hard disk was considered large. Today, a typical
high performance game requires 20 to 30 megabytes of storage. AH | Input Parameters | Output Parameters | Description |
---|---|---|---|
0 | dl - drive (0..7fh is
floppy, 80h..ffh is hard) | ah - status (0 and carry clear
if no error, error code if error). | Resets the specified disk drive. Resetting a hard disk also resets the floppy drives. |
1 | dl -
drive (as above) | ah - 0al - status of previous disk operation. | This call returns
the following status values in al: 0- no error 1- invalid command 2- address mark not found 3- disk write protected 4- couldn't find sector 5- reset error 6- removed media 7- bad parameter table 8- DMA overrun 9- DMA operation crossed 64K boundary 10- illegal sector flag 11- illegal track flag 12- illegal media 13- invalid # of sectors 14- control data address mark encountered 15- DMA error 16- CRC data error 17- ECC corrected data error 32- disk controller failed 64- seek error 128- timeout error 170- drive not ready 187- undefined error 204- write error 224- status error 255- sense failure |
2 | al - # of sectors to reades:bx - buffer addresscl - bits 0..5: sector #cl - bits 6/7- track bits 8 & 9ch - track bits 0..7.dl - drive # (as above)dh - bits 0..5: head #dh - bits 6&7: track bits 10 & 11. | ah -
return statusal - burst error lengthcarry- 0:success, 1:error | Reads the specified number of 512 byte sectors from the disk. Data read must be 64 Kbytes or less. |
3 | same as (2) above | same as (2) above | Writes the specified number of 512 byte sectors to the disk. Data written must not exceed 64 Kbytes in length. |
4 | Same as (2) above except there is no need for a buffer. | same as (2) above | Verifies the data in the specified number of 512 byte sectors on the disk. |
0Ch | Same as (4) above except there is no need for a sector # | Same as (4) above | Sends the disk head to the specified track on the disk. |
0Dh | dl - drive # (80h or 81h) | ah -
return statuscarry-0:no error 1:error | Reset the hard disk controller |