The instructions is:
rol $t0, $t1, n
rolv $t0, $t1, $t2
n: 1bit- 31bit
Is this correct translation of the above instructions?
srl $t1, $s1, 1
sll $t2, $s1, 31
or $s2, $t1, $t2 #combine_words
For rol $t0, $t1, n
I would use $at
as the scratch register.
Suppose you want to rotate 4 binary digits to the left:
srl $at, $t1, 28 # 32-4 = 28
sll $t0, $t1, 4
or $t0, $t0, $at
For rolv $t0, $t1, $t2
I would emit ($t2
holds the number of bits to rotate):
sllv $t0, $t1, $t2
subu $at, $zero, $t2
addiu $at, $at, 32 # $at = 32-$t2
srlv $at, $t1, $at
or $t0, $t0, $at