fix potential adc overflow flag bug

This commit is contained in:
Vineet K 2024-06-09 15:35:31 +05:30
parent 76b9059b2e
commit 858cbfba48

2
cpu.c
View File

@ -120,7 +120,7 @@ adc(uint8_t arg)
regs.status.carry = sum > 0xFF;
/* 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_NEGATIVE(regs.a);
}