Department of Electrical and Computer Engineering
University of Texas at Austin
EE 379K, Fall 2000
Y. N. Patt, Instructor
TAs: Kathy Buchheit, Laura Funderburg, Chandresh Jain, Onur Multu, Danny Nold, Kameswar Subramanian, Francis Tseng, Brian Ward
Problem Set 4
Due: October 30, 2000

Instructions: Remember to put all group members' names on the solution sheet. Also, remember to put the unique number of the discussion session you want the homework returned back to you. Good luck!!

Problem 1

Consider the following load instructions, LD, LDR, LDI, and LEA. For each instruction, how many accesses to memory are performed during each phase of the instruction cycle? Fill in the table below by writing the number of times memory is accessed in each of the boxes.
Fetch Instruction
Evaluate Address
Fetch Data
Store Result


Problem 2

(a) State the page number for each of the following LC-2 memory addresses:

(1) x12FE
(2) xDEAD
(3) xA931
(4) xFACE
(b) State the page offset for each of the above LC-2 memory addresses.

Problem 3

Consider the following machine language program:

x3000     0101010010100000
x3001     0001001001111111
x3002     0001001001111111
x3003     0001001001111111
x3004     0000100000000111
x3005     0001010010100001
x3006     0000111000000001
x3007     1111000000100101
(a) Translate this program into a valid LC-2 assembly language program. Make sure you make proper use of labels and pseudo-ops.

(b) What are the possible initial values of R1 that cause the final value in R2 to be 3?

Problem 4

(a) What does the following program do?

        .ORIG   x3000
        LD     R2, ZERO
        LD     R0, D0
        LD     R1, D1
        ADD    R2, R2, R0
        ADD    R1, R1, -1
        BRnzp  LOOP
RESULT  .FILL  x0000
ZERO    .FILL  x0000
D0      .FILL  x0004
D1      .FILL  x0803
(b) What value will be contained in RESULT after the program runs to completion ?

Problem 5

(a) Consider the program in  problem 4(a). Assembly is a two-pass process. In pass one, we create the symbol table and in pass two, we translate the individual assembly language instructions into their corresponding machine language instructions. Draw the symbol table generated by the assembler after the first pass.

(b) Using the symbol table generated in part (a), perform the second pass to complete the assembly process. Generate the machine code for the program in problem 4(a).

Problem 6

An assembly language program contains the following two instructions. The assembler puts the translated version of the LDI instruction shown below into location 0x3025 of the object module. After assembly is complete, what is in location x3025? Write your answer in hex.

PLACE   .FILL  x45A7
        LDI    R3, PLACE

Problem 7

When the following LC-2 program is executed, how many times will the instruction at the memory address labeled LOOP execute?

        .ORIG  x3000
        LEA    R2, DATA
        LDR    R4, R2, #0
LOOP    ADD    R4, R4, #-3
        BRzp   LOOP
        TRAP   x25
DATA    .FILL  x000B