Assignment 3, due Feb 8

Part of the homework for 22C:60 (CS:2630), Spring 2013
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

  1. Background: Consider the following code, written in SMAL:
            B       239
            B       -66
            H       57005
    

    A Problem: If you assemble this and load it into memory, these two bytes plus a halfword can be viewed as a single word in memory. What is the value of that word in hexadecimal? (1.2 points)

    Suggestion: Do it by hand first, converting the three parts to binary and then shuffling them into the correct fields of a 32 bit word before converting the results to hex. Then check your work by assembling this code using the SMAL assembler and then loading the resulting object file into the Hawk emulator to see what actually loads in memory. If you do this, you prove that you understand what the assembler did and you check your work.

  2. Background: Here is a fragment of SMAL code that creates a null-terminated linked list data structure, where each element contains a pointer to the next element of the list and an integer. The head of the list has the label HEAD.
    NULL    =       0
    VALUE   =       1
    BIG     =       2
    
    HEAD:   W       CO,  VALUE+BIG
    AX:     W       DE,  VALUE
    BE:     W       NULL,(BE-HEAD)+1
    CO:     W       EE,  BIG >> VALUE
    DE:     W       BE,  (DE-CO)+1
    EE:     W       AX,  BIG+BIG
    

    a) What values does this place in memory? As above, you will learn more from this question if you do it by hand and then check your work using SMAL. (0.6 points)

    b) If you traverse this list, starting at the head and continuing until you reach a null pointer, what integer values are found in each list element (list them from left to right and you should almost recognize a pattern -- unfortunately, the problem statement above got scrambled, and the last two list elements break the intended pattern). (0.6 points)

  3. A Problem: The instructions for MP1 say to hit the r key twice in order to run your code. The instructions explain that the first time you hit the r key, it runs some kind of operating system code. What values are in registers 1 to 4 after the first time you hit r (these depend only on the little bit of operating sytem code). (0.6 points)