a Suppose the following LC3 program is loaded into memory st

(a) Suppose the following LC-3 program is loaded into memory starting at location x30FF:

x30FF 1110 0010 0000 0001

x3100 0110 0100 0100 0010

x3101 0001 0100 0100 0001

x3102 0001 0100 1000 0010

If the program is completely executed, what is the value in R2?

(b) The following memory locations contain values as shown below:

x3050: x70A4

x70A2: x70A3

x70A3: xFFFF

x70A4: x123B

Now, the following three LC-3 instructions are being executed, causing one value to be loaded into register R6. Initially, program counter (PC) contains x3010.

x3010: 1110 0110 0011 1111

x3011: 0110 1000 1100 0000

x3012: 0110 1101 0000 0000

(i) What is the loaded value?

(ii) The execution of the above three LC-3 instructions can be replaced by one instruction. What is it?

Solution

a) LEA R1, 1: 0x3101 stored in R1
LDR R2, R1, 1: 0x1441 stored in R2
HALT

0x1441 - value of R2

b)

LEA R3 x3F, PC = x3011, therefore R3 = x3050 LDR R4 R3 0, therefore R4 = x70A4 LDR R6 R4 0, therefore R6 = x123B Could replace these with LDI R6 000111111, which takes the value at the address stored in memory location x3050 (x3011 + x003F)

(a) Suppose the following LC-3 program is loaded into memory starting at location x30FF: x30FF 1110 0010 0000 0001 x3100 0110 0100 0100 0010 x3101 0001 0100 010

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site