Write an interrupt routine to handle division by zero, Computer Engineering

Assignment Help:

Q. Write an interrupt routine to handle 'division by zero'?

This file can be loaded just like a COM file though makes itself permanently resident until the system is running.

This ISR is splitted into two main sections: initialisation and interrupt handler. The initialisation procedure (INIT) is executed just once when program is executed from DOS level. INIT takes over the type zero interrupt vector and it also prints a sign-on message and then performs a terminate and 'stay resident exit' to MS-DOS. This special exit reserves memory occupied by program so that it's not overwritten by subsequent application programs. The interrupt handler (ZDIV) receives control when a divide-by-zero interrupt takes place.

CR                            EQU      ODH  ; ASCII carriage return

LF                             EQU       0Ah    ; ASCII line feed

BEEP                          EQU    07h      ; ASCII beep code

BACKSP                 EQU      08h      ; ASCII backspace code  

CSEG SEGMENT PARA PUBLIC 'CODE' 

 ORG 100h

 ASSUME CS: CSEG, DS: CSEG, ES: CSEG, SS: CSEG

INIT PROC NEAR

MOV                        DX,OFFSET ZDIV      ; reset interrupt 0 vector

                                                                        ; to address of new

                                                                        ; handler using function 25h, interrup

MOV                        AX, 2500h                     ; 0 handles divide-by-zero

INT                           21h  

MOV                        AH,09                            ; print identification message

INT                           21h  

                                                                        ; DX assigns paragraphs of memory

                                                                        ; to reserve

MOV                        DX, ((OFFSET PGM_LEN + 15)/16) + 10h

MOV                        AX, 3100h                     ; exit and stay resident

INT                           21h                                 ; with a return code = 0

INIT ENDP

 

ZDIV PROC FAR                                                     ; this is the zero-divide

                                                                        ; Hardware interrupt handler.

STI                                                                  ; enable interrupts.

PUSH AX                                                       ; save general registers

PUSH BX

PUSH CX

PUSH DX

PUSH SI

PUSH DI

PUSH BP

PUSH DS

PUSH ES

MOV AX, CS   

MOV DS, AX   

MOV   DX, OFFSET WARN                                                            ; print warning "divide by

MOV AH, 9                                                                            ; zero "and" continue or

INT 21h                                                                                  ; quit?"

 

ZDIV1: MOV                         AH, 1                          ; read keyboard

INT                                         21h  

CMP                                        AL, 'C'                       ; is it 'C' or 'Q'?

JE                                            ZDIV3                                    ; jump it is a 'C'.

CMP                                        AL, 'Q'  

JE                                            ZDIV2                        ; jump it's a'Q'

MOV                                       DX, OFFSET BAD   ; illegal entry, send a

MOV                                       AH, 9                                      ; beep, erase the bad char

INT                                         21h                              ; and try again

JMP   ZDIV1

ZDIV2: MOV                         AX, 4CFFh                 ; user wants to abort the

   INT                                                  21h                              ; program, return with

                                                                                    ; return code = 255

ZDIV3: MOV                         DX, OFFSET CRLF   ; user wishes to continue

MOV                                       AH, 9                                      ; send CRLF

INT 21h  

POP ES                                                                       ; restore general registers

POP DS                                                                      ; and resume execution

POP BP  

POP DI  

POP SI  

POP DX  

POP CX  

POP BX  

POP AX  

IRET    

ZDIV   ENDP

SIGNON                    DB   CR, LF, 'Divide by zero interrupt'

                                    DB 'Handler Installed'

                                    DB   CRLF,'$'

WARN                        DB CR, LF, 'Divide by zero detected:'

                                    DB CR, LF 'Quit or Continue (C/Q)?'

                                    DB '$'

BAD                           DB BEEP, BACKSP, "BACKSP,'$'

CRLF                          DB CR, LF, $'

PGM_LEN                 EQU $-INIT 

CSEG ENDS

END


Related Discussions:- Write an interrupt routine to handle division by zero

How do we save a selected sub-image to a file in gimp, Use "Edit->Paste As-...

Use "Edit->Paste As->New Image" menu command or press Ctrl-Shift-V key combination, then save newly created image.The script-fu-selection-to image can also be used to cut a selecti

Experiment with neural network, Assignment 3.b: Experiment with Neural Netw...

Assignment 3.b: Experiment with Neural Network Background: In this assignment, you will experiment with neural network for solving different types of practical problems. Y

What is the importance of hierarchy of operators, Bring out the importance ...

Bring out the importance of hierarchy of operators?  The operators  within  C are grouped  hierarchically according to their precedence(i.e., order of evaluation). Operations w

What is a demultiplexer, What is a Demultiplexer ? Ans. Demultiplex...

What is a Demultiplexer ? Ans. Demultiplexer has similar circuit as decoder but here E is obtained as the particular input line, the output lines are similar as decode

Process of world wide web, Q. Process of World Wide Web? When you type ...

Q. Process of World Wide Web? When you type a URL in a web browser, this is what happens: 1. If URL contains a domain name, browser first connects to a domain name server an

Why did my jdbc code throw a rollback sqlexception, Your JDBC code may thro...

Your JDBC code may throw the following exception: "The coordinator has rolled back the transaction.No further JDBC access is permitted within this transaction." The WebLogic

Computer organisation, How many 32K X 1 RAM chips are needed to provide a m...

How many 32K X 1 RAM chips are needed to provide a memory capacity 256 kilobytes?

What is the bios full form, BIOS - Basic Input Output System, Power On ...

BIOS - Basic Input Output System, Power On Self Test (POST) and Loading Bootloader from the Hard disk drive Boot Sector is being completed by BIOS. It started the system for

DBMS SQL Queries, How to fetch random ID from table by SQL query Select ...

How to fetch random ID from table by SQL query Select * from Table_Name order by NewID()

Poor human support - obstacle to information system, Poor human support - O...

Poor human support - Obstacle to Information System The full utility of an IS will only be realised if it is properly supported by the users. Technology is never a solution in

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd