【发布时间】:2012-02-20 15:41:12
【问题描述】:
有没有办法将寄存器值向右移动,而不是加 0(像 srl 那样),让它加 1。如果这是不可能的,任何其他实现相同目标的建议将不胜感激。
【问题讨论】:
标签: mips cpu-registers instruction-set
有没有办法将寄存器值向右移动,而不是加 0(像 srl 那样),让它加 1。如果这是不可能的,任何其他实现相同目标的建议将不胜感激。
【问题讨论】:
标签: mips cpu-registers instruction-set
您可以首先确保要移位的寄存器的最高有效位为 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
【讨论】: