0% found this document useful (0 votes)
6 views

Interupt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Interupt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

INT 21h / AH=5: Output Character to Printer

 Purpose: Sends a character (stored in the DL register) to the printer.


 Inputs:
o AH = 5: Function number indicating "output character to printer."
o DL = character: The ASCII value of the character to print.
 Output:

o After execution, the AL register contains the same value as DL.

Example : mov ah, 5


mov dl, 'a'
int 21h

INT 21h / AH=6: Direct Console Input or Output

This function performs either direct input from or direct output to the
console, depending on the parameters provided.

 Purpose: Handles raw input/output operations directly with the console.


 Input:
o AH = 6: Specifies the function code.
o If DL = 0xFF (255 in decimal), it reads a character from the
console (input mode).
o Otherwise, DL contains the ASCII value of a character to be
output (output mode).
 Output:

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.

INT 21h / AH=7: Direct Console Input Without Echo

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:

o The ASCII value of the key pressed is returned in the AL register.

 Behavior:

o The function waits until a key is pressed.


o The key pressed is not displayed (no echo).
o It does not handle special keys like function keys; only ASCII
characters are returned.

Example:

mov ah, 7
int 21h

INT 21h / AH=9: output of a string at DS:DX. String must be terminated


by '$'.

This DOS interrupt function outputs a null-terminated string (terminated by a


$ character) to the screen via the standard output.

 Function Code (AH=9): Displays a string to the console.


 Inputs:
o AH = 9: Specifies the function to display a string.
o DX: Points to the memory address where the string starts.
 Outputs:

o Displays the string on the screen.


o Stops when it encounters a $ character (this character is not
displayed).

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.

 Function Code (AH=0Ah): Reads a string from the keyboard into a


buffer.
 Input:
o AH = 0Ah: Specifies the buffered input function.

 Output:

o The number of characters entered is stored at offset 1 of the


buffer.
o The actual string is stored starting at offset 2, terminated by CR
(ASCII 13).

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

INT 21h with AH = 0Bh

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

o The character pressed will be returned in AL (the ASCII value of


the key).
o CF (Carry Flag) is cleared on success, set on error (e.g., invalid
input).

Example Code (in Assembly):

mov ah, 0Bh ; Function to read a character from the keyboard mov dx, offset
buffer ; Address of the buffer to store the key

int 21h ; Call DOS interrupt ;

Now the character will be in AL and also stored at 'buffer'

You might also like