Professional Documents
Culture Documents
COAL Lec 5 Input Output Instructions - Chap4
COAL Lec 5 Input Output Instructions - Chap4
MOV ah, 01H; input key function
INT 21H; get ASCII code in AL
On entry: Ah= 01H
Returns: AL= 8 bit data input.
When a character is pressed, AL will contain its ASCII code if any other key is
pressed, such as an arrow key or F0-F10 and so on, AL will contain 0.
Function 02 - Display a Character on Screen
To display a character “A‟ on screen execute the following instruction, actually DL must
contain the ASCII code of Character that is to be displayed. In this example DL will
contain ASCI code of “A‟.
MOV AH, 2; display character function
MOV DL, “A‟; character is “A
INT 21H ; display character
On entry:
AH = 02h
DL = 8 bit data (usually ASCII character)
Returns:
Nothing
Function 08 - Read a character input without
Echo from keyboard
Reads a character from the standard input device without copying it
to the display. If no character is ready it waits until one is available.
MOV AH, 08h ; Input key function
INT 21h ; get ASCII code in AL.
On entry: Ah= 01H
Returns: AL= 8 bit data input.
Function 09 - Display a string on Screen
To display a String execute the following instruction, DX register must
contain the starting offset Address of string that to be displayed
LEA DX, msg; get offset address of msg
OR
MOV DX, offset msg ; get offset address of msg.
MOV AH, 9; string Display function
Int 21h; Display msg
On entry: Ah= 09H
DS: DX = segment: offset of string
Returns: Nothing.
Where msg is string define in Data Segment as
Msgdb‟hello world‟, 0Ah, 0Dh, “$‟ or
Msgdb “hello world” ,13h,10h,24h
Displaying an integer 0-9
• We can print character only
• Ascii of 0-9 is 30h-39h respectively
• First convert the didgit inro its ascii by adding
30h then print it like a character
Input two numbers from user .. Adding them and displaying them
; taking input 1 saving in bh
mov ah,1
int 21h
mov bh,al