You are on page 1of 7

In this

-a 100 program ,character a is read from key-board. So it will give its


0572: 0100ASCII
equivalent mov ah,01
value in AL register. Here INT 21h is inbuilt function to
0572: 0102
execute all the
int 21
instructions of it proceed is used.
0572: 0104 mov cx,1234
-t = 100
AX=0100 BX=0000 CX=0000
-p
a
AX=0161 BX=0000 CX=0000
-t
AX=0161 BX=0000 CX=1234
EXPERIMENT - 2
DOS INTERRUPTS

AIM:To study different DOS interrupt functions and use them to write user friendly
programs.

THEORY:Commonly used DOS interrupts for input from keyboard, display on


screen are discussed below.

1. To read a single character from keyboard (function 01)


FigFig
2.12.2
read
Display
a single
a single
char. character
From keyboard
on screen

3. To read a single character without ECO(Don’t see the character on screen)


2.
(function
Display07):
a single character on screen(function 02):

-a-a0100
0100
0B0E:
00A7:0100
0100 mov ah,02
ah,07
0B0E:
00A7:0102
0100 mov
int 21h
dl,61
0B0E:
00A7:0106
0100 int
mov 21h
cx,12
0B0E:
00A7:0109
0100 mov cx,12
-t=0100
-t = 100
AX=0700
AX=0200BX=0000
BX=0000CX=0000
CX=0000
-p-t
AX=0762
AX=0200BX=0000
BX=0000CX=0000
CX=0000
-t-p
AX=0762
a BX=0000 CX=0012
AX=0261 BX=0000 CX=0012
In this case
DX=000whatever character read from a keyboard that will not display on a
screen0but its ASCII value will be stored in to AL register.
DX=006
1
DX=006
1
Fig 2.3 Read a single character on screen

4. To display a string on a screen(function 09):

We should first start a string at some address & at the end of the string ‘$’ is used to
show the ending of the string.then address of that string should be stored in to DX
register.

-e 0200 “diya$”

-a 0100

0B0E: 0100 mov ah,09

0B0E: 0102 mov dx,0200

0B0E: 0105 int 21h

0B0E: 010A

-t=0100

DX=000

AX=0900 BX=0000 CX=0000 0

-t

DX=020

AX=0900 BX=0000 CX=0000 0


Fig 2.4 Display a string on a screen
-p

raj

DX=020

AX=0900 BX=0000 CX=0000 0

-t

DX=020

AX=0900 BX=0000 CX=1234 0

Here string “ diya$ ” which is stored at 200 will be shown on the screen.

5. To read a string from key-board(function 0A):

-e 0200 4
-a 0100
0B0E: 0100 mov ah,0A
0B0E: 0102 mov dx,0200
0B0E: 0105 int 21h
0B0E: 0107 mov cx,12
0B0E: 010A
-t
AX=0A0 DX=000 Fig 2.5 Read a string from key-board
0 BX=0000 CX=0000 0
CONCLUSION:
-t
From this experiment we learn how to write a char or string from keyboard
AX=0A0
and how DX=020
to display char and string on screen. We see that for writing char
0we use “$” sign
BX=0000 to display
CX=0000 0 on screen.
EXERCISE:
-p
1. Write an assembly language program in DEBUG to take an input
diya
string from the keyboard and display the same string on the screen
using INT
AX=0A0 21H functions. Save the program using DEBUG
DX=020
commands.
0 BX=0000 CX=0000 0
-t
AX=0A0 DX=020
0 BX=0000 CX=0012 0
-d 200 206
0B0E:200 04 03 72 61 6A 0d 3c ..diya..

From this example we can only read a string up to (define size -1) character. String
will be start after two type where we define size of it. so, total three bytes (1st = total
size, 2nd =actual size & 3rd =for enter). So, total three will be wasted. If we want to
display the string then we must put ‘$’ at the end of it while it reads..
Fig 2.6 take the string from keyboard

Fig 2.7 display string on screen

2. Write an assembly language program to take two 2 digit numbers


from the keyboard and display the result of addition of the numbers
on the screen.

data segment
str1 db "Enter 1st 2-digit number:$"
str2 db "Enter 2nd 2-digit number:$"
str3 db "Result:$"
num1 db 2 dup(?) ;to store the 1st number
num2 db 2 dup(?) ;to store the 2nd number
result db 3 dup(?) ;to store the result
ends
code segment
assume cs:code, ds:data
mov ax,data
mov ds,ax
xor cx,cx ;clear cx register
LEA dx,str1 ;load string 1
mov Ah,09
int 21h ;display str1
mov cl,02
LEA SI,num1
loop1: mov ah,01 ;take the 1st number as input from keyboard
int 21h
sub al,30h
mov [si],al ;store the number
inc si
loop loop1
LEA dx,str2 ;load string 2
mov ah,09
int 21h ;display str2
mov cl,02
LEA SI,num2
loop2: mov ah,01 ; take the 2nd number as input from keyboard
int 21h
sub al,30h
mov [si],al ;store the number
inc SI

You might also like