Assignment 4, due Sep 16

Part of the homework for 22C:60 (CS:2630), Fall 2011
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 SMAL code
            USE     "hawk.h"
    .       =       0
            LIS     R1,1
            ADDI	R2,R1,1
            LIL     R3,3
            MOVE    R4,R2
            ADDSI   R4,2
            ADD     R5,R3,R2
    

    a) If execution begins at location zero and all 6 of the above instructions are executed, what values do these instructions leave in registers? (0.5 points).

    a) Show the contents of the memory locations that hold the above code. That is, show what the assembler (plus the loader) put into RAM when the above code is assembled. (1.0 points)

    Note: Both of the above problems are typical exam questions from the first midterm. You must learn how to do this by hand, but you can check your answers using the assembler and the Hawk emulator.

  2. An Exercise From The Text: Do exeercise l) from Chapter 4, at the end of the section on Memory Reference Instructions.

  3. Background: Suppose you wanted to come up with a general rule for load immediate. You could express this as a macro called LI that would automatically select the best load instruction. The following macro does this in SMAL, given appropriate values for x, y, z and w.
            MACRO LI =dst, =const
              IF (const > x) & (const < y)
                LIS dst,const
              ELSEIF (const > z) & (const < w)
                LIL dst,const
              ELSE
                LIW dst,const
              ENDIF
            ENDMAC
    

    A Question: Give the appropriate values for x, y, z and w. (0.5 points)

  4. A Problem: When you run the Hello World program from Chapter 5, what are the values of the registers immediately prior to the execution of the JSRS instruction that calls puts()? (0.5 points)