assemblymipsmodulomips64

How to calculate the remainder of a division in WinMIPS64


The MIPS ISA supports DIV, having the quotient stored in $LO and the remainder in $HI. However, WinMIPS64 does not appear to support the DIV operation, and instead has (for example) DDIV.

From the documentation it remains unclear if DDIV only calculates the quotient, but when I output the result to the terminal I only get the integer part of it, and nowhere in the WinMIPS64 GUI can I find a register or a segment of data memory where the quotient is stored.

I considered just performing the division by using consecutive subtractions, but I would like to know if there is an easy way in WinMIPS64 to compute the remainder of a division.

I will appreciate any help you can provide.


Solution

  • I don't have enough XP to write a comment so I write here:

    If you're in the same class as me and you need to get the remainder for loop unrolling, you can just check if (i+x) > ITERATIONS-1 with SLT where x is your loop unrolling factor. Since you need to calculate (i+x) in any case, this won't cost you any additional cycles.