问题
In my method one, I have the number that I want to shift by stored inside $a0 (e.g. 5 bits), and I want to shift $t9 by 5 bits, but I'm running into a bit of trouble. Does anyone know why?
MethodOne:
sw $a0, ($t8)
sll $t9, $t9, $t8
回答1:
To shift left by a variable amount, use sllv
:
sllv $t9, $t9, $a0
sll
only takes an immediate shift amount. There is no need for sw
or $t8
.
来源:https://stackoverflow.com/questions/26051933/shifting-left-in-mips