mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-12-23 07:30:31 +00:00
Fix overflow flag for SBC.
This commit is contained in:
parent
1b936f087e
commit
a255b093e9
@ -804,13 +804,11 @@ emul_sbc(rk65c02emu_t *e, void *id, instruction_t *i)
|
||||
if (!(e->regs.P & P_CARRY))
|
||||
res--;
|
||||
|
||||
if ((e->regs.A ^ res) & (arg ^ res) & 0x80)
|
||||
if ((e->regs.A ^ res) & ((0xFF-arg) ^ res) & 0x80)
|
||||
e->regs.P |= P_SIGN_OVERFLOW;
|
||||
else
|
||||
e->regs.P &= ~P_SIGN_OVERFLOW;
|
||||
|
||||
printf("res is %x\n", res);
|
||||
|
||||
/* if the result does not fit into 8 bits then clear carry */
|
||||
if (res & 0x8000)
|
||||
e->regs.P &= ~P_CARRY;
|
||||
|
Loading…
Reference in New Issue
Block a user