Interupt
Interupt
This function performs either direct input from or direct output to the
console, depending on the parameters provided.
o For input: The character read from the console is returned in AL.
o For output: The character in DL is printed directly to the console.
example:
mov ah, 6
mov dl, 'a'
int 21h ; output character.
mov ah, 6
mov dl, 255
int 21h ; get character from keyboard buffer (if any) or set ZF=1.
This function is used to read a single character from the console (keyboard)
without echoing it to the screen. It allows low-level input without displaying
the entered character.
Function Code (AH=7): Reads one character from the keyboard buffer.
Input:
o AH = 7: Specifies the function for direct console input without
echo.
Output:
Behavior:
Example:
mov ah, 7
int 21h
Example:
org 100h
mov dx, offset msg
mov ah, 9
int 21h
ret
msg db "hello world $"
INT 21h / AH=0Ah: Buffered Input
This DOS interrupt function allows the user to input a string from the
keyboard into a buffer. It provides a more controlled way to handle user input,
including limiting the length of the input.
Output:
Example:
org 100h
mov dx, offset buffer
mov ah, 0ah
int 21h
jmp print
buffer db 10,?, 10 dup(' ')
print:
xor bx, bx
mov bl, buffer[1]
mov buffer[bx+2], '$'
mov dx, offset buffer + 2
mov ah, 9
int 21h
ret
the function does not allow to enter more characters than the specified buffer
size.
see also int21.asm in c:\emu8086\examples
is a DOS interrupt function that is used for console input. Specifically, it waits
for the user to press a key, reads the input from the keyboard, and stores the
result in a buffer.
INT AH = 0Bh: This is the DOS interrupt function for reading a
character from the keyboard.
Input:
o AL: This must be set to a value that specifies the input mode:
AL = 0: Waits for a key press and returns the key in AL.
AL = 1: Waits for a key press but does not echo the
character to the screen (useful for password input).
o DX: Points to the buffer where the character will be stored.
Output
mov ah, 0Bh ; Function to read a character from the keyboard mov dx, offset
buffer ; Address of the buffer to store the key