Machine Problem 5, due Apr 13

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

Background: Consider the following sequence of 4 figures:

0   1     2          3
[]  []    [][]       [][][][]
    [][]  []         []    []
          []    []   []
          [][][][]   [][]
                     [][]        [][]
                     []            []
                     []    [][]    []

You've seen this problem before. That was Machine Problem 4. Take any solution to MP4 (but as always, document where you got it) and modify the code so that it runs on the Sparrowhawk subset of the Hawk architecture. To do that, start by replacing this line of the original code:

        USE     "hawk.h"

With these lines:

        USE     "sparrowhawk.h"

This gives you a version of the Hawk instruction set that omits all of the 32-bit instructions. You still have 32-bit registers, of course, but no long instructions.

When you run your program, use sparrowhawk link.o instead of hawk link.o. In the Sparrowhawk emulator, all use of the missing instructios will give you an instruction trap.

You are welcome to look at the source of the sparrowhawk.h file to see how, if you don't use the strict subset, it provides automatic support for long instructions. There is a section of the file set off in an IF - ENDIF block that is suppressed by defining STRICTSPARROW that shows how to assemble all of the missing instructions, but these macros are messy.

Your job is to write reasonably comprehensible code within the strict Sparrowhawk subset of the Hawk instruction set. Your code should be written with reasonable comments and intended to be human readable (to the extent that assembly code is ever human readable). Your code must not, for example, include things like this:

        W const

Linking and Running under the Sparrowhawk: To link and run a program under the sparrowhawk, in addition to the changes required to your source program, you must do the following:

        link -m sparrowmon.o mp5.o
        sparrowhawk link.o

The -m option to the Hawk linker prevents the Hawk from linking with the standard Hawk monitor. sparrowmon.h is a rewrite of the Hawk monitor that runs on the Sparrowhawk.

You can, of course, link and run your program on the Hawk, since all Sparrowhawk programs should run perfectly well on the Hawk. This lets you eliminate all the long instructions one at a time, checking if the program still runs at each step, before finally running it with sparrowhawk.h in strict mode.

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

        TITLE   "mp5.a by Yourname Here"

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