4. Using a shift operation, write MIPS code that multiplies the number in $t0=
16 by 16.
ANS: # do a multiply by 16 with shift
li
$t0, 16
sll
$to, $t0, 4
# result is 256 (16 * 16)
5. Using a shift operation, write the MIPS code that divides the number in $t0
=256 by 8.
ANS: # do a divide by 8 with shift
li
$t0, 256
srl
$to, $t0, 3
# result is 32 (256 / 8 = 32)
6. Using only ori and sll instructions, put the constant 0x3FF01 into $t0.
ANS:
Do this by putting 0x3FF0 into $t0, then shift value by 4, then ORI
with 0x01. 0x01 comes right after the 3FF0.
ori
$t0, $0, 0x3FF0
sll
$to, $t0, 4
ori
$to, $t0, 0x1