Assignment 3, due Feb 7

Part of the homework for 22C:60 (CS:2630), Spring 2014
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 this fragment of SMAL assembly code:
    .       =       100000
    A:      B       "h","i","l","l"
    .       =       A + 1
    B:      B       "e"
    .       =       B + 3
    C:      ASCII   "o girth"
    .       =       C + 2
    D:      ASCII   "wo"
    .       =       D + 3
    E:      B       "l","d"
    

    a) When this code is assembled for the Hawk computer system our class is using, does the data go in RAM, ROM, or some other memory region? (0.2 points)

    b) Show the contents of memory locations 100000 through 100010 after the above code is assembled and loaded into memory. Show it as a sequence of bytes (not halfwords or words) with the contents of each byte interpreted as an ASCII character. (0.8 points)

    c) Show the contents of memory location 100004 as a 32-bit word in hexadecimal. (0.5 points)

    Note: You will learn the most if you do this by hand first, and then check your work by using the SMAL assembler to assemble the code and then use the Hawk emulator to load the object file and display the contents of memory in hex and ASCII.

  2. Background: Here is a fragment of SMAL assembly code for a linked list, where each list element consists of 2 words, first a pointer to (the address of) the next element and then an integer value:
    .       =       #1000
    NIL     =       0
    HEAD:   W       P, 3
    A:      W       N, 1
    C:      W       E, 9
    E:      W       NIL, 3
    N:      W       C, 5
    P:      W       R, 1
    R:      W       A, 4
    

    a) Give the integer values of the list elements starting with the element with the label HEAD and continuing until the end of the list (the value NIL in the pointer field marks the end). (0.5 points)

    b) Give the contents, in hexadecimal, of the 4 words of memory starting at location 100016. (0.5 points)

  3. A simple question: Give a simple rule describing when an ALIGNdirective should be inserted into the assembly code. (0.2 points)

  4. Background: The following SMAL code assembles a Hawk ADD instruction into memory:
            B       #31
            B       #23
    

    a) What is the destination register? (0.1 points)

    b) What is the first source register? (0.1 points)

    c) What is the second source register? (0.1 points)