You are on page 1of 14

MNI LAB-11

Sheikh Abuzar Amjad


19-CP-6

Submitted TO: ENGR. USMAN RAUF SB


LAB #11

Interrupts

INT Interrupt:

An interrupt is either a hardware-generated CALL (externally derived from a hardware


signal) or a software-generated CALL (internally derived from the execution of an
instruction or by some other internal event).

It is a method of creating a temporary halt during the program execution to allow


peripheral devices to access the microprocessor. Microprocessor responds to that
interrupt with interrupt Service Routine (ISR), a short program to instruct the
microprocessor that how to handle the interrupt.

The microprocessor has three different interrupt instructions that are available to the
programmer: INT, INTO, and INT 3. In the real mode, each of these instructions fetches
a vector from the vector table, and then calls the procedure stored at the location
addressed by the vector.

Syntax: INT type or Value

Example: INT 21H,


There are 256 different software interrupt instructions (INTs) available to the
programmer.

Lab Tasks

Execute the following tasks CLO [1]

TASK 1
Take input from the user, increment that and show the
incremented value at the output Take the input from the user,
decrement it and show the decremented value at the output

CODE
org 100h
.data
a db 0ah,0dh, "Enter 1st Number: $"

b db 0ah,0dh, "Incremented number: $"

c db 0ah,0dh, "Enter 2nd Number: $"

d db 0ah,0dh, "Decremented Number: $"


.code
mov ax, @data
mov ds, ax
lea dx,a
mov ah, 09 ; Display
int 21h
mov ah, 01h ; input 1st number
int 21h
mov bl, al
INC BL
lea dx,b
mov ah, 09 ; Display
int 21h
mov dl, bl
mov ah, 02
int 21h
mov ah,00h
mov al, 02h
int 10h
lea dx,c
mov ah, 09 ; Display
int 21h
mov ah, 01h ; input 2nd number
int 21h
mov BH,AL
DEC BH
lea dx,d
mov ah, 09 ; Display
int 21h
mov dl, bh
mov ah, 02
int 21h
ret

OUTPUT

TASK 2:
Write a code to add first ten natural numbers starting from the
memory location 0200H?
TASK 2
Take the ASCII value 31 and 35 from user and show the
result of their sum?

CODE
Org 100h
.data
a DB 0AH, 0DH,"Enter 1stAscii Number 31: $"
b DB 0AH, 0DH,"Enter 2nd Ascii Number 35: $"
c DB 0AH, 0DH,"The Result of the Sum is: $"
.code
mov ax, @data
mov ds, ax

lea dx,a

mov ah, 09 ; Display


int 21h

mov ah, 01h ; input 1st number


int 21h

mov bl, al

lea dx,b

mov ah, 09 ; Display


int 21h

mov ah, 01h ; input 2nd number


int 21h
add bl, al
AAA

lea dx,c

mov ah, 09 ; Display


int 21h
AAA
mov dl, bl
mov ah, 02
int 21h

ret

OUTPUT
ASCII EQUIVALENT OUTPUT OF HEX 66 THAT IS “f”

HEX EQUIVALENT ASCII VALUES SUM OF 31 AND 35 THAT IS “1” + “5”


=6

TASK 3:
Design a calculator that takes three input numbers from user
and perform addition, subtraction, division and multiplication
on two of them and return the output value to the user. Third
value is used to decide which operation it has to perform e.g.
1=add,2=sub…….

CODE
org 100h
.data
a db 0AH,0DH, "Enter The first number = $"
b db 0ah,0dh, "Enter the Second number = $"
C DB 0AH, 0DH,"1-ADDITION", 0AH, 0DH,"2-SUBTRACT", 0AH, 0DH,"3-MULTIPLY", 0AH,
0DH,"4-DIVIDE", 0AH, 0DH, 0AH, 0DH,"SELECT THE NUMBER: $"
D DB 0AH, 0DH,"THE OUTPUT VALUE IS: $"
NUM1 DB ?
NUM2 DB ?
.code
MOV AX,@data
MOV DS, AX
LEA DX, C
MOV AH, 09
INT 21H
MOV AH, 01H
INT 21H
CMP AL, 31H
JE Addition
CMP AL, 32H
JE SUBTRACTION
CMP AL, 33H
JE MULTIPLICATION
CMP AL, 34H
JE DIVISION

ADDITION:
lea dx,a

mov ah, 09 ; Display


int 21h

mov ah, 01h ; input 1st number


int 21h

mov bl, al

lea dx,b
mov ah, 09 ; Display
int 21h

mov ah, 01h ; input 2nd number


int 21h

add al, bl
AAA
mov bl,al

lea dx,D

mov ah, 09 ; Display


int 21h

add bl, 30h


mov dl, bl

mov ah, 02
int 21h
RET

SUBTRACTION:
lea dx,a

mov ah, 09 ; Display


int 21h

mov ah, 01h ; input 1st number


int 21h

mov bl, al

lea dx,b

mov ah, 09 ; Display


int 21h

mov ah, 01h ; input 2nd number


int 21h

sub al, 30h


sub bl, 30h

SUB bl, al
add bl, 30h

lea dx,D
mov ah, 09 ; Display
int 21h

mov dl, bl
mov ah, 02
int 21h
RET

MULTIPLICATION:
LEA DX, A
MOV AH, 09
INT 21H

MOV AH, 01H ; INPUT IST NUMBER


INT 21H

SUB AL, 30H


MOV NUM1, AL
LEA DX, B
MOV AH, 09
INT 21H
MOV AH, 01H ; INPUT 2ND NUMBER
INT 21H
SUB AL, 30H
MOV NUM2, AL
MUL NUM1
ADD AH, 30H
ADD AL, 30H
MOV BL, AL
LEA DX, D
MOV AH, 09H
INT 21H
MOV DX, BX
MOV AH, 02 ; OUTPUT VALUE
INT 21H
Ret
DIVISION:
LEA DX, A
MOV AH, 09
INT 21H
MOV AH, 01H ; INPUT IST NUMBER
INT 21H
SUB AL,30H;
MOV NUM1, AL
LEA DX, B
MOV AH, 09
INT 21H
MOV AH, 01H ; INPUT 2ND NUMBER
INT 21H
SUB AL, 30H
MOV NUM2, AL
MOV CL, NUM1
MOV CH, 00
MOV AX, CX
DIV NUM2
ADD AH, 30H
ADD AL, 30H
MOV BL, AL
LEA DX, D
MOV AH, 09H
INT 21H
MOV DX, BX
MOV AH, 02 ; OUTPUT VALUE
INT 21H
RET

RET

OUTPUT
First input the 4 methods that is 1-Add, 2-Subtract, 3-Multiply and 4-division and then input “select
the number”. When we select 1 then the code jump to the addition and perform addition between
two inputs numbers. After perform addition then write the code to display the output.

FOR ADDITION:
FOR SUBTRACTION:

FOR MULTIPLICTION:
FOR DIVISION:
THE END

TASK 3:
Write a code to perform addition on 8-bit data stored in consecutive memory
locations (10) and store result in next memory locations. Use any starting
address.

CODE
SOlUTION
STEPS:
 Move the data 200h in the register BX.
 Store 8-bit data in consecutive memory location (10) the memory location is 0200h by using
this [BX].
 Then we used a loop of 10 iterations as “CX=10”
THE END

You might also like