Machine Problem 2, due September 26

Part of the homework for 22C:60, Fall 2005
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Assignment:

Write a main program that traverses the list of items found in any solution to MP1 and prints out the boxes in the list by calling SHOWITEM once for each item in the list.

The file http://homepage.cs.uiowa.edu/~dwjones/assem/hw/mp1test.txt contains Hawk object code for the subroutine SHOWITEM that displays one item on the screen, where the item is described using the data structure from machine problem 1.

When called, SHOWITEM expects register 1 to contain the return address, register 2 to contain the stack pointer, and register 3 to contain the parameter, a pointer to the item. On return, SHOWITEM makes no guarantees about the contents of register 1 and registers 3 to 7. It guarantees that register 2 and registers 8 to 15 will be exactly as they were before the call.

Here is a main program that links to the data structure in mp1.o and to the code in mp2test.o and demonstrates a single call to SHOWITEM.

        TITLE   "mp2.a skeleton by Douglas Jones"

        S       START
        USE     "hawk.macs"
        USE     "monitor.h"

        COMMON  STACK,#1000
PSTACK: W       STACK

; ----------------- linkage ------------------

        EXT     ITEM1
PITEM1: W       ITEM1   ; link to the data structures from mp1

        EXT     SHOWITEM
PSHOWITEM:
        W       SHOWITEM; link to the code in mp2test.o

        SUBTITLE "main program"
; --------------------------------------------
START:
        LOAD    R2,PSTACK       ; set up the stack

        LOAD    R1,PDSPINI
        JSRS    R1,R1           ; initialize the display

        LOAD    R3,PITEM1       ; parameter p = pitem1, points to an item
        LOAD    R1,PSHOWITEM
        JSRS    R1,R1           ; call showitem( p )

        LOAD    R1,PEXIT
        JSRS    R1,R1           ; call monitor routine to stop!

        END

Assuming that you have a copy of any solution to machine problem 1 in the same directory your are using to develop your solution to machine problem 2, you can assemble, link and test your code using the following commands.

        [you@serv16 ~/assem]$ smal mp1.a

           no errors
        [you@serv16 ~/assem]$ smal mp2.a

           no errors
        [you@serv16 ~/assem]$ link mp1.o mp2.o mp2test.o

           no errors
        [you@serv16 ~/assem]$ hawk link.o

The last command above starts the Hawk emulator to run the test program; running this code will be exactly like running the test program for machine problem 1. Once you have assembled a copy of mp1.o, you will not need to re-assemble it again, so you will need to use the first line only once.

Additional Requirements:

In addition to code that runs as assigned, you are responsible for producing readable code! Clean use of indenting, and appropriate comments that explain anything slightly subtle are required! Your solution must also conform to the following specific details:

  1. The file must be named mp2.a.
  2. It must begin with a TITLE directive saying MP2 followed by your name as it appears on your university ID card.
  3. The file must be named mp2.a

Submit your result:

Use the submit command on the departmental linux cluster to submit your solution. Your complete submit dialogue will look just like the dialogue illustrated on the handout for machine problem 1, except that your choice will be mp2 and your file will be mp2.a.

Grading:

Your program will be assembled and the result linked to our test data. If the output is right when we run it, you will get half credit. The other half of the credit will be assigned based on the quality of your source file (see the list of requirements for the assignment). The listing file will be printed by the TA and marked up with comments about how you could improve your code.