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.
无论如何要将寄存器值向右移动,而不是添加 0(像 srl 那样),而是添加 1。如果这是不可能的,任何其他实现相同目标的建议将不胜感激。
您可以通过首先确保要移位的寄存器的最高有效位为 1,然后进行右移算术(该符号扩展结果)来做到这一点。
例如,假设您想将寄存器 $t0 右移四位,那么您将执行以下操作:
lui $at, 0x8000 # Set leftmost bit of $at to 1 and the others to 0 or $t0, $t0, $at # OR into register to be shifter sra $t0, $t0, 4 # do an arithmetic shift right