To perform integer division, you can use div $t1, $t2, $t3 , which sets $t1 to integer division $t2/$t3 or div $t1, $t2, imm , where imm is immediate.
Similarly, to calculate the remainder of integer division, you can use rem $t1, $t2, $t3 or rem $t1, $t2, imm
These pseudo instructions will basically execute div $t1, $t2 , which stores the results in special registers LO and HI (for private and the rest), and then move these values ββto the target register using mfhi and mflo .
To perform floating point division, you need to use the floating point registers $ f0 - $ f31. When you have floating point numbers stored in some of these registers (correctly encoded as floating point numbers, for example, in $f1 and $f2 ), you issue the instruction div.s $f0, $f1, $f2 so that get into $f0 result is $f1/$f2 . Now, to get the remainder, you can subtract the division result with truncating the result. For instance:
li $a1, 20 mtc1 $a1, $f1 cvt.sw $f1, $f1
source share