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.
|
|
|
|
|
|
|
LD | ||||||
LDR | ||||||
LDI | ||||||
LEA |
Problem 2
(a) State the page number for each of the following LC-2 memory addresses:
(1) x12FE(b) State the page offset for each of the above LC-2 memory addresses.
(2) xDEAD
(3) xA931
(4) xFACE
Problem 3
Consider the following machine language program:
x3000 0101010010100000(a) Translate this program into a valid LC-2 assembly language program. Make sure you make proper use of labels and pseudo-ops.
x3001 0001001001111111
x3002 0001001001111111
x3003 0001001001111111
x3004 0000100000000111
x3005 0001010010100001
x3006 0000111000000001
x3007 1111000000100101
(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(b) What value will be contained in RESULT after the program runs to completion ?
LD R2, ZERO
LD R0, D0
LD R1, D1
LOOP BRz DONE
ADD R2, R2, R0
ADD R1, R1, -1
BRnzp LOOP
DONE ST R2, RESULT
HALT
RESULT .FILL x0000
ZERO .FILL x0000
D0 .FILL x0004
D1 .FILL x0803
.END
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
.END