Suppose the following LC3 program is loaded into memory star

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? The following memory locations contain values as shown below: x3050: x70A4 X70A2: x70A3 x70A3: xFFFF x70A4: xl23B 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 What is the loaded value? The execution of the above three LC-3 instructions can be replaced by one instruction. What is it?

Solution

Answer

1.

R[1]  <- x3100 + 1

R[2] <- MEM[X3101+2] = x1482

HALT

Therefore, the value of R2 will be x1482, if the program is executed completely.

2.

x3010              1110 0110 0011 1111 LEA R3, x3F      ; R3 <- x3050
x3011              0110 1000 1100 0000    LDR R4, R3, #0 ; R4 <- x70A4
x3012              0110 1101 0000 0000     LDR R6, R4, #0 ; R6 <- x123B

i. The value that gets loaded into R6 is x123B

ii. The execution of the given three LC-3 instruction can be replaced by the below single instruction:

LDI R6, x3F; 1010 1100 00111111     ; R6 <- M[M[x3050] = M[x70A4] = x123B

 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 0

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site