Homework 9 - Interrupts

Overview

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

Part 1

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:

Part 2

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:

  1. Ax - a signed number to display,
  2. Cx - the length of the string,
  3. Di - the offset of the string to display.

Replace the above two code segments with the appropriate parameter initialization and Int 50 instruction for each.

Turn in

  1. Cover page  - Your name, date, and Homework 9. Staple all papers together.
  2. Listing of Homework 9 program.
  3. Output  - Provide output of six test executions:

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
Document last modified: