summaryrefslogtreecommitdiff
path: root/instruction.h
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-04-03 13:36:27 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-04-03 13:36:27 +1000
commitc9df40c99f40418d869712b31de1b59d7654362f (patch)
tree86ee085c3df1e90fcdab0b1cc8a1e56c69df0a15 /instruction.h
parent970f76b28ff07206b9e7bdfdce84a7bf8f5aecd0 (diff)
removed some files
Diffstat (limited to 'instruction.h')
-rw-r--r--instruction.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/instruction.h b/instruction.h
index bdb337c..b296e0c 100644
--- a/instruction.h
+++ b/instruction.h
@@ -4,14 +4,16 @@
// how many cycles passed
struct instruction_data {
- int length;
- int cycles;
+ int length = 0;
+ int cycles = 0;
};
int getLength(Addressing addr){
switch(addr){
- case eZeroPage: case eZeroPageIndexedX: case eZeroPageIndexedY:
+ case eAbsolute: case eAbsoluteIndexedX: case eAbsoluteIndexedY:
return 3;
+ case eAccumulator:
+ return 1;
default:
return 2;
}
@@ -21,34 +23,45 @@ int getLength(Addressing addr){
// Load and Store Instructions
instruction_data fLDA(Addressing addr, address val){
- acc = fAddressing(addr, val);
instruction_data d; d.length = getLength(addr);
-
+ acc = fAddressing(addr, val);
+ return d;
}
instruction_data fLDX(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
X = fAddressing(addr, val);
+ return d;
}
instruction_data fLDY(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
Y = fAddressing(addr, val);
+ return d;
}
instruction_data fSTA(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
Memory[(fAddressing(addr, val))] = acc;
+ return d;
}
instruction_data fSTX(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
Memory[(fAddressing(addr, val))] = X;
+ return d;
}
instruction_data fSTY(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
Memory[(fAddressing(addr, val))] = Y;
+ return d;
}
// Arithmetic Instructions
instruction_data fADC(Addressing addr, address val){
+ instruction_data d; d.length = getLength(addr);
int buffer = acc + fAddressing(addr, val);
setFlagV(buffer, acc);
@@ -138,39 +151,39 @@ instruction_data fEOR(Addressing addr, address val){
// Jump, Branch, Compare, and Test Bits
instruction_data fJMP(address val){
- S = val;
+ PC = val;
}
instruction_data fBCC(signed char val){
- if (getFlag(flag_C) == 0) S += val;
+ if (getFlag(flag_C) == 0) PC += val;
}
instruction_data fBCS(signed char val){
- if (getFlag(flag_C) == 1) S += val;
+ if (getFlag(flag_C) == 1) PC += val;
}
instruction_data fBEQ(signed char val){
- if (getFlag(flag_Z) == 1) S += val;
+ if (getFlag(flag_Z) == 1) PC += val;
}
instruction_data fBNE(signed char val){
- if (getFlag(flag_Z) == 0) S += val;
+ if (getFlag(flag_Z) == 0) PC += val;
}
instruction_data fBMI(signed char val){
- if (getFlag(flag_N) == 1) S += val;
+ if (getFlag(flag_N) == 1) PC += val;
}
instruction_data fBPL(signed char val){
- if (getFlag(flag_N) == 0) S += val;
+ if (getFlag(flag_N) == 0) PC += val;
}
instruction_data fBVS(signed char val){
- if (getFlag(flag_V) == 1) S += val;
+ if (getFlag(flag_V) == 1) PC += val;
}
instruction_data fBVC(signed char val){
- if (getFlag(flag_V) == 0) S += val;
+ if (getFlag(flag_V) == 0) PC += val;
}
instruction_data fCMP(address val){