Tjh Thon
Tjh Thon

Reputation: 85

2 shift operations in MIPS

The syntax for sll and srl is:

sll $s0,$s1,n (n is an integer, for example sll $s0,$s1,3)

srl $s0,$s1,n (n is an integer, for example srl $s0,$s1,3)

I wonder if I can substitute $n$ for a register.

For instance:

sll $s0,$s1,$s2

I'm sorry, I'm a newbie to MIPS.

Upvotes: 1

Views: 369

Answers (1)

Michael
Michael

Reputation: 58507

The instructions you're looking for are sllv/srlv et al. For example, sllv $s0,$s1,$s2

And as always when having questions regarding the MIPS instruction set, consult MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set.

Upvotes: 1

Related Questions