MIPS

       What is MIPS?       Operation Codes

Some Examples   Applet to Run your MIPS Code  

 

MIPS arithmetic instructions

Instruction Example Meaning Comments
add add $1,$2,$3 $1 = $2 + $3 3 operands; exception possible
subtract sub $1,$2,$3 $1 = $2 – $3 3 operands; exception possible
add immediate addi $1,$2,100 $1 = $2 + 100 + constant exception possible
add unsigned addu $1,$2,$3 $1 = $2 + $3 3 operands; no exceptions
subtract unsigned subu $1,$2,$3 $1 = $2 – $3 3 operands; no exceptions
add imm. unsign. addiu $1,$2,100 $1 = $2 + 100 + constant no exceptions
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,
Hi = $2 mod $3
Lo = quotient, Hi = remainder
divide unsigned divu $2,$3 Lo = $2 ÷ $3,
Hi = $2 mod $3
Unsigned quotient & 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