diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-07 04:39:33 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-07 04:39:33 +1100 |
commit | 68cdad3be01539e583627e1c8929f182255541be (patch) | |
tree | 15349096a94ac9b3383f1d6af2266f2024ef107b /src/cpu/instructions.c | |
parent | 98dd41e2ce7dedb81ab91342eed29da017006ea4 (diff) |
small changes
Diffstat (limited to 'src/cpu/instructions.c')
-rw-r--r-- | src/cpu/instructions.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index 1a94386..abe6365 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -16,39 +16,39 @@ AddData idata; // Load and Store Instructions -void fLDA(Addressing addr, address val){ +void fLDA(Addressing addr){ acc = idata.value; SetFlagN(acc); SetFlagZ(acc); } -void fLDX(Addressing addr, address val){ +void fLDX(Addressing addr){ X = idata.value; SetFlagN(X); SetFlagZ(X); } -void fLDY(Addressing addr, address val){ +void fLDY(Addressing addr){ Y = idata.value; SetFlagN(Y); SetFlagZ(Y); } -void fSTA(Addressing addr, address val){ +void fSTA(Addressing addr){ SetMemory(idata.add, acc); } -void fSTX(Addressing addr, address val){ +void fSTX(Addressing addr){ SetMemory(idata.add, X); } -void fSTY(Addressing addr, address val){ +void fSTY(Addressing addr){ SetMemory(idata.add, Y); } // Arithmetic Instructions -void fADC(Addressing addr, address val){ +void fADC(Addressing addr){ byte buffer = acc + idata.value + getFlag(flag_C); SetFlagV(buffer, acc); @@ -60,7 +60,7 @@ void fADC(Addressing addr, address val){ SetFlagZ(acc); } -void fSBC(Addressing addr, address val){ +void fSBC(Addressing addr){ byte buffer = acc - idata.value - !getFlag(flag_C); SetFlagV(buffer, acc); @@ -75,39 +75,39 @@ void fSBC(Addressing addr, address val){ //Increment and Decrement Instructions -void fINC(Addressing addr, address val){ +void fINC(Addressing addr){ byte a = idata.value; SetMemory(idata.add, ++a); SetFlagN(a); SetFlagZ(a); } -void fINX(Addressing addr, address val){ +void fINX(Addressing addr){ X++; SetFlagN(X); SetFlagZ(X); } -void fINY(Addressing addr, address val){ +void fINY(Addressing addr){ Y++; SetFlagN(Y); SetFlagZ(Y); } -void fDEC(Addressing addr, address val){ +void fDEC(Addressing addr){ byte a = idata.value; SetMemory(idata.add, --a); SetFlagN(a); SetFlagZ(a); } -void fDEX(Addressing addr, address val){ +void fDEX(Addressing addr){ X--; SetFlagN(X); SetFlagZ(X); } -void fDEY(Addressing addr, address val){ +void fDEY(Addressing addr){ Y--; SetFlagN(Y); SetFlagZ(Y); @@ -115,19 +115,19 @@ void fDEY(Addressing addr, address val){ // Logical Instructions -void fAND(Addressing addr, address val){ +void fAND(Addressing addr){ acc &= idata.value; SetFlagN(acc); SetFlagZ(acc); } -void fORA(Addressing addr, address val){ +void fORA(Addressing addr){ acc |= idata.value; SetFlagN(acc); SetFlagZ(acc); } -void fEOR(Addressing addr, address val){ +void fEOR(Addressing addr){ acc ^= idata.value; SetFlagN(acc); SetFlagZ(acc); @@ -135,61 +135,61 @@ void fEOR(Addressing addr, address val){ // Jump, Branch, Compare, and Test Bits -void fJMP(Addressing addr, address val){ - PC = idata.value - idata.length; +void fJMP(Addressing addr){ + PC = idata.add - idata.length; } -void fBCC(Addressing addr, address val){ +void fBCC(Addressing addr){ if (getFlag(flag_C) == 0) PC += (char)idata.value; } -void fBCS(Addressing addr, address val){ +void fBCS(Addressing addr){ if (getFlag(flag_C) == 1) PC += (char)idata.value; } -void fBEQ(Addressing addr, address val){ +void fBEQ(Addressing addr){ if (getFlag(flag_Z) == 1) PC += (char)idata.value; } -void fBNE(Addressing addr, address val){ +void fBNE(Addressing addr){ if (getFlag(flag_Z) == 0) PC += (char)idata.value; } -void fBMI(Addressing addr, address val){ +void fBMI(Addressing addr){ if (getFlag(flag_N) == 1) PC += (char)idata.value; } -void fBPL(Addressing addr, address val){ +void fBPL(Addressing addr){ if (getFlag(flag_N) == 0) PC += (char)idata.value; } -void fBVS(Addressing addr, address val){ +void fBVS(Addressing addr){ if (getFlag(flag_V) == 1) PC += (char)idata.value; } -void fBVC(Addressing addr, address val){ +void fBVC(Addressing addr){ if (getFlag(flag_V) == 0) PC += (char)idata.value; } -void fCMP(Addressing addr, address val){ +void fCMP(Addressing addr){ SetFlag(flag_C, (acc >= idata.value) ? 1 : 0); SetFlag(flag_Z, (acc == idata.value) ? 1 : 0); SetFlag(flag_N, (acc < idata.value) ? 1 : 0); } -void fCPX(Addressing addr, address val){ +void fCPX(Addressing addr){ SetFlag(flag_C, (X >= idata.value) ? 1 : 0); SetFlag(flag_Z, (X == idata.value) ? 1 : 0); SetFlag(flag_N, (X < idata.value) ? 1 : 0); } -void fCPY(Addressing addr, address val){ +void fCPY(Addressing addr){ SetFlag(flag_C, (Y >= idata.value) ? 1 : 0); SetFlag(flag_Z, (Y == idata.value) ? 1 : 0); SetFlag(flag_N, (Y < idata.value) ? 1 : 0); } -void fBIT(Addressing addr, address val){ +void fBIT(Addressing addr){ 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); @@ -197,7 +197,7 @@ void fBIT(Addressing addr, address val){ // Shift and Rotate Instructions -void fASL(Addressing addr, address val){ +void fASL(Addressing addr){ if (addr == eAccumulator) { SetFlag(flag_C, (acc & 0x80)); acc = (idata.value << 1) & 0xFE; @@ -213,7 +213,7 @@ void fASL(Addressing addr, address val){ } } -void fLSR(Addressing addr, address val){ +void fLSR(Addressing addr){ if (addr == eAccumulator) { SetFlag(flag_C, (acc & 0x01)); acc = (idata.value >> 1) & 0x7F; @@ -229,7 +229,7 @@ void fLSR(Addressing addr, address val){ } } -void fROL(Addressing addr, address val){ +void fROL(Addressing addr){ if (addr == eAccumulator) { SetFlag(flag_C, (idata.value & 0x80)); acc = (idata.value << 1) & 0xFE; @@ -248,7 +248,7 @@ void fROL(Addressing addr, address val){ } } -void fROR(Addressing addr, address val){ +void fROR(Addressing addr){ if (addr == eAccumulator) { SetFlag(flag_C, (idata.value & 0x01)); acc = (idata.value >> 1) & 0x7F; @@ -269,25 +269,25 @@ void fROR(Addressing addr, address val){ // Transfer Instructions -void fTAX(Addressing addr, address val){ +void fTAX(Addressing addr){ X = acc; SetFlagN(X); SetFlagZ(X); } -void fTAY(Addressing addr, address val){ +void fTAY(Addressing addr){ Y = acc; SetFlagN(Y); SetFlagZ(Y); } -void fTXA(Addressing addr, address val){ +void fTXA(Addressing addr){ acc = X; SetFlagN(acc); SetFlagZ(acc); } -void fTYA(Addressing addr, address val){ +void fTYA(Addressing addr){ acc = Y; SetFlagN(acc); SetFlagZ(acc); @@ -295,46 +295,46 @@ void fTYA(Addressing addr, address val){ // Stack Instructions -void fTSX(Addressing addr, address val){ +void fTSX(Addressing addr){ X = S; } -void fTXS(Addressing addr, address val){ +void fTXS(Addressing addr){ S = X; } -void fPHA(Addressing addr, address val){ +void fPHA(Addressing addr){ SetStack(acc); } -void fPHP(Addressing addr, address val){ +void fPHP(Addressing addr){ SetStack(P); } -void fPLA(Addressing addr, address val){ +void fPLA(Addressing addr){ acc = GetStack(); } -void fPLP(Addressing addr, address val){ +void fPLP(Addressing addr){ P = GetStack(); } // Subroutine Instructions -void fJSR(Addressing addr, address val){ +void fJSR(Addressing addr){ SetStack ((PC+idata.length) >> 8); SetStack(((PC+idata.length) & 0x00FF) - 1); PC = idata.add; PC -= idata.length; } -void fRTS(Addressing addr, address val){ +void fRTS(Addressing addr){ PC = (address)(GetStack()) + 1; PC += ((address)(GetStack())) << 8; PC -= idata.length; } -void fRTI(Addressing addr, address val){ +void fRTI(Addressing addr){ P = GetStack(); //NEED TO FIX PC = (address)(GetStack()); PC += (address)(GetStack() << 8); @@ -342,40 +342,40 @@ void fRTI(Addressing addr, address val){ // Set/Reset Insutrctions -void fCLC(Addressing addr, address val){ +void fCLC(Addressing addr){ SetFlag(flag_C, 0); } -void fCLD(Addressing addr, address val){ +void fCLD(Addressing addr){ SetFlag(flag_D, 0); } -void fCLI(Addressing addr, address val){ +void fCLI(Addressing addr){ SetFlag(flag_I, 0); } -void fCLV(Addressing addr, address val){ +void fCLV(Addressing addr){ SetFlag(flag_V, 0); } -void fSEC(Addressing addr, address val){ +void fSEC(Addressing addr){ SetFlag(flag_C, 1); } -void fSED(Addressing addr, address val){ +void fSED(Addressing addr){ SetFlag(flag_D, 1); } -void fSEI(Addressing addr, address val){ +void fSEI(Addressing addr){ SetFlag(flag_I, 1); } // NOP/BRK Instructions -void fNOP(Addressing addr, address val){ +void fNOP(Addressing addr){ } -void fBRK(Addressing addr, address val){ +void fBRK(Addressing addr){ SetStack((((PC+2) & 0xFF00) >> 8)); SetStack((PC+2) & 0x00FF); SetStack(P); |