summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpu/instructions.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c
index c83a428..7cbf5ed 100644
--- a/src/cpu/instructions.c
+++ b/src/cpu/instructions.c
@@ -18,26 +18,32 @@ AddData idata;
void fLDA(Addressing addr, address val){
acc = idata.value;
+ PC += idata.length;
}
void fLDX(Addressing addr, address val){
X = idata.value;
+ PC += idata.length;
}
void fLDY(Addressing addr, address val){
Y = idata.value;
+ PC += idata.length;
}
void fSTA(Addressing addr, address val){
SetMemory(idata.add, acc);
+ PC += idata.length;
}
void fSTX(Addressing addr, address val){
SetMemory(idata.add, X);
+ PC += idata.length;
}
void fSTY(Addressing addr, address val){
SetMemory(idata.add, Y);
+ PC += idata.length;
}
// Arithmetic Instructions
@@ -54,6 +60,7 @@ void fADC(Addressing addr, address val){
acc += idata.value;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fSBC(Addressing addr, address val){
@@ -68,6 +75,7 @@ void fSBC(Addressing addr, address val){
acc -= idata.value;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
//Increment and Decrement Instructions
@@ -78,18 +86,21 @@ void fINC(Addressing addr, address val){
SetMemory(idata.add, a);
SetFlagN(Memory[idata.add]);
SetFlagZ(Memory[idata.add]);
+ PC += idata.length;
}
void fINX(Addressing addr, address val){
X++;
SetFlagN(X);
SetFlagZ(X);
+ PC += idata.length;
}
void fINY(Addressing addr, address val){
Y++;
SetFlagN(Y);
SetFlagZ(Y);
+ PC += idata.length;
}
void fDEC(Addressing addr, address val){
@@ -98,18 +109,21 @@ void fDEC(Addressing addr, address val){
SetMemory(idata.add, a);
SetFlagN(Memory[idata.add]);
SetFlagZ(Memory[idata.add]);
+ PC += idata.length;
}
void fDEX(Addressing addr, address val){
X--;
SetFlagN(X);
SetFlagZ(X);
+ PC += idata.length;
}
void fDEY(Addressing addr, address val){
Y--;
SetFlagN(Y);
SetFlagZ(Y);
+ PC += idata.length;
}
// Logical Instructions
@@ -118,18 +132,21 @@ void fAND(Addressing addr, address val){
acc &= idata.value;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fORA(Addressing addr, address val){
acc |= idata.value;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fEOR(Addressing addr, address val){
acc ^= idata.value;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
// Jump, Branch, Compare, and Test Bits
@@ -181,6 +198,7 @@ void fCMP(Addressing addr, address val){
else if (acc > idata.value){
flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
}
+ PC += idata.length;
}
void fCPX(Addressing addr, address val){
@@ -193,6 +211,7 @@ void fCPX(Addressing addr, address val){
else if (X > idata.value){
flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
}
+ PC += idata.length;
}
void fCPY(Addressing addr, address val){
@@ -205,6 +224,7 @@ void fCPY(Addressing addr, address val){
else if (Y > idata.value){
flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
}
+ PC += idata.length;
}
//NEED TO DOUBLE CHECK THIS INSTRUCTION
@@ -217,6 +237,7 @@ void fBIT(Addressing addr, address val){
} else {
flagSet(flag_Z);
}
+ PC += idata.length;
}
// Shift and Rotate Instructions
@@ -226,6 +247,7 @@ void fASL(Addressing addr, address val){
acc = (idata.value << 1);
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fLSR(Addressing addr, address val){
@@ -233,6 +255,7 @@ void fLSR(Addressing addr, address val){
acc = (idata.value >> 1);
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fROL(Addressing addr, address val){
@@ -241,6 +264,7 @@ void fROL(Addressing addr, address val){
acc |= (getFlag(flag_C) * 0x01);
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fROR(Addressing addr, address val){
@@ -249,6 +273,7 @@ void fROR(Addressing addr, address val){
acc |= (getFlag(flag_C) * 0x80);
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
// Transfer Instructions
@@ -257,54 +282,64 @@ void fTAX(Addressing addr, address val){
X = acc;
//SetFlagN(X);
//SetFlagZ(X);
+ PC += idata.length;
}
void fTAY(Addressing addr, address val){
Y = acc;
//SetFlagN(Y);
//SetFlagZ(Y);
+ PC += idata.length;
}
void fTXA(Addressing addr, address val){
acc = X;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
void fTYA(Addressing addr, address val){
acc = Y;
SetFlagN(acc);
SetFlagZ(acc);
+ PC += idata.length;
}
// Stack Instructions
void fTSX(Addressing addr, address val){
X = S;
+ PC += idata.length;
}
void fTXS(Addressing addr, address val){
S = X;
+ PC += idata.length;
}
void fPHA(Addressing addr, address val){
SetStack(acc);
S++;
+ PC += idata.length;
}
void fPHP(Addressing addr, address val){
SetStack(P);
S++;
+ PC += idata.length;
}
void fPLA(Addressing addr, address val){
S--;
acc = GetStack();
+ PC += idata.length;
}
void fPLP(Addressing addr, address val){
S--;
P = GetStack();
+ PC += idata.length;
}
// Subroutine Instructions
@@ -338,35 +373,43 @@ void fRTI(Addressing addr, address val){
void fCLC(Addressing addr, address val){
flagClear(flag_C);
+ PC += idata.length;
}
void fCLD(Addressing addr, address val){
flagClear(flag_D);
+ PC += idata.length;
}
void fCLI(Addressing addr, address val){
flagClear(flag_I);
+ PC += idata.length;
}
void fCLV(Addressing addr, address val){
flagClear(flag_V);
+ PC += idata.length;
}
void fSEC(Addressing addr, address val){
flagSet(flag_C);
+ PC += idata.length;
}
void fSED(Addressing addr, address val){
flagSet(flag_D);
+ PC += idata.length;
}
void fSEI(Addressing addr, address val){
flagSet(flag_I);
+ PC += idata.length;
}
// NOP/BRK Instructions
void fNOP(Addressing addr, address val){
+ PC += idata.length;
}
void fBRK(Addressing addr, address val){
@@ -383,4 +426,4 @@ void fBRK(Addressing addr, address val){
#ifdef ILLEGAL_INSTRUCTIONS
-#endif \ No newline at end of file
+#endif