ori $7, $0, 146 # put +146 into $7 addiu $10,$7,-82 # add -82
The program is much shorter.
subu
InstructionMIPS has two integer subtraction instructions:
subu d,s,t # $d <—— s - t . # No overflow trap. # This is equivalent to $d <—— s + (-t) # where (-t) is reflect-add-one of t.
sub d,s,t # $d <—— s - t . # Overflow is trapped! # This is equivalent to $d <—— s + (-t) # where (-t) is reflect-add-one of t.
When ori $d,$0,const
is used to load
the register $d
,
const
is 16-bit unsigned binary.
Say that you want to load $8
with a negative 86.
Will the following work?
addiu $8,$0,-86 # $8 <—— -86