究竟什么是磅指令呢? [英] What exactly does the lb instruction do?
问题描述
我有一个考试来了,和实践问题之一是:
I have an exam coming up, and one of the practice problems was:
假设 $ T0
包含值 0x12121212
和 $ T1
包含
地址 0x1000000
。
假设内存中的数据,从地址开始 0x1000000
是:
88 77 66 55
。
Assume that the memory data, starting from address 0x1000000
is:
88 77 66 55
.
会有什么 $ t0的值
执行下面的code后:
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
,因为字节的磅
指令将读取(在我的理解什么指令不执行)为88。然后,88将被存储在 $ T0
,因此该值将 0x00000088
。但给出的答案是 C
。我觉得我对如何磅
工作的根本误解 - ?可有人请解释为什么答案是 C
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
?
推荐答案
答案应该是 C)0xffffff88
。在磅
指令信号扩展字节为32位值。即最显著位(MSB)被复制到高24位
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,即最高位是1,因此高24位将是0b111111111111111111111111 == 0XFFFFFF。
0x88 == 0b10001000, i.e. the msb is 1. So the upper 24 bits will be 0b111111111111111111111111 == 0xffffff.
这篇关于究竟什么是磅指令呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!