Homework 9
MSDOS/BIOS
Programming

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\"

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 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 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:

  1. eAx - the signed number to display,
  2. eDx - the address of the string to display.

Replace the above two code fragments 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 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

  1. See the OverFlow Interrupt Handler in the notes for a complete example of setting up an interrupt handler.
  2. See the text on the range of values allowed for the ReadInt function.
  3. For Part 2, the INT 50 routine should use the WriteString and WriteInt functions.