fix potential adc overflow flag bug
This commit is contained in:
parent
76b9059b2e
commit
858cbfba48
2
cpu.c
2
cpu.c
@ -120,7 +120,7 @@ adc(uint8_t arg)
|
|||||||
|
|
||||||
regs.status.carry = sum > 0xFF;
|
regs.status.carry = sum > 0xFF;
|
||||||
/* overflow flag formula: https://stackoverflow.com/a/29224684 */
|
/* overflow flag formula: https://stackoverflow.com/a/29224684 */
|
||||||
regs.status.overflow = ~(regs.a ^ arg) & (regs.a ^ sum) & 0x80;
|
regs.status.overflow = (~(regs.a ^ arg) & (regs.a ^ sum) & 0x80) > 0;
|
||||||
STATUS_UPDATE_ZERO(regs.a);
|
STATUS_UPDATE_ZERO(regs.a);
|
||||||
STATUS_UPDATE_NEGATIVE(regs.a);
|
STATUS_UPDATE_NEGATIVE(regs.a);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user