Skip to content

Commit

Permalink
Fixed OF flag for ADOX instruction
Browse files Browse the repository at this point in the history
The OF flag defintion is different from OF of other instructions
Instead it is defined as:
The instruction sets the OF flag with the **carry** generated by the unsigned addition of the operands.
  • Loading branch information
stlintel committed Jan 19, 2024
1 parent 6e48bc7 commit dd9aaa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bochs/cpu/bmi32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::ADOX_GdEdR(bxInstruction_c *i)

BX_WRITE_32BIT_REGZ(i->dst(), sum_32);

Bit32u overflow = GET_ADD_OVERFLOW(op1_32, op2_32, sum_32, 0x80000000);
set_OF(!!overflow);
Bit32u carry_out = ADD_COUT_VEC(op1_32, op2_32, sum_32);
set_OF(carry_out >> 31);

BX_NEXT_INSTR(i);
}
4 changes: 2 additions & 2 deletions bochs/cpu/bmi64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::ADOX_GqEqR(bxInstruction_c *i)

BX_WRITE_64BIT_REG(i->dst(), sum_64);

Bit64u overflow = GET_ADD_OVERFLOW(op1_64, op2_64, sum_64, BX_CONST64(0x8000000000000000));
set_OF(!!overflow);
Bit64u carry_out = ADD_COUT_VEC(op1_64, op2_64, sum_64);
set_OF(carry_out >> 63);

BX_NEXT_INSTR(i);
}
Expand Down

0 comments on commit dd9aaa7

Please sign in to comment.