Skip to content

Commit

Permalink
impl div set flags
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Jun 14, 2024
1 parent 7ffeace commit 30d6ed2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/op_handlers/div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit 30d6ed2

Please sign in to comment.