Department of Electrical and Computer Engineering

The University of Texas at Austin

EE 360N, Spring 2007
Problem Set 1b
Due: before class January 31st, 2007
Yale N. Patt, Instructor
Chang Joo Lee, Rustam Miftakhutdinov, Poorna Samanta, TAs

Instructions

You are encouraged to work on the problem set in groups and turn in one problem set for the entire group. Remember to put all your names on the solution sheet. Also remember to put the name of the TA in whose discussion section you would like the problem set turned back to you.

You will need to refer to the assembly language handouts and the LC-3b ISA on the course website.

Questions

  1. Consider the following LC-3b assembly language program:

            .ORIG x3000
    	AND R5, R5, #0
    	AND R3, R3, #0
    	ADD R3, R3, #8
    	LEA R0, B
    	LDW R1, R0, #1
    	LDW R1, R1, #0
    	ADD R2, R1, #0
    AGAIN	ADD R2, R2, R2
    	ADD R3, R3, #-1
    	BRp AGAIN
    	LDW R4, R0, #0
    	AND R1, R1, R4
    	NOT R1, R1
    	ADD R1, R1, #1
    	ADD R2, R2, R1
    	BRnp NO
    	ADD R5, R5, #1
    NO	HALT
    B	.FILL XFF00
    A	.FILL X4000
    	.END
    1. The assembler creates a symbol table after the first pass. Show the contents of this symbol table.

    2. What does this program do? (in less than 25 words)

    3. When the programmer wrote this program, he/she did not take full advantage of the instructions provided by the LC-3b ISA. Therefore the program executes too many unnecessary instructions. Show what the programmer should have done to reduce the number of instructions executed by this program.

  2. Consider the following LC-3b assembly language program.

            .ORIG	x4000
    MAIN	LEA	R2,L0
    	JSRR	R2
    	JSR	L1
    	HALT
    	;
    L0	ADD	R0,R0,#5
    	RET
    	;
    L1	ADD	R1,R1,#5
    	RET
    1. Assemble the above program. Show the LC-3b machine code for each instruction in the program as a hexadecimal number.

    2. This program shows two ways to call a subroutine. One requires two instructions: LEA and JSRR. The second requires only one instruction: JSR. Both ways work correctly in this example. Is it ever necessary to use JSRR? If so, in what situation?

  3. Please go to the handouts section of the course web site, print and fill out the student information sheet, and turn it in with a recognizable recent photo of yourself on January 31st (the same day this problem set is due).