Chapter 8
Introduction to Video and Keyboard Processing



Two types of interrupts are covered in this chapter the BIOS interrupt 10H and the DOS interrupt 21H. Both of these interrupts request an action that you insert in the AH register which identifies the service to be done.
 

The low-level BIOS operation such as INT 10H transfer control directly to BIOS. The DOS INT 21H provides interrupt service that first transfers control to DOS.
 

The BIOS INT 10H functions are 02H for setting the cursor and 06H for scrolling the screen. The DOS INT 21H functions are 02H for screen display, 09H for screen display, 0AH for keyboard input, 3fH for keyboard input, and 40H for screen display.
 

Screen Features

The screen is a grid of addressable locations at any one of which the cursor can be set by row and column position.  On the standard text mode display there are 25 rows and 80 columns number from 0 to 24 and 0 to 79 respectively.

The system provides space in memory for a Video display area, or buffer. There are various display mode available.  The standard text mode display begins at BIOS location B000[0]H and supports 4K bytes of memory, 2K of which are available for characters and 2K for an attribute for each character, such as reverse video, blinking, high intensity, and underlining.
The Video Display Area also provides for screen pages numbered from 0 to 7.

The basic color graphics video display support 16K bytes, starting at BIOS location B8000[0]H. You process either in text mode for normal display or in graphics mode. For text mode, the display area provides for screen "pages" numbered 0 through 3 for an 80-column screen, with bytes for each character and its attribute.
You can directly address the video adapter but its not recommended. The recommend practice is to use the appropriate interrupt instructions: INT 10H functions to display, to set the cursor at any location, and to clear the screen and INT 21H functions for various types of display.
 

Setting the Cursor
 

Setting the cursor is provided in text mode but not in graphics mode. This is accomplished with a INT 10H interrupt and a function 02H in the AH. The BH contains the page number 0 through 3 and the DX contain the row column (DH-row: DL-column) address of the screen.

        MOV    AH,02H        ;request set cursor function
        MOV    BH,0            ;page 0
        MOV    DX,080FH    ;row 8 column 15
        INT      10H

Clearing the Screen
 

Clearing the screen is also provided with a BIOS 10H INT using the function 06H. This function will handle screen clearing or scrolling. You can clear all or part of the screen with this function. The AL contains the number of lines to scroll. If it is set to zero or a number greater than the height of the specified window then the entire window area is cleared. The BH contains the diplay attribute. The CX contains the row column address of the upper left corner of the screen area to be cleared and the DX contains the row column address of the lower right corner of this area.

        MOV    AX, 0600H    ;scroll the full screen
        MOV    BH,71H         ;white background with blue foreground
        MOV    CX,0000H     ;starting scroll position
        MOV    DX,184FH    ;ending scroll position
        INT      10H
 
 
 

INT 21 H FUNCTION 09H FOR SCREEN DISPLAY

The DOS function 09H is used for displaying a string that is terminated by a dollar sign to the current cursor location. The contents of the DX register contains the effective address of the string in memory. Use LEA to load this offset into the DX register.

See Figure 8-1, Program A08DISAS for displaying ASCII characters.
 

INT 21H 0AH FOR KEYBOARD INPUT

The DOS function 0AH is used to accept data from the keyboard. It uses a parameter list which contains the specified fields that the interrupt operation uses. The interrupt needs to know the maximum length of the input data. It delivers the number of bytes actually entered. The parameter list is defined with a LABEL directive with the attribute of BYTE which aligns on byte boundaries. The first byte contains the limit for input characters,0 - 255 bytes. The second byte is used to store the actual number of bytes entered. The third byte begins a field that is to contain the typed characters, from left to right.
 
 
 

Use of Control Characters for a Screen Displaying
 
 
CONTROL CHARACTER
ASCII
HEX
EFFECT ON CURSOR
Carriage return 13 0DH Reset to left positon of screen
Line feed 10 0AH Advances to next line
Tab 09 09H Advances to next tab stop

 

INT 21H FUNCTION 02H FOR SCREEN DISPLAY

The DOS function 02H is for screen dsiplay. It is useful for displaying a single character at a time. The Tab, carriage return, and line feed act normally, and the operation automatically advances the cursor.
 
 

FILE HANDLES
 

A file handle is simple a number that refers to a specific device. See page 148 for preset handles.
 

FILE HANDLES FOR SCREEN DISPLAY
 

DOS INT 21H, function 40H uses file handles to request display operations. The AH contains the 40H function, the BX contains the file handle, 01 for screen, the CX contains the number of bytes to write, and the DX contains the segment address for the buffer or display area.
 

FILE HANDLES FOR KEYBOARD INPUT
 

DOS INT 21H, function 3FH uses file handles to request keyboard input. Load the AH with 3FH, the BX with file handle 00, the CX with the maximum number of charcters to accept, and the DX with the address of the data area for enetering characters.