diff options
Diffstat (limited to 'src/cpu/instructions.c')
-rw-r--r-- | src/cpu/instructions.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index b4daf6e..1a94386 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -68,6 +68,7 @@ void fSBC(Addressing addr, address val){ SetFlag(flag_C, (buffer > acc) ? 1 : 0); acc = buffer; + SetFlagN(acc); SetFlagZ(acc); } @@ -135,7 +136,7 @@ void fEOR(Addressing addr, address val){ // Jump, Branch, Compare, and Test Bits void fJMP(Addressing addr, address val){ - PC = idata.add - idata.length; + PC = idata.value - idata.length; } void fBCC(Addressing addr, address val){ @@ -189,9 +190,9 @@ void fCPY(Addressing addr, address val){ } void fBIT(Addressing addr, address val){ - SetFlag(flag_N, (idata.value & flag_N) ? 1 : 0); - SetFlag(flag_V, (idata.value & flag_V) ? 1 : 0); - SetFlag(flag_Z, (idata.value & acc) ? 0 : 1); + SetFlag(flag_N, ((idata.value & flag_N) != 0) ? 1 : 0); + SetFlag(flag_V, ((idata.value & flag_V) != 0) ? 1 : 0); + SetFlag(flag_Z, ((idata.value & acc) == 0) ? 1 : 0); } // Shift and Rotate Instructions @@ -321,14 +322,14 @@ void fPLP(Addressing addr, address val){ // Subroutine Instructions void fJSR(Addressing addr, address val){ - SetStack((PC+3) >> 8); - SetStack((PC+3) & 0x00FF); + SetStack ((PC+idata.length) >> 8); + SetStack(((PC+idata.length) & 0x00FF) - 1); PC = idata.add; PC -= idata.length; } void fRTS(Addressing addr, address val){ - PC = (address)(GetStack()); + PC = (address)(GetStack()) + 1; PC += ((address)(GetStack())) << 8; PC -= idata.length; } |