sll
Shift left logical
Sets $t1 to $t2 shifted left by a fixed amount of 0 to 31 bits, filling vacated bits with zeros.
Used in
- Arithmetic, logic and bitsMIPS assembly
- jal, jr, and the course calling conventionMIPS assembly
- The bitmap display and keyboard registersMIPS assembly
- The largest elementMIPS assembly
- Masks, shifts, popcount, and leading zeroesMIPS assembly
- A jump tableMIPS assembly
- Binary searchMIPS assembly
- A 2D arrayMIPS assembly
- Drawing shapes on the screenMIPS assembly
- A bouncing ballMIPS assembly
Forms
sll , ,
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$31). $t2- A general-purpose register. It may be the same register as
$t1. imm5- An unsigned 5-bit immediate,
0to31, used for values such as a shift count.
Vacated bits on the right are filled with 0. Shifting left by n is equivalent to multiplying by 2^n (without overflow checking). Example: sll $t1,$t1,2 multiplies $t1 by 4.
# Shift or rotate an initialized word; inspect $t2: 72.
li $t0, 0x12
sll $t2, $t0, 2