Insights

Integer Arithmetic

Instructions

Description Instruction Function Notes
Move from HI mfhi $rd $R[\text{\$rd}] \leftarrow \text{HI}$
Move to HI mthi $rs $\text{HI} \leftarrow R[\text{\$rs}]$
Move from LO mflo $rd $R[\text{\$rd}] \leftarrow \text{LO}$
Move to LO mtlo $rs $\text{LO} \leftarrow R[\text{\$rs}]$
Multiply mult $rs, $rt $\{\text{HI}, \text{LO}\} \leftarrow R[\text{\$rs}] * R[\text{\$rt}]$ Signed Multiplication
Multiply Unsign multu $rs, $rt $\{\text{HI}, \text{LO}\} \leftarrow R[\text{\$rs}] * R[\text{\$rt}]$ Unsigned Multiplication
Divide div $rs, $rt $\text{LO} \leftarrow R[\text{\$rs}] \div R[\text{\$rt}], \text{HI} \leftarrow R[\text{\$rs}] \% R[\text{\$rt}]$ Signed Division
Divide Unsign divu $rs, $rt $\text{LO} \leftarrow R[\text{\$rs}] \div R[\text{\$rt}], \text{HI} \leftarrow R[\text{\$rs}] \% R[\text{\$rt}]$ Unsigned Division
Add add $rd, $rs, $rt $R[\text{\$rd}] \leftarrow R[\text{\$rs}] + R[\text{\$rt}]$ Exception on signed overflow
Add 无溢出检测 addu $rd, $rs, $rt $R[\text{\$rd}] \leftarrow R[\text{\$rs}] + R[\text{\$rt}]$ No exception on overflow
Subtract sub $rd, $rs, $rt $R[\text{\$rd}] \leftarrow R[\text{\$rs}] - R[\text{\$rt}]$ Exception on Signed overflow
Sub 无溢出检测 subu $rd, $rs, $rt $R[\text{\$rd}] \leftarrow R[\text{\$rs}] - R[\text{\$rt}]$ No exception on overflow

addu & add R-type Instruction

addiu I-type Instruction

subu & sub R-type Instruction

<aside> ⚠️ There is no subi / subiu

mult & multu R-type Instruction