Machine Problem 6, due May 4

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

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

A more sophisticated trap handler can virtualize the missing instructions by completing the operations that the CPU was unable to complete and then returning to the user program. 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 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 mp4.o
        sparrowhawk link.o

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. If you use a solution to MP5, for example, it will not use any of the virtualization code. If you take that MP5 code and switch just one intruction from the Sparrowhawk version back to the Hawk version, you can test your virtualization of just one instruction. This allows you to work incrementally.

Submission: As usual, use the on-line (and rather clunky) submit command, selecting the course cs_2630 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.

Fair Warning: The midterm exam on Friday, April 24, will require that you be familiar with this assignment.