0
votes

Assume that the processor is executing the following instruction:

lb $t3,-7($s0)

Moreover, assume that the instruction above is located at address 0x004000f0, register $t3 contains value 0x20040144, and that register $s0 contains value 0x305502db. What value has registers $t3 after that the instruction has finished executing?

From my calculation:

The format of the instruction is:

lb RegDest, Offset(RegSource)

we know $s0 contains value 0x305502db, which leads to 0x305502db - 7 = 0x305502d4 and this value will be loaded in $t3. I am confused here now because the correct answer says $t3 = unknown, how come?

1
Because it loads from memory at that address and the content of that byte is not given in the problem description.Jester
@Jester thanks for the comment, how would the problem describe so $t3 is not unknown?nihulus
By giving the contents of memory at the target address for the load, obviously. You only know register values, not memory contents other than the 4 bytes containing the instruction word. Or there would also have a known solution if the text simply told you what value was loaded (and maybe asked you what address it was loaded from, or was simply part of a larger question). Or if the address pointed inside the instruction word.Peter Cordes

1 Answers

2
votes

0x305502db - 7 = 0x305502d4

... so the lb instruction will load the byte from the memory (for example: RAM) at address 0x305502d4, sign-extend it and write it into the register $t3.

If the RAM contains the value 0x5A at address 0x305502d4, $t3 will contain the value 0x0000005A. If it contains the value 0xA5, $t3 will contain the value 0xFFFFFFA5.

... the correct answer says $t3 = unknown, how come?

Your exercise does not contain any information about the content of the RAM at address 0x305502d4.

Therefore you cannot say which value $t3 will contain.