我即将进行考试,练习题之一是:
Assume that
$t0
contains the value0x12121212
and$t1
contains the address0x1000000
.Assume that the memory data, starting from address
0x1000000
is:88 77 66 55
.What will be the value of
$t0
after the following code is executed:lb $t0, 0($t1)
a)
0x00000088
b)0x88121212
c)0xffffff88
d)0x12121288
我给出的答案是a
,因为lb
指令将读取的字节(根据我对指令作用的理解)是88。然后88将存储在$t0
中,因此该值将为0x00000088
。但给出的答案是c
。我觉得我对 lb
的工作原理有一个根本性的误解 - 有人可以解释一下为什么答案是 c
吗?
最佳答案
答案是c) 0xffffff88
。 lb
指令将字节符号扩展为 32 位值。 IE。最高有效位 (msb) 被复制到高 24 位。
0x88 == 0b10001000,即最高有效位为1。因此高24位将为0b111111111111111111111111 == 0xffffff。
关于assembly - lb 指令到底有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14836338/