diff --git a/src/op_handlers/div.rs b/src/op_handlers/div.rs index 59d3ea47..a252666b 100644 --- a/src/op_handlers/div.rs +++ b/src/op_handlers/div.rs @@ -5,13 +5,12 @@ pub fn _div(vm: &mut VMState, opcode: &Opcode) { let (src0, src1) = address_operands_read(vm, &opcode); let (quotient, remainder) = src0.div_mod(src1); if opcode.alters_vm_flags { - // If overflow, set the flag. - // otherwise keep the current value. - // vm.flag_lt_of |= overflow; - // Set eq if res == 0 - // vm.flag_eq |= quotient.is_zero(); - // Gt is set if both of lt_of and eq are cleared. - vm.flag_gt |= !vm.flag_lt_of && !vm.flag_eq; + // Lt overflow is cleared + vm.flag_lt_of = false; + // Eq is set if quotient is not zero + vm.flag_eq = !quotient.is_zero(); + // Gt is set if the remainder is not zero + vm.flag_gt = !remainder.is_zero(); } address_operands_store(vm, &opcode, (quotient, Some(remainder)));