Machine Problem 1, Supplement

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

Testing Your Solution

To test your solution to MP1, you need a program that can traverse your data structure and follow the instructions encoded in that data structure to print out the boxes and you've encoded. The file http://homepage.cs.uiowa.edu/~dwjones/assem/hw/mp1test.txt does this.

To test your solution, get a copy of this file (cut and paste from the web, for example, or use the download command from your web browser) and save it as a text file named mp1test.o in the same working directory you are using to do machine problem 1. Then do as follows:

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

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

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

The last command above starts the Hawk emulator to run the test program linked together with your data structure. When the emulator starts up, it will show something like this:

 HAWK EMULATOR
   /------------------CPU------------------\   /----MEMORY----\
   PC:  000010D0                R8: 00000000   0010CC: CPUSET  R0,#0
   PSW: 00000000  R1: 00000000  R9: 00000000   0010CE: NOP
   NZVC: 0 0 0 0  R2: 00000000  RA: 00000000 ->0010D0: LOAD    R2,#0010C8
                  R3: 00000000  RB: 00000000   0010D4: LOAD    R1,#00109C
                  R4: 00000000  RC: 00000000   0010D8: JSRS    R1,R1
                  R5: 00000000  RD: 00000000   0010DA: LOAD    R3,#0010CC
                  R6: 00000000  RE: 00000000   0010DE: JSR     R1,#0010E8
                  R7: 00000000  RF: 00000000   0010E2: LOAD    R1,#001098

 **HALTED**  r(run) s(step) q(quit) ?(help)

The final line is the command prompt. For now, the only thing that matters is that you hit the r key to start the emulator running the test program. Control-c will stop the emulator if it gets hung in an infinite loop and q will exit back to the command shell. If your data structures are correct, running the emulator will give you this:

 **HALTED**  r(run) s(step) q(quit) ?(help)


     +---------------+           +---+    +
     | text in a box |------+    | A |    |
     +---------------+      |    | B | +-----------+
        |                   |    | C |    |
        +-------------------+    +---+    +  

If you make a mistake with the pointers in your data structures, the bottom half of the screen might end up like this:

 **HALTED**  r(run) s(step) q(quit) ?(help)

Bus Trap.          Trap PC = #0000111E
     +-----------  Trap MA = #00010000
     | text in a   Trap PSW= #00010008
     +---------------+      |    | B |
        |                   |    | C |
        +-------------------+    +---+

The message "Bus Trap" indicates that the program raised an exception by attempting to access an unimplemented memory address (that is, some part of the address space that didn't have RAM plugged into it). In this case, it happened after the program had plotted the third box in the series of boxes, so it must have been the third pointer in the linked list that had a bogus value. The values of the registers will be of little use when using a program you didn't write, so just ignore them.