0% found this document useful (0 votes)
60 views3 pages

18BCE363 - Practical 10

This document contains assembly code to handle a divide overflow error. It defines an interrupt service routine (ISR) called "bad_div" that will be called if a divide by zero error occurs. The main program divides several numbers by a scale factor and checks for the error flag after each division. If the flag is set, it stores a 0 in the results array instead of the quotient. This allows the program to handle the error and continue executing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views3 pages

18BCE363 - Practical 10

This document contains assembly code to handle a divide overflow error. It defines an interrupt service routine (ISR) called "bad_div" that will be called if a divide by zero error occurs. The main program divides several numbers by a scale factor and checks for the error flag after each division. If the flag is set, it stores a 0 in the results array instead of the quotient. This allows the program to handle the error and continue executing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical-10

Roll No: ​18BCE363


Name:Praful parmar
Aim: ​Write an assembly program to ​Design an ​ISR to handle divide overflow
error.

main.asm
data segment word public
input_values dw 0035h, 0855h, 2011h, 1359h
scaled_values db 4 dup(0)
scale_factor db 09
bad_div_flag db 0
data ends

stack_seg segment stack


dw 100 dup(0)
top_stack label word
stack_seg ends

public bad_div_flag

int_proc segment word public


extrn bad_div:far
int_proc ends

code segment word public


assume cs:code,ds:data,ss:stack_seg
start:
mov ax,stack_seg
mov ss,ax
mov sp, offset top_stack
mov ax,data
mov ds,ax

mov ax,0000
mov es,ax
mov word ptr es:0002, seg bad_div
mov word ptr es:0000, offset bad_div

mov si,offset input_values


mov bx,offset scaled_values
mov cx, 0004
next:
mov ax,[si]
div scale_factor
cmp bad_div_flag,1
jne ok
mov byte ptr [BX], 00
jmp skip
ok:
mov [bx],al
skip:
mov bad_div_flag,0
add si,02
inc bx
dec cx
cmp cx,0
jne next
stop:
mov ax,4ch
int 21h
code ends
end start

isrdiv.asm
data segment word public
extrn bad_div_flag:byte
output db 'Bad Division : Division Error Was Occured$'
data ends
public bad_div

int_proc segment word public


bad_div proc far
assume cs:int_proc,ds:data
push ax
push ds
push dx
mov ax,data
mov ds,ax
mov bad_div_flag,01
mov ah,09h
lea dx,output
int 21h
pop dx
pop ds
pop ax
iret
bad_div endp
int_proc ends
end

Output:

You might also like