li $t0, 32
This one you can easily check by disassembling your executable or object file. Use objdump
from your MIPS toolchain with the -d
or -D
option. I would guess that the assembler is smart enough not to generate a lui
for such a small value.
div $t2, $t2, $t0
Since you're you're dividing by a power of two (32), there's a much faster way of doing this: shift right by log2(divisor)
bits (i.e. 5 bits):
srl $t2, $t2, 5 # if $t2 is unsigned
or
sra $t2, $t2, 5 # if $t2 is signed