I have an exam coming up, and one of the practice problems was:
Assume that
$t0contains the value0x12121212and$t1contains the address0x1000000.Assume that the memory data, starting from address
0x1000000is:88 77 66 55.What will be the value of
$t0after the following code is executed:lb $t0, 0($t1)a)
0x00000088b)0x88121212c)0xffffff88d)0x12121288
The answer I gave was a, because the byte that the lb instruction will read (by my understanding of what the instruction does) is 88. The 88 will then be stored in $t0, thus the value will be 0x00000088. But the answer given was c. I feel like I have a fundamental misunderstanding about how lb works - can someone please explain why the answer is c?
The answer would be c) 0xffffff88. The lb instructions sign-extends the byte into a 32-bit value. I.e. the most significant bit (msb) is copied into the upper 24 bits.
0x88 == 0b10001000, i.e. the msb is 1. So the upper 24 bits will be 0b111111111111111111111111 == 0xffffff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With