From cc61646ba947df365f46ed9db3295c819e0aeb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Wed, 15 Feb 2017 21:58:42 +0100 Subject: [PATCH] Fix carry flag setting in comparison instructions. Resolve #2. --- src/emulation.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/emulation.c b/src/emulation.c index 9dd0005..7032515 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -397,9 +397,9 @@ emul_cmp(rk65c02emu_t *e, void *id, instruction_t *i) instruction_status_adjust_negative(e, sr); if (e->regs.A < val) - e->regs.P |= P_CARRY; - else e->regs.P &= ~P_CARRY; + else + e->regs.P |= P_CARRY; } /* CPX - compare X and memory location */ @@ -415,9 +415,9 @@ emul_cpx(rk65c02emu_t *e, void *id, instruction_t *i) instruction_status_adjust_negative(e, sr); if (e->regs.X < val) - e->regs.P |= P_CARRY; - else e->regs.P &= ~P_CARRY; + else + e->regs.P |= P_CARRY; } /* CPY - compare Y and memory location */ @@ -433,9 +433,9 @@ emul_cpy(rk65c02emu_t *e, void *id, instruction_t *i) instruction_status_adjust_negative(e, sr); if (e->regs.Y < val) - e->regs.P |= P_CARRY; - else e->regs.P &= ~P_CARRY; + else + e->regs.P |= P_CARRY; } /* DEC - decrement memory location/acumulator */