aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_machine')
-rw-r--r--qtmips_machine/alu.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp
index 3889b44..fbbaff4 100644
--- a/qtmips_machine/alu.cpp
+++ b/qtmips_machine/alu.cpp
@@ -154,10 +154,20 @@ std::uint32_t machine::alu_operate(enum AluOp operation, std::uint32_t s,
alu_write_hi_lo_64bit(regs, u64_val);
return 0x0;
case ALU_OP_DIV:
+ if (t == 0) {
+ regs->write_hi_lo(false, 0);
+ regs->write_hi_lo(true, 0);
+ return 0;
+ }
regs->write_hi_lo(false, (std::uint32_t)((std::int32_t)s / (std::int32_t)t));
regs->write_hi_lo(true, (std::uint32_t)((std::int32_t)s % (std::int32_t)t));
return 0x0;
case ALU_OP_DIVU:
+ if (t == 0) {
+ regs->write_hi_lo(false, 0);
+ regs->write_hi_lo(true, 0);
+ return 0;
+ }
regs->write_hi_lo(false, s / t);
regs->write_hi_lo(true, s % t);
return 0x0;