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

DOS Services Using INT 21H Interrupt: Dos Functions and Interrupts: The Intel CPU Recognizes Two Types of Interrupts

This document discusses using INT 21H interrupts in DOS to perform various functions like displaying strings, characters, reading input from the keyboard, and reversing strings. It includes example programs demonstrating how to call DOS services to display a string, display a character, read a single character of input, read a string of input, and reverse a given string. The examples show initializing registers, calling INT 21H with the appropriate function number, and obtaining the input or output in registers. The conclusion is that INT 21H allows accessing common DOS services from assembly language programs.

Uploaded by

Denis Rijal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

DOS Services Using INT 21H Interrupt: Dos Functions and Interrupts: The Intel CPU Recognizes Two Types of Interrupts

This document discusses using INT 21H interrupts in DOS to perform various functions like displaying strings, characters, reading input from the keyboard, and reversing strings. It includes example programs demonstrating how to call DOS services to display a string, display a character, read a single character of input, read a string of input, and reverse a given string. The examples show initializing registers, calling INT 21H with the appropriate function number, and obtaining the input or output in registers. The conclusion is that INT 21H allows accessing common DOS services from assembly language programs.

Uploaded by

Denis Rijal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab-07 - Microprocessor

LAB: 07
DOS Services using INT 21H interrupt

DOS FUNCTIONS AND INTERRUPTS:


√ The Intel CPU recognizes two types of interrupts:

l Hardware interrupt

l Software interrupts (INT 10H-video services and INT 21H-DOS services.)

√ INT 21H: It is called the DOS function call.

√ By calling INT 21h with a subfunction number in the AH processor register and
other parameters in other registers, one invokes various DOS services.

√ DOS services include handling keyboard input, video output, disk file access,
program execution, memory allocation, and various other activities.

INT 21H FUNCTIONS


INITIALIZE DS ( assembler should 00H It terminates the current program.
inform processor where the data is 01H Read a character with echo
located):
02H Display single character

MOV AX, @DATA 03H Auxiliary input


MOV DS, AX 04H Auxiliary output
05H Printer service
06H Direct keyboard and display
07H waits for a character from standard input
08H keyboard input without echo
EXIT PROGRAM ( Initialize AH
09H string display
register with 4CH and call INT 21H
DOS service): 0AH Read string
0BH Check keyboard status
MOV AX, 4C00H
0CH Clear keyboard buffer and invoke input
INT 21H functions

[email protected] 1 Compiled by: Baikuntha Acharya


Sagarmatha Engineering College
Lab-07 - Microprocessor

LAB: 07
DOS Services using INT 21H interrupt

√ Program to Display string.

TITLE to display a string Note down the final result and conclusion:
.MODEL SMALL
.STACK 64
.DATA
STR DB ‘programming is fun’, ‘$’
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 09H ;display string
LEA DX, STR
INT 21H
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN

√ Program to Display a character.

TITLE to display a character. Note down the final result and conclusion:

Data Segment
Check DB 65

Code Segment
MOV DL, CHECK
MOV AH, 02H
INT 21H

[email protected] 2 Compiled by: Baikuntha Acharya


Sagarmatha Engineering College
Lab-07 - Microprocessor

LAB: 07
DOS Services using INT 21H interrupt
√ Program to read a character form keyboard.

TITLE to read a character. Note down the final result and conclusion:

Code Segment
MOV AH, 01H
INT 21H

Input will be assigned to AL.

√ Program to read string form keyboard.

TITLE to read string from Format of string stored in memory after read:
keyboard. MAXLEN ACTLEN INPUT[0] INPUT[1] ......... INPUT[N]

Data Segment MAXLEN: Maximum characters user can give as


MAXLEN DB 255 input.
ACTLEN DB ?
INPUT DB 255 DUP (‘$‘) MAXLEN: It gives count of number of characters
entered by the users.
Code Segment
MOV AH, 0AH MAXLEN: Stores string as array of characters.
LEA DX, MAXLEN
INT21H *Note: Initialize DX with effective address of INPUT
or MAXLEN+2 for display using INT 21H by loading
Input will be assigned to AL. AH=09H

Note down the final result and conclusion:

[email protected] 3 Compiled by: Baikuntha Acharya


Sagarmatha Engineering College
Lab-07 - Microprocessor

LAB: 07
DOS Services using INT 21H interrupt

TITLE to reverse given string.


.model small
.data
str1 db ‘Sagarmatha Engineering College’
len equ ($-str1) ; $ = current location, str1= location of str1
space db 5 dup (?)
str2 db len dup (?)
.code
start: Mov ax, @data
Mov ds,ax

Lea si, str1


add si, len-1
Lea di, str2
Mov cx, len

back: Mov al, [si]


Mov [di], al
Dec si
Inc di
loop back

mov [di], ‘$’


mov ah, 09h
lea dx, str2
int 21h
mov ah, 4ch
int 21h
end

Note down the final result and conclusion:

[email protected] 4 Compiled by: Baikuntha Acharya


Sagarmatha Engineering College

You might also like