You can somewhat improve the display performance of programs that are intended for use only on IBM PC—compatible machines by using the ROM BIOS video driver instead of the MS-DOS output functions. Accessed by means of Int 10H, the ROM BIOS driver supports the following functions for all of the currently available IBM display adapters:
Function Action
Display mode control
00H Set display mode.
0FH Get display mode.
Cursor control
01H Set cursor size.
02H Set cursor position.
03H Get cursor position and size.
Writing to the display
09H Write character and attribute at cursor.
0AH Write character-only at cursor.
0EH Write character in teletype mode.
Reading from the display
08H Read character and attribute at cursor.
Graphics support
0CH Write pixel.
0DH Read pixel.
Scroll or clear display
06H Scroll up or initialize window.
07H Scroll down or initialize window.
Miscellaneous
04H Read light pen.
05H Select display page.
0BH Select palette/set border color.
Additional ROM BIOS functions are available on the EGA, MCGA, VGA, and PCjr to support the enhanced features of these adapters, such as programmable palettes and character sets (fonts). Some of the functions are valid only in certain display modes.
Each display mode is characterized by the number of colors it can display, its vertical resolution, its horizontal resolution, and whether it supports text or graphics memory mapping. The ROM BIOS identifies it with a unique number. Section III of this book, "IBM ROM BIOS and Mouse Functions Reference," documents all of the ROM BIOS Int 10H functions and display modes.
As you can see from the preceding list, the ROM BIOS offers several desirable capabilities that are not available from MS-DOS, including initialization or scrolling of selected screen windows, modification of the cursor shape, and reading back the character being displayed at an arbitrary screen location. These functions can be used to isolate your program from the hardware on any IBM PC—compatible adapter. However, the ROM BIOS functions do not suffice for the needs of a high-performance, interactive, full-screen program such as a word processor. They do not support the rapid display of character strings at an arbitrary screen position, and they do not implement graphics operations at the level normally required by applications (for example, bit-block transfers and rapid drawing of lines, circles, and filled polygons). And, of course, they are of no use whatsoever in non-IBM display modes such as the monochrome graphics mode of the Hercules Graphics Card.
Let's look at a simple example of a call to the ROM BIOS video driver. The following sequence writes the string hello to the screen:
msg db 'hello'
msg_len equ $-msg
.
.
.
mov si,seg msg ; DS:SI = message address
mov ds,si
mov si,offset msg
mov cx,msg_len ; CX = message length
cld
next: lodsb ; get AL = next character
push si ; save message pointer
mov ah,0eh ; int 10h function 0eh = write
; character in teletype mode
mov bh,0 ; assume video page 0
mov bl,color ; (use in graphics modes only)
int 10h ; transfer to ROM BIOS
pop si ; restore message pointer
loop next ; loop until message done
.
.
.
(Note that the SI and DI registers are not necessarily preserved across a call to a ROM BIOS video function.)