Monday, April 25, 2016

Description of INT 21h

** INT 21h may be used to invoke a large number of DOS functions ; a particular function is requested by placing a function number in the AH register and invoking INT 21h. Here we are interested in the following functions :


Function Number                    Routine

1                                            Single-key input

2                                            Single-Character Output

9                                            Character String Output

INT 21h functions expect input values to be in certain registers and return output values in other registers. There are listed as we describe each function.

Function 1:

Single-Key input

Input : AH = 1
output :  AL = ASCII code if character key is pressed
             = 0 if non-character key is pressed

To invoke the routine, execute these instructions :

MOV  AH,1       ;input key function
INT 21h              ;ASCII code in AL

The processor will wait for the user to hit a key if necessary. if a character key is pressed, AL gets its ASCII code; the character is also displayed on the screen. If any other key is pressed, such as an arrow key, F1-F10, and so on, AI, will contain 0. The instructions following the INT 21h can examine AL and take appropriate action.

Because INT 21h, function 1, doesn't prompt the user for input, he or she might not know whether the computer is waiting for input or is occupied by some computation. The next function can be used to generate an input prompt.


Function 2 :

Display a character or execute a control function

Input :             AH   = 2
                       DL   =    ASCII code of the display character or control character

Output  :   AL  = ASCII code of the display character or control character

No comments:

Post a Comment