Assignment 4, due September 16

Part of the homework for 22C:60, Fall 2005
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, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

  1. Background:

    Here is a bit of Hawk assembly code:

    .	=	0
    	LIS	R1,1
    	ADD	R2,R1,R1
    	ADDI    R3,R2,2
    	MOVE	R4,R3
    	ADDSI	R4,4
    	LIL	R5,16
    	ADD	R6,R5,R4
    	ADD	R6,R6,R4
    	LIS	R7,0
    	ORIS	R7,64
    

    a) For each line of the above, add a comment saying what register the indicated machine instruction changes, what value it puts there, and where or how did it get that value. (1 point)

    Suggestion: Model your answer on the following:

    	LOAD	R3,R4  ; R3 gets the word R4 points to in memory
    

    b) By hand, assemble this code, and show the result as a sequence of SMAL halfword directives, with their operands expressed in hexadecimal. Add comments on each line that holds the first (or only) halfword of an instruction showing the source code that produced that halfword (and any uncommented ones that follow). (1 point)

    Suggestion: Model your answer on the following:

    	H	#F3D4	; LOAD	R3,R4
    

    Hint: You can use the assembler to check your answer, but to do this you will need to add some "boilerplate" to the code. Once you do this, look at the object file to see what the assembler did for you happened.

  2. Given: 32-bit integer variables a and b are stored in Hawk memory locations 1060016 through 1060716 (inclusive and in that order).

    Assignment: Write a fragment of SMAL Hawk assembly code equivalent to the following high-level language code. (1 point)

    int temp = a; a = a + (b - 16); b = (temp + a) + 16;

    Note: The variable temp is temporary, you can use a register to hold it instead of putting it in memory.