summaryrefslogtreecommitdiff
path: root/instruction.h
diff options
context:
space:
mode:
Diffstat (limited to 'instruction.h')
-rw-r--r--instruction.h118
1 files changed, 49 insertions, 69 deletions
diff --git a/instruction.h b/instruction.h
index 2c4c3a2..c1b4843 100644
--- a/instruction.h
+++ b/instruction.h
@@ -1,4 +1,3 @@
-
// array/map of pointers which all point
// to the functions which the index corresponds to.
// use that like a sort of map
@@ -36,8 +35,7 @@ void fSTY(Addressing addr, address val){ idata = fAddress(addr, val);
// Arithmetic Instructions
-instruction_data fADC(Addressing addr, address val){
- instruction_data d; d.length = getLength(addr);
+void fADC(Addressing addr, address val){ idata = fAddress(addr, val);
int buffer = acc + fAddress(addr, val);
setFlagV(buffer, acc);
@@ -52,7 +50,7 @@ instruction_data fADC(Addressing addr, address val){
setFlagZ(acc);
}
-instruction_data fSBC(Addressing addr, address val){
+void fSBC(Addressing addr, address val){ idata = fAddress(addr, val);
int buffer = acc - fAddress(addr, val);
setFlagV(buffer, acc);
@@ -68,37 +66,37 @@ instruction_data fSBC(Addressing addr, address val){
//Increment and Decrement Instructions
-instruction_data fINC(Addressing addr, address val){
+void fINC(Addressing addr, address val){ idata = fAddress(addr, val);
Memory[x]++;
setFlagD(Memory[x]);
setFlagZ(Memory[x]);
}
-instruction_data fINX(){
+void fINX(Addressing addr, address val){ idata = fAddress(addr, val);
X++;
setFlagD(X);
setFlagZ(X);
}
-instruction_data fINY(){
+void fINY(Addressing addr, address val){ idata = fAddress(addr, val);
Y++;
setFlagD(Y);
setFlagZ(Y);
}
-instruction_data fDEC(Addressing addr, address val){
+void fDEC(Addressing addr, address val){ idata = fAddress(addr, val);
Memory[x]--;
setFlagD(Memory[x]);
setFlagZ(Memory[x]);
}
-instruction_data fDEX(){
+void fDEX(Addressing addr, address val){ idata = fAddress(addr, val);
X--;
setFlagD(X);
setFlagZ(X);
}
-instruction_data fDEY(){
+void fDEY(Addressing addr, address val){ idata = fAddress(addr, val);
Y--;
setFlagD(Y);
setFlagZ(Y);
@@ -106,19 +104,19 @@ instruction_data fDEY(){
// Logical Instructions
-instruction_data fAND(Addressing addr, address val){
+void fAND(Addressing addr, address val){ idata = fAddress(addr, val);
acc = acc & fAddress(addr, val);
setFlagN();
setFlagZ(acc);
}
-instruction_data fORA(Addressing addr, address val){
+void fORA(Addressing addr, address val){ idata = fAddress(addr, val);
acc = acc | fAddress(addr, val);
setFlagN();
setFlagZ(acc);
}
-instruction_data fEOR(Addressing addr, address val){
+void fEOR(Addressing addr, address val){ idata = fAddress(addr, val);
acc = acc ^ fAddress(addr, val);
setFlagN(acc);
setFlagZ(acc);
@@ -126,43 +124,44 @@ instruction_data fEOR(Addressing addr, address val){
// Jump, Branch, Compare, and Test Bits
-instruction_data fJMP(address val){
+void fJMP(Addressing addr, address val){ idata = fAddress(addr, val);
PC = val;
}
-instruction_data fBCC(signed char val){
+void fBCC(Addressing addr, address val){ idata = fAddress(addr, val);
+ //signed char val down to BVC
if (getFlag(flag_C) == 0) PC += val;
}
-instruction_data fBCS(signed char val){
+void fBCS(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_C) == 1) PC += val;
}
-instruction_data fBEQ(signed char val){
+void fBEQ(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_Z) == 1) PC += val;
}
-instruction_data fBNE(signed char val){
+void fBNE(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_Z) == 0) PC += val;
}
-instruction_data fBMI(signed char val){
+void fBMI(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_N) == 1) PC += val;
}
-instruction_data fBPL(signed char val){
+void fBPL(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_N) == 0) PC += val;
}
-instruction_data fBVS(signed char val){
+void fBVS(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_V) == 1) PC += val;
}
-instruction_data fBVC(signed char val){
+void fBVC(Addressing addr, address val){ idata = fAddress(addr, val);
if (getFlag(flag_V) == 0) PC += val;
}
-instruction_data fCMP(address val){
+void fCMP(Addressing addr, address val){ idata = fAddress(addr, val);
if (acc < Memory[val]){
flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
}if (acc == Memory[val]){
@@ -172,7 +171,7 @@ instruction_data fCMP(address val){
}
}
-instruction_data fCPX(address val){
+void fCPX(Addressing addr, address val){ idata = fAddress(addr, val);
if (X < Memory[val]){
flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
}if (X == Memory[val]){
@@ -182,7 +181,7 @@ instruction_data fCPX(address val){
}
}
-instruction_data fCPY(address val){
+void fCPY(Addressing addr, address val){ idata = fAddress(addr, val);
if (Y < Memory[val]){
flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
}if (Y == Memory[val]){
@@ -192,7 +191,7 @@ instruction_data fCPY(address val){
}
}
-instruction_data fBIT(address val){
+void fBIT(Addressing addr, address val){ idata = fAddress(addr, val);
setFlag(flag_N, (Memory[val] & flag_N));
setFlag(flag_V, (Memory[val] & flag_V));
if (((Memory[val] & flag_N) & (Memory[val] & flag_V)) == 0) {
@@ -204,21 +203,21 @@ instruction_data fBIT(address val){
// Shift and Rotate Instructions
-instruction_data fASL(Addressing addr, address val){
+void fASL(Addressing addr, address val){ idata = fAddress(addr, val);
setFlag(flag_C, (val & 0x80));
acc = (val << 1);
setFlagN(acc);
setFlagZ(acc);
}
-instruction_data fASL(Addressing addr, address val){
+void fASL(Addressing addr, address val){ idata = fAddress(addr, val);
setFlag(flag_C, (val & 0x01));
acc = (val >> 1);
setFlagN(acc);
setFlagZ(acc);
}
-instruction_data fROL(Addressing addr, address val){
+void fROL(Addressing addr, address val){ idata = fAddress(addr, val);
setFlag(flag_C, (val & 0x80));
acc = (val << 1);
acc |= (getFlag(flag_C) * 0x01);
@@ -226,7 +225,7 @@ instruction_data fROL(Addressing addr, address val){
setFlagZ(acc);
}
-instruction_data fROR(Addressing addr, address val){
+void fROR(Addressing addr, address val){ idata = fAddress(addr, val);
setFlag(flag_C, (val & 0x01));
acc = (val >> 1);
acc |= (getFlag(flag_C) * 0x80);
@@ -236,25 +235,25 @@ instruction_data fROR(Addressing addr, address val){
// Transfer Instructions
-instruction_data fTAX(){
+void fTAX(Addressing addr, address val){ idata = fAddress(addr, val);
X = acc;
setFlagN(X);
setFlagZ(X);
}
-instruction_data fTAY(){
+void fTAY(Addressing addr, address val){ idata = fAddress(addr, val);
Y = acc;
setFlagN(Y);
setFlagZ(Y);
}
-instruction_data fTXA(){
+void fTXA(Addressing addr, address val){ idata = fAddress(addr, val);
acc = X;
setFlagN(acc);
setFlagZ(acc);
}
-instruction_data fTYA(){
+void fTYA(Addressing addr, address val){ idata = fAddress(addr, val);
acc = Y;
setFlagN(acc);
setFlagZ(acc);
@@ -262,27 +261,27 @@ instruction_data fTYA(){
// Stack Instructions
-instruction_data fTSX(){
+void fTSX(Addressing addr, address val){ idata = fAddress(addr, val);
X = S;
}
-instruction_data fTXS(){
+void fTXS(Addressing addr, address val){ idata = fAddress(addr, val);
S = X;
}
-instruction_data fPHA(){
+void fPHA(Addressing addr, address val){ idata = fAddress(addr, val);
}
-instruction_data fPHP(){
+void fPHP(Addressing addr, address val){ idata = fAddress(addr, val);
}
-instruction_data fPLA(){
+void fPLA(Addressing addr, address val){ idata = fAddress(addr, val);
}
-instruction_data fPLP(){
+void fPLP(Addressing addr, address val){ idata = fAddress(addr, val);
}
@@ -292,67 +291,48 @@ instruction_data fPLP(){
// Set/Reset Insutrctions
-instruction_data fCLC(){
+void fCLC(Addressing addr, address val){ idata = fAddress(addr, val);
flagClear(flag_C);
return {1, 2};
}
-instruction_data fCLD(){
+void fCLD(Addressing addr, address val){ idata = fAddress(addr, val);
flagClear(flag_D);
return {1, 2};
}
-instruction_data fCLI(){
+void fCLI(Addressing addr, address val){ idata = fAddress(addr, val);
flagClear(flag_I);
return {1, 2};
}
-instruction_data fCLV(){
+void fCLV(Addressing addr, address val){ idata = fAddress(addr, val);
flagClear(flag_V);
return {1, 2};
}
-instruction_data fSEC(){
+void fSEC(Addressing addr, address val){ idata = fAddress(addr, val);
flagSet(flag_C);
return {1, 2};
}
-instruction_data fSED(){
+void fSED(Addressing addr, address val){ idata = fAddress(addr, val);
flagSet(flag_D);
return {1, 2};
}
-instruction_data fSEI(){
+void fSEI(Addressing addr, address val){ idata = fAddress(addr, val);
flagSet(flag_I);
return {1, 2};
}
// NOP/BRK Instructions
-instruction_data fNOP(){
+void fNOP(Addressing addr, address val){ idata = fAddress(addr, val);
return {1, 2};
}
-instruction_data fBRK(){
+void fBRK(Addressing addr, address val){ idata = fAddress(addr, val);
flagSet(flag_B);
return {1, 7};
-}
-
-
-
-
-
-
-
-
-
-
-/*
-void runInstruction(int code, int val){
- switch(code){
-
- }
-
-}
-
-*/ \ No newline at end of file
+} \ No newline at end of file