Assignment 3, due Sept. 11

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

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!

Problems

  1. Background: Consider this bit of SMAL code that defines a constant data structure in RAM:
            NULL	=	0
    
            A:      W       B
                    W       Aend - Abegin
            Abegin: ASCII   "A string"
    	Aend:
    
            B:      W       C
                    W       Bend - Bbegin
            Bbegin: ASCII   "begins with a"
    	Bend:
    
            C:      W       NULL
                    W       Cend - Cbegin
            Cbegin: ASCII   "character"
    	Cend:
    

    a) If words are required to be aligned in memory, what align directives must be added to the above code? (0.4 points)

    b) If words are required to be aligned in memory, what additional align directives should be added to the above code? (0.4 points)

    c) Assemble the above code using the SMAL assembler, with the ALIGN directives you believe are appropriate in answer to parts a) and b). Directives you believe are a, mandatory or b, merely recommended should be commented as such. (0.4 points)

    A properly commented assembly listing for the above code is a sufficient answer for parts a), b) and c) of this problem.

    d) The data structure starting at A: in the above code can be described as consisting of several objects, some of which may have several components. In English, give a brief description of both the nature of these objects and how they are connected. An adequate answer can be written in well under 50 words. Answers that are excessively long may be penalized. (0.4 points)

    e) The top-level objects in the above example could be several of a single class or structure. We don't know the methods of that class, but we can describe the structure of instances of this class. Give a declaration of this class or structure (omitting the methods, since we don't know them) in any high-level programming language you know that is sufficiently expressive to solve this problem. (0.4 points)

  2. Background: Consider this bit of SMAL code that defines a constant data structure in RAM:
    	X	=	.
    	.	=	. + 4
    	Y	=	.
    		ASCII	"ABCDE"
    	Z	=	.
    	.	=	X
    		W	Z - Y
    	.	=	Z
    
    Assume that the initial value of the location counter is 100016.

    a) What are the values of the symbols X, Y and Z? (0.5 points)

    b) Show the contents of the memory locations changed by this code. Give your answer in hexadecimal, showing memory as a sequence of consecutive 32-bit words. (0.5 points)