【问题标题】:MIPS shifting to the right (but adding 1's instead of zero's)MIPS 向右移动(但添加 1 而不是 0)
【发布时间】:2012-02-20 15:41:12
【问题描述】:

有没有办法将寄存器值向右移动,而不是加 0(像 srl 那样),让它加 1。如果这是不可能的,任何其他实现相同目标的建议将不胜感激。

【问题讨论】:

    标签: mips cpu-registers instruction-set


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2020-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多