Assignment 3, due Feb 3

Part of the homework for 22C:60 (CS:2630), Spring 2012
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 string labeled MESSAGE in Machine Problem 1:
    MESSAGE:
            B       'M'
            B       #65
            B       8#163,'s'
            H       #6761
            H       #2065
            W       #6D6F7266
            ASCII   " MP1",0
    
    a) Give equivalent SMAL code for the first 3 B directives, using just 1 B directive with 4 arguments, where all arguments are quoted character constants. (0.4 points)

    b) Give an ASCII character string equivalent to the two H directives. (0.4 points) c) Give a sequence of 4 B directives equivalent to the W directive in the code, with the arguments given in hexadecimal. (0.4 points)

    d) Give a sequence of 2 H directives equivalent to the W directive in the code, with the arguments given in hexadecimal. (0.4 points)

    e) Give a sequence of B directives equivalent to the ASCII directive, with argumets given in hexadecimal. (0.4 points)

    Note: You should read Section 3 of the SMAL manual before doing this. Sections 1.4 and 1.5 are relevant, as is section 2.5. Chapter 3 of the notes is also critical. One way to check your work is to substitute your solution into a spare varsion of MP1 and test it. If you get it right, the output should not change.

  2. Background: Consider this SMAL code, based on exercise p) from Chapter 3 of the notes, with a bit of extra code added:
    .       =       0
    A:      B       1
    B:      W       2
    C:      B       3
    D:      H       4
    E:      W       5
    

    a) What are the values of the identifiers A, B, C, D and E. (0.5 points)

    b) If you add ALIGN directives so that each byte, halword or word is aligned as required for use on a Hawk computer (exercise q) what values result for the identifiers? (0.5 points)

    Note: You can solve this by reading Chapter 3 of the notes; Sections 2.1 and 3 of the SMAL manual are also relevant. You can check your work by using the SMAL assembler and then reading the assembly listing. Seciton 10.2 of the SMAL manual is relevant to the latter, and Section 10.3 provides an alternative way to use the SMAL assembler to help solve this problem.