rol伪指令MIPS代码

时间:2018-04-10 10:28:57

标签: mips instructions qtspim

说明是:

rol $t0, $t1, n
rolv $t0, $t1, $t2

n:1bit-31bit

这是上述说明的正确翻译吗?

srl $t1, $s1, 1
sll $t2, $s1, 31
or $s2, $t1, $t2 #combine_words

1 个答案:

答案 0 :(得分:0)

对于rol $t0, $t1, n,我会使用$at作为临时寄存器。

假设您想要向左旋转4位二进制数字:

   srl $at, $t1, 28  # 32-4 = 28
   sll $t0, $t1, 4
   or $t0, $t0, $at

对于rolv $t0, $t1, $t2我会发出($t2保存要旋转的位数):

   sllv $t0, $t1, $t2
   subu $at, $zero, $t2
   addiu $at, $at, 32    # $at = 32-$t2
   srlv $at, $t1, $at
   or $t0, $t0, $at
相关问题