Division in MipsAsmGen

  • Why the instruction div has only 2 registers, unlike add, sub and mul? where is the result stored?

  • Since a week, I failed the daily test Prog2.tests.daily.CodeGenTests::testExpression. I’ve written tests to check if the my implementation fails but it seems to work perfectly in my local tests. Is there any hints to solve this?

Since division is a complex instruction and you can’t really divide without computing the modulo simultaneously,
division stores its result in the special hi and lo registers (as does mult).

lo = s/t, hi = s % t.

1 Like

Question moved to

Here is a detailed MIPS reference with all the detail you would need to build a mips emulator.

1 Like