Machine Problem 6, due July 29

Part of the homework for CS:2630, Spring 2015
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Background: The Sparrowhawk is a computer that supports a subset of the Hawk instruction set. When the Sparrowhawk encounters a Hawk instruction that is not part of the Sparrowhawk subset, for example, an LIL or STORE instruction, it responds with an instruction trap. That is, control transfers to address 2016 after the program counter is saved in the TPC (trap program counter) register.

The trap-handler code starting at address 2016 can do anything it wants with the instruction trap. The default trap handlers for the Hawk and Sparrowhawk simply output a message saying that there was an instruction, output the saved program counter value, and then halt. Homework 12 discusses some extremely simple trap handlers for the Hawk and Sparrowhawk.

A more sophisticated trap handler can virtualize the missing instructions by completing the operations that the CPU was unable to complete before returning to the user program that caused the trap. A program running on a correctly constructed virtual Hawk will behave exactly the same as a program running on a real Hawk, except that some instructions will be much slower.

The Assignment: A trap handler that does this has been written and tested. See:
-- http://homepage.cs.uiowa.edu/~dwjones/assem/hw/mp6.txt

Note, however, that two segments of this code, the parts that support the LEACC and LOAD instructions have been deleted. Your assignment is to replace the missing code.

You must, of course, change the title to include your name, and you must change the header comments to reflect what you have done and where you got the original, but aside from that, you must not change any part of the program aside from the areas where comments indicate that code was deleted.

Linking and Running under the Sparrowhawk: To link and run a Hawk program (for example, mp4.o) under the sparrowhawk with your trap service routine installed, you must do the following:

        link -m sparrowmon.o mp6.o mp3.o
        sparrowhawk link.o

By way of explanation: The -m option to the Hawk linker prevents the Hawk from linking with the standard Hawk monitor. sparrowmon.h installs the default sparrowhawk monitor. mp6.o installs your trap service routine over the monitor, and mp4.o is the Hawk software you are using to test your code.

You can, of course, test your code with any user program. To test it with the code for MP5, replace mp3.o in the above with mp5.o mp5test.o.

For debugging, we strongly suggest that you use very simple test programs containing just one genuine hawk instruction, with the rest of the code written in the Sparrowhawk subset.

Submission: As usual, use the on-line (and rather clunky) submit command, selecting the course CS2630 and the assignment mp6; your source file must be named mp6.a and it must contain a title line formatted (as usual) as:

        TITLE   "mp6.a by Yourname Here"

Of course, substitute your own name for Yourname Here, since we do not know of any students named Here.