Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9574803

Have any Question?


Related Questions in Computer Engineering

Question what sequence of numbers would be printed by the

Question : What sequence of numbers would be printed by the following recursive function if we started it with N assigned the value 1? def Exercise (N): print(N) if (N Exercise(N + 1) print(N)

Respond to the statement below in at least 100 words

Respond to the statement below in at least 100 words. Original answers only. If developers are making decisions on the requirements, then how do they know that the software will work properly for the end user? Developers ...

Questions 1 what are the four parts of the administrative

Questions: 1. What are the four parts of the administrative simplification requirements of HIPAA? 2. Name three factors used to determine whether you need to comply with HIPAA. 3. What are the three categories of entitie ...

Question discuss in 500 words how you would advise your

Question: Discuss, in 500 words, how you would advise your current employer to use encryption to reduce the vulnerabilities of their data at rest, in use, and in transit (or in motion). Identify at what points you think ...

1 what is the purpose of exclusive gates such as the xor

1. What is the purpose of exclusive gates such as the XOR and XNOR? 2. What function do these gates perform?

Question provide a real-world example or describe a

Question: Provide a real-world example or describe a hypothetical situation in which a legitimate organization used spam in an effective and nonintrusive manner to promote a product or service. Need 300-350 words APA sta ...

Assignment -note in your assignment how you arrived at your

Assignment - Note: In your assignment, how you arrived at your solution is as important (if not more so) than the solution itself and will be assessed accordingly. There may be more than one way to find a solution, and y ...

When talking about economics and the history of it for the

When talking about Economics and the history of it. For the past recessions the U.S. has had, do we look at it mostly on the loan side of the banks or what causes most recessions?

Question a file is to be shared among different processes

Question : A file is to be shared among different processes, each of which has a unique id number and a priority level number. The file can be accessed simultaneously by several processes, subject to the following constr ...

Discuss honeypots are they legal should they be legal what

Discuss honeypots. Are they legal? Should they be legal? What are some of the potential problems for those implementing a honeypot?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As