You are on page 1of 16

Chapter – 4(In/Out)

By
Hasan Murad
CSE,UAP
In/out Operation
• BIOS Routine
• Interrupt Vector
BIOS
• BIOS(Basic input/output system)
• Perform I/O operation for the PC
• BIOS routines are machine specific
• DOS I/O operations are done by BIOS
• In simple word BIOS is a library of input/output functions
Interrupt vector
• The addresses of the BIOS routines are called interrupt vectors
The Interrupt Instruction
• INT interrupt_number
• INT 21H
• INT 21H ->Console
Functions of INT 21H
Function Number Routine

1 Single-Key Input

2 Single-Character Output

9 Character String Output


Function 1:Single-Key Input
• INT 21H
• Input: AH = 1 (function number)
• Output: AL = ASCII code of the character key pressed
= 0 if non-character key is pressed

• MOV AH,1 ;function number


• INT 21H ;execute
• Output will be stored in AL in ASCII value
Function 2:Single-Character Output
• INT 21H
• Input: AH = 2 (function number)
DL = ASCII code of the display character
• Output: AL = ASCII code of the display character

• MOV AH,2 ; function number


• MOV DL, ‘?’ ; character is ‘?’
• INT 21H ;execute
• Output will be stored in AL in ASCII value
Function 2:Single-Character Output
• INT 21H
• Input: AH = 2 (function number)
DL = ASCII code of the display character or Control Function
• Output: AL = ASCII code of the display character or Control Function
ASCII code(Hex) Symbol Function
7 BEL Beep(sounds a tone)
8 BS backspace
9 HT tab
A LF Line feed (new line)
D CR Carriage return(start of
current line)
Function 2:Single-Character Output
• INT 21H
• Input: AH = 2 (function number)
DL = ASCII code of the display character or Control Function
• Output: AL = ASCII code of the display character or Control Function

• MOV AH,2 ;function number


• MOV DL, 7H ; Beep a tone
• INT 21H ;execute
• Output will be stored in AL in ASCII value
New line
• INT 21H
• Input: AH = 2 (function number)
DL = ASCII code of the display character or Control Function
• Output: AL = ASCII code of the display character or Control Function

• MOV AH,2 ;function number


• MOV DL, 0DH ; carriage return
• INT 21H ; execute carriage return
• MOV DL, 0AH ; line feed
• INT 21H ; execute line feed
Function 9:Character String Output
• INT 21H
• Input: AH = 9 (function number)
DX =offset address of string
The LEA Instruction
• LEA -> Load Effective Address
• LEA destination, source
• It copy the source offset address into the destination
• LEA DX,MSG
• In data segment -> MSG DB ‘Hello world!$’
• In code segment -> LEA DX, MSG
Function 9:Character String Output
• INT 21H
• Input: AH = 9 (function number)
DX =offset address of string
The string must end with a ‘$’ character

• MOV AH,9 ;function number


• LEA DX,MSG ; copy the offset address of source into DX register
• INT 21H ;execute
Instruction Set In this Chapter
• MOV
• XCHG
• ADD
• SUB
• NEG
• INC
• DEC
• LEA
• INT

You might also like