Mumbai University > Electronics and Telecommunication > Sem 4 > Microprocessor and peripherals
INT 21H – DOS Interrupt :
MS-DOS provides a lot of functions for displaying and reading the text on the console. The general syntax for calling the function is
MOV AH ; Function number, input parameters
INT 21 H ; return values
- Input a character:
MOV AH, 01H
After the interrupt, AL contains the ASCII Code of the input character.
- Output a character :
MOV AH 02H
Load the desired character into DL, then call the interrupt with function code 2 in AH.
- Input a string
Buffer DB BUFSIZE ; BUFSIZE is max number of character
RESB BUFSIZE + 1
MOV DX, Buffer
MOV AH, OAH
After the interrupt, BYTE [ BUFFER + 1 ] will contain the number of character read, and the character themselves will start at Buffer + 2. The character will be terminated by a carriage return ( ASCII Code 13), although this will be included in the count.
- Output a string
MOV AH, 09H
Load the address of a \$ terminated into DX then call the interrupt with fuction code 9 in ASCIII
MOV AH, 4CH
Load the return code ( O for normal exit, non zero error) into AL, then call the interrupt with code 4CH in AH. This is the proper DOS exit. However, if we are running our program with DX this will exit DEBUG.