Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 MIPS,并且来自程序编程背景,但事实证明这很困难。这是我在换档时遇到的一个问题。如果在回答它时有任何指示,将不胜感激。
假设 rt 是一个包含整数的寄存器。解释为什么指令
sll $rd, $rt, h
有投放效果
2^h ∗ rt
在寄存器 rd
这与过程编程无关,而是与二进制数有关。
使用 8 位数字的一些示例:
如果你有数字1(十进制) - 二进制0000 0001
1
0000 0001
如果左移 1,则将所有数字上移 1,并将 0 插入新的移位空间
所以现在你会有二进制0000 0010或2十进制。
0000 0010
2
左移另一个给出0000 0100或4小数。
0000 0100
4
因此,如果将原始数字 1 左移 2,则得到 4。
或将其视为一种模式:
1 左移 = *2 (2^1)
2 左移 = *4 (2^2)
所有这些看起来像