From 858cbfba48145ff9303a4127cb73911fc8904462 Mon Sep 17 00:00:00 2001 From: vin Date: Sun, 9 Jun 2024 15:35:31 +0530 Subject: [PATCH] fix potential adc overflow flag bug --- cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu.c b/cpu.c index 4aeaaf6..3bbfc42 100644 --- a/cpu.c +++ b/cpu.c @@ -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); }