Chapter Thirteen (Part 1)
|Table of Content||
Chapter Thirteen (Part 3)
MS-DOS PC-BIOS AND FILE I/O (Part 2)
The IBM PC BIOS
13.2 - An Introduction to the BIOS' Services
13.2.1 - INT 5- Print Screen
13.2.2 - INT 10h - Video Services
INT 11h - Equipment Installed
13.2.4 - INT 12h - Memory Available
13.2.5 - INT 13h - Low Level Disk Services
|13.1 The IBM PC BIOS|
Rather than place the BIOS routines at fixed memory
locations in ROM
IBM used a much more flexible approach in the BIOS design. To call a
you use one of the 80x86's
int software interrupt instructions.
int instruction uses the following syntax:
Value is some number in the range 0..255. Execution of the
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
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
int 4 via 0:10.
When the PC resets
one of the first operations it does is
initialize several of these interrupt vectors so they point at BIOS service routines.
when you execute an appropriate
control transfers to
the appropriate BIOS code.
If all you're doing is calling BIOS routines (as opposed to
you can view the
int instruction as nothing more than a
The IBM PC BIOS uses software interrupts 5 and 10h..1Ah to
accomplish various operations. Therefore
int 1ah instructions provide the interface to BIOS. The following table
summarizes the BIOS services:
5 Print Screen operation.
10h Video display services.
11h Equipment determination.
12h Memory size determination.
13h Diskette and hard disk services.
14h Serial I/O services.
15h Miscellaneous services.
16h Keyboard services.
17h Printer services.
1Ah Real time clock 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.
13.2.1 INT 5- Print Screen
Instruction: int 5h BIOS Operation: Print the current text screen. Parameters: None
If you execute the
int 5h instruction
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
int 5 for the BOUNDS trap.
13.2.2 INT 10h - Video Services
Instruction: int 10h BIOS Operation: Video I/O Services Parameters: Several passed in ax bx cx dx and es:bp registers.
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
The video services represent one of the largest set of BIOS calls available. There are many different video display cards manufactured for PCs each with minor variations and often each having its own set of unique BIOS functions. The BIOS reference in the appendices lists some of the more common functions available but as pointed out earlier this list is quite incomplete and out of date given the rapid change in technology.
Probably the most commonly used video service call is the character output routine:
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.
Most BIOS video display routines are poorly written. There is not much else that can be said about them. They are extremely slow and don't provide much in the way of functionality. For this reason most programmers (who need a high-performance video display driver) end up writing their own display code. This provides speed at the expense of portability. Unfortunately there is rarely any other choice. If you need functionality rather than speed you should consider using the ANSI.SYS screen driver provided with MS-DOS. This display driver provides all kinds of useful services such as clear to end of line clear to end of screen etc. For more information consult your DOS manual.
|0||al=mode||Sets the video display mode.|
||Sets the shape of the cursor. Line values are in the range
0..15. You can make the cursor disappear by loading
||Position cursor to location (x y) on the screen. Generally you would specify page zero. BIOS maintains a separate cursor for each page.|
||Get cursor position and shape.|
|4||Obsolete (Get Light Pen Position).|
||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).|
||Clear or scroll up. If
||Clear or scroll down. If
||Read character's ASCII code and attribute byte from current screen position.|
||This call writes cx copies of the character and attribute
||Writes character in al to the current screen position using the existing attribute. Does not change cursor position.|
||Sets the border color for the text display.|
||Write a character to the screen. Uses existing attribute and repositions cursor after write.|
||Get video mode|
Note that there are many other BIOS 10h subfunctions. Mostly these other functions deal with graphics modes (the BIOS is too slow for manipulating graphics so you shouldn't use those calls) and extended features for certain video display cards. For more information on these calls pick up a text on the PC's BIOS.
13.2.3 INT 11h - Equipment Installed
Instruction: int 11h BIOS Operation: Return an equipment list Parameters: On entry: None on exit: AX contains equipment list
On return from
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.
13.2.4 INT 12h - Memory Available
Instruction: int 12h BIOS Operation:Determine memory size Parameters: Memory size returned in AX
Back 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.
13.2.5 INT 13h - Low Level Disk Services
Instruction: int 13h BIOS Operation: Diskette Services Parameters: ax es:bx cx dx (see below)
int 13h function provides several
different low-level disk services to PC programs: Reset the diskette system
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
||Resets the specified disk drive. Resetting a hard disk also resets the floppy drives.|
||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
carry- 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.|
|Reset the hard disk controller|
Note: see appropriate BIOS documentation for additional information about disk subsystem BIOS support.
Chapter Thirteen: MS-DOS
File I/O (Part 2)
28 SEP 1996