diff options
author | vin <git@vineetk.net> | 2024-06-29 09:51:12 -0400 |
---|---|---|
committer | vin <git@vineetk.net> | 2024-06-29 09:51:12 -0400 |
commit | 5d36aeb8856fa17d491b0c8c18d6593a9ec4997a (patch) | |
tree | 7bed7514512136f50e395d4a323ae11268b25bf1 /cpu.c | |
parent | f16ab6cb6dce3a64ead1d0f0bc99f3d034a005b2 (diff) |
fix ADC bug where V is calculated with new A instead of old A
Diffstat (limited to 'cpu.c')
-rw-r--r-- | cpu.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -218,11 +218,12 @@ adc(uint8_t arg) uint16_t sum; // 16-bit sum makes it easier to determine carry flag sum = regs.a + arg + regs.status.carry; - regs.a = sum & 0xFF; regs.status.carry = sum > 0xFF; /* overflow flag formula: https://stackoverflow.com/a/29224684 */ regs.status.overflow = (~(regs.a ^ arg) & (regs.a ^ sum) & 0x80) != 0; + regs.a = sum & 0xFF; + STATUS_UPDATE_ZERO(regs.a); STATUS_UPDATE_NEGATIVE(regs.a); } |