一个简单的MIPS编程问题[array,lw]
因此,在这段代码片段中,我试图找出十六进制形式的 $t2 和 $t3 的值。我得到的答案是 $t2 = 0x30,$t3 是 0x3C。然而后面的答案是$t2 = 0x130,$t3 = 0x13C。有人可以解释一下吗??
.data
x: .byte 1, 2, 3, 4, 5
y: .word 19, 20, 25, 30, 35
.text
addi $t0, $0, 8
lw $t1, x($t0)
sll $t2, $t1, 4
ori $t3, $t2, 12
So, in this code snippet, I am trying to find out the values of $t2, and $t3 in HEX. I get the answer to be $t2 = 0x30 and $t3 to be 0x3C. However, the answer in the back is $t2 = 0x130, $t3 = 0x13C. Can someone explain??
.data
x: .byte 1, 2, 3, 4, 5
y: .word 19, 20, 25, 30, 35
.text
addi $t0, $0, 8
lw $t1, x($t0)
sll $t2, $t1, 4
ori $t3, $t2, 12
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是如何得出你的答案的?我对 MIPS 很生疏,这是基于我在大学时的记忆。
x 指向数据为 1 的字节。在小端机器上,x+5 标记 4 字节字(数据为 19)的结束,x+8 标记开始。因此 19 (10011) 被加载到 $t1 中,左移 4 到 100110000(304 或 0x130)。最后加上12就得到0x13C。
如果您有不明白的地方,请告诉我。它有助于绘制图表:)
How did you derive your answer? I'm pretty rusty with MIPS and this is based on what I remember from uni.
x points to the byte with data 1. On a little-endian machine, x+5 marks the end of the 4 byte word (with data 19) and x+8 marks the beginning. So 19 (10011) is loaded into $t1, shifted left by 4 to 100110000 (304 or 0x130). Finally, 12 is added to get 0x13C.
Let me know if you don't understand something. And it helps to draw a diagram :)