What is the difference between div
and divu
in MIPS.
I have seen difference between add
and addu
(link for same). My understanding of add and addu : both operate on 2's complement signed numbers, the only difference that add generates traps on overflow whilst addu does not
But what is difference between div and divu, I mean we wont really get overflows here right.
I tried following cases but got pretty weird results with divu. I only loaded the quotients (with mflo) and here are the outputs:
num1 | num2 | div num1 num2 (qoutient) | divu num1 num2 (qoutient) |
5 | 2 | 2 | 2 |
-5 | 2 | -2 | 2147483645 |
5 | -2 | -2 | 0 |
-5 | -2 | 2 | 0 |
Can Someone please explain logic of what is happening!!??