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!!
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.
(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.
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.
(b) What are the possible initial values of R1 that cause the final
value in R2 to be 3?
(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
DONE ST R2, RESULT
RESULT .FILL x0000
ZERO .FILL x0000
D0 .FILL x0004
D1 .FILL x0803
(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).
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
When the following LC-2 program is executed, how many times will the instruction at the memory address labeled LOOP execute?
LEA R2, DATA
LDR R4, R2, #0
LOOP ADD R4, R4, #-3
DATA .FILL x000B