Homework 9
|
Modified: |
Building and Executing
The text author provides instructions on building and executing MSDOS programs.
See Building 16-bit Applications (Chapters 14-17) in http://kipirvine.com/asm/gettingStartedVS2010/index.htm
Edit C:\Irvine\make16.bat, change:
SET MASM="C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\"
to
SET MASM="C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\"
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 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 fragments to display a string and a signed number:
Lea eDx, xplusy
Call WriteString
Call WriteInt
Call CrLf
:
Lea eDx, xdivy
Call WriteString
Call WriteInt
Call CrLf
|
Implement a type 5010 interrupt routine to display a string (the address is in eDx) and a signed number (in eAx). The INT 50 routine takes two parameters:
Replace the above two code fragments with the appropriate parameter initialization and INT 50 instruction for each.
- Using original program below
- Input x and y where no error occurs due to addition overflow or division.
- Input x and y where an overflow error occurs but not division.
- Input x and y where a division error occurs.
- Your program with interrupt handlers for overflow and division errors, and printing the string and signed number (i.e. type 0, 4, and 50 interrupts).
- Input x and y where no error occurs due to addition overflow or division.
- Input x and y where an overflow error occurs but not division.
- Input x and y where a division error occurs.
Original Program - Modify the following program for Part 1 and Part 2.
Title HW9 - Interrupts INCLUDE Irvine16.inc
.data
xprompt db "x ",0
yprompt db "y ",0
xdivy db "x/y=",0
xplusy db "x+y=",0
x dword ?
y dword ?
.code
main Proc near ; void main() {
Mov Ax, @data
Mov Ds, Ax
Mov Es, Ax
Lea eDx, xprompt
Call WriteString ; cout << xprompt ;
Call ReadInt ; cin >> x ;
Mov x, eAx
Call CrLf
Lea eDx, yprompt
Call WriteString ; cout << yprompt ;
Call ReadInt ; cin >> y ;
Mov y, eAx
Call CrLf
Mov eAx, x ; eAx=x+y
Add eAx, y
Into ; Interrupt on overflow
Lea eDx, xplusy
Call WriteString
Call WriteInt ; cout << x+y ;
Call CrLf
Mov eAx, x ; eAx=x/y
Cdq
IDiv y
Lea eDx, xdivy
Call WriteString
Call WriteInt ; cout << x/y ;
Call CrLf
Mov Ah, 4ch
Int 21h
main Endp ; }
End main
|
Hints
- See the OverFlow Interrupt Handler in the notes for a complete example of setting up an interrupt handler.
- See the text on the range of values allowed for the ReadInt function.
- For Part 2, the INT 50 routine should use the WriteString and WriteInt functions.