Experiment - 2 Dos Interrupts: Aim: Theory
Experiment - 2 Dos Interrupts: Aim: Theory
Experiment - 2 Dos Interrupts: Aim: Theory
AIM:To study different DOS interrupt functions and use them to write user friendly
programs.
-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
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: 010A
-t=0100
DX=000
-t
DX=020
raj
DX=020
-t
DX=020
Here string “ diya$ ” which is stored at 200 will be shown on the screen.
-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
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