assembly - lb 指令到底有什么作用?

标签 assembly mips

我即将进行考试,练习题之一是:

Assume that $t0 contains the value 0x12121212 and $t1 contains the address 0x1000000.

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) 0xffffff88lb 指令将字节符号扩展为 32 位值。 IE。最高有效位 (msb) 被复制到高 24 位。

0x88 == 0b10001000,即最高有效位为1。因此高24位将为0b111111111111111111111111 == 0xffffff。

关于assembly - lb 指令到底有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14836338/

相关文章:

c - C中的可变长度数组,它们是如何编译的

c - shellcode 中的地址在执行过程中发生变化

assembly - PTEST 可以用来测试两个寄存器是否都为零或其他条件吗?

assembly - 引导加载程序参数通过参数寄存器传递到 Linux 内核 (MIPS 24KEc)

c++ - 关于堆栈增长和寻址的困惑

MIPS R4000 : Why is there a global bit in each EntryLo register?

gcc - 在 C++ Builder 中使用 GCC 生成的汇编程序

visual-c++ - 为什么 MSVC 使用 SSE2 指令处理这种琐碎的事情?

mips - MIPS中的浮点寄存器是几号寄存器?

algorithm - 在mips中实现LRU