MIPS Arithmetic Instructions
Which add for address arithmetic? Which for integers?
Instruction Example Meaning Comments
add add $1,$2,$3 $1 = $2 + $3 3 operands
subtract sub $1,$2,$3 $1 = $2 – $3 3 operands
add immediate addi $1,$2,100 $1 = $2 + 100 + constant
add unsigned addu $1,$2,$3 $1 = $2 + $3 3 operands
subtract unsigned subu $1,$2,$3 $1 = $2 – $3 3 operands
add imm. unsign. addiu $1,$2,100 $1 = $2 + 100 + constant
multiply mult $2,$3 Hi, Lo = $2 x $3 64-bit signed product
multiply unsigned multu $2,$3 Hi, Lo = $2 x $3 64-bit unsigned product
divide div $2,$3 Lo = $2 ÷ $3, Lo = quotient,
Hi = $2 mod $3 Hi = remainder
divide unsigned divu $2,$3 Lo = $2 ÷ $3, Unsigned quotient
Hi = $2 mod $3 Usigned remainder
Move from Hi mfhi $1 $1 = Hi Used to get copy of Hi
Move from Lo mflo $1 $1 = Lo Used to get copy of Lo