The purpose of the assignment is to develop some intuition about interrupts, important to understanding operating systems and the interfacing of hardware to computer systems. The assignment examines hardware interrupts generated by the CPU when division or overflow errors occur and the use of DOS and BIOS interrupts
Modify the following program that inputs two 16-bit signed numbers, x and y, and displays x+y and x/y. Interrupt handlers should be implemented for:
The program contains the following two nearly identical code segments to display a string and a signed number:
Mov Cx, 4
Lea Di, xdivy
Call PutStrng
Mov Bh, 0
Call Putdec
Call NewLine
...
Mov Cx, 4
Lea Di, xplusy
Call PutStrng
Mov Bh, 0
Call Putdec
Call NewLine
|
Implement a type 5010 interrupt routine to display a string and a signed number that takes three parameters:
Replace the above two code segments with the appropriate parameter initialization and Int 50 instruction for each.
- Original program
- No error occurs due to addition overflow or division.
- An overflow error occurs but not division.
- A division error occurs.
- Your program with interrupt handlers for overflow and division errors and printing (i.e. type 0, 4, and 50 interrupts).
- No error occurs due to addition overflow or division.
- An overflow error occurs but not division.
- A division error occurs.
Original Program - Modify the following program to implement interrupt handlers for overflow and division errors.
Title HW9 - Interrupts
; v:\common\user\c335\assembler
; ml hw9.asm /link io.lib
; hw9
.model small
Extrn Getdec:Far ; #include <iostream.h>
Extrn Putdec:Far
Extrn PutStrng:Far
Extrn NewLine:Far
.data
xprompt db "x "
yprompt db "y "
xdivy db "x/y="
xplusy db "x+y="
x dw ?
y dw ?
.code
main Proc near ; void main() {
Mov Ax, @data
Mov Ds, Ax
Mov Es, Ax
Mov Cx, 2
Lea Di, xprompt
Call Putstrng ; cout << xprompt ;
Call Getdec ; cin >> x ;
Mov x, Ax
Mov Cx, 2
Lea Di, yprompt
Call Putstrng ; cout << yprompt ;
Call Getdec ; cin >> y ;
Mov y, Ax
Mov Ax, x ; Ax=x/y
Mov Dx, 0
IDiv y
Mov Cx, 4
Lea Di, xdivy
Call PutStrng
Mov Bh, 0
Call Putdec ; cout << x/y ;
Call NewLine
Mov Ax, x ; Ax=x+y
Add Ax, y
Into ; Interrupt on overflow
Mov Cx, 4
Lea Di, xplusy
Call PutStrng
Mov Bh, 0
Call Putdec ; cout << x+y ;
Call NewLine
Mov Ah, 4ch
Int 21h
main Endp ; }
End main
|