

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions to homework problems related to memory addressing and instruction execution in lc-3 architecture. Topics include pc-relative addressing, indirect addressing, base+offset addressing, ld, ldi, lea instructions, and trap routines.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Homework #3 Solutions 5.4 We have 256 locations in memory and each location is 16-bits. a) 8 bits are required for the address. b) 5 bits are needed to allow transfer between instructions 20 locations away c) The PC-relative offset is 6 (The PC has already been incremented once)
We could use c, which is a branch that never is taken and goes nowhere. The add instruction sets condition codes so it actually has some effect on the system.
(1): 1001 100 001 111111 (2): 1001 101 010 111111 (3): 0101 110 100 000 101 (4): 1001 011 110 111111
a) PC-Relative addressing will work in this case because the offset is within the range of numbers that can be stored in the offset field of the instruction. b) Indirect addressing or Base+Offset addressing will work because we need a register to hold the address since we can no longer place it in the offset field of the instruction. c) Base+Offset addressing is the most sensible addressing mode when loading a sequential array of values.
LD Instruction: Reads the IR from Memory = 1 Read the data = 1 Total = 2 LDI Instruction: Read the IR from Memory = 1 Read the address to look at from memory = 1 Read the value from memory = 1 Total = 3 LEA Instruction: Read the IR from Memory = 1 Total = 1
The LC-3 can currently support 256 different trap routines. This is because the low order 8-bits of the TRAP instruction determine which element of the TRAP vector contains the next address to execute.
a) LDR R2, R1, # STR R2, R0, # b) MAR <- SR
MDR <- Memory[MAR] MAR <- DR Memory[MAR] <- MDR
The instruction changes the memory location 0x3406 into the contents of register 2. Register 4 contains an address a short distance away from that address, so the instruction is STR R2, R4, #
The only register that changed was the PC, and the new value of the PC is not contained in any other register, so the instruction that could have been executed was: BRz #