summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 21:06:45 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 21:06:45 +1100
commit09288876a8080b2a643a8c644eb116c021f0c397 (patch)
treecd4595978df9058c98f54eba2b2d312176c28169
parentfe180c8df4f656dc788af4d478dbbb53c0e5253b (diff)
changed compare instructions
-rw-r--r--src/cpu/addressing.c4
-rw-r--r--src/cpu/instructions.c37
-rw-r--r--src/cpu/table.c2
3 files changed, 12 insertions, 31 deletions
diff --git a/src/cpu/addressing.c b/src/cpu/addressing.c
index f21e7da..f381e51 100644
--- a/src/cpu/addressing.c
+++ b/src/cpu/addressing.c
@@ -50,8 +50,8 @@ byte fAddressGetValue(Addressing mode, short x, address addr) {
switch(mode){
case eImplied:
case eIndirectAbsolute:
- case eRelative:
return 0;
+ case eRelative: // TODO: MARKER FOR 3/12/2023
case eImmediate:
return x;
case eAccumulator:
@@ -176,4 +176,4 @@ AddData fAddress(Addressing mode, short x) {
ret.length = fAddressGetLength (mode);
ret.cycles = fAddressGetCycles (mode, x, ret.add);
return ret;
-} \ No newline at end of file
+}
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c
index 2d4fc9e..2a2f97f 100644
--- a/src/cpu/instructions.c
+++ b/src/cpu/instructions.c
@@ -172,42 +172,23 @@ void fBVC(Addressing addr, address val){
}
void fCMP(Addressing addr, address val){
- if (acc < idata.value){
- flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
- }
- else if (acc == idata.value){
- flagClear(flag_N); flagSet(flag_Z); flagClear(flag_C);
- }
- else if (acc > idata.value){
- flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
- }
+ SetFlag(flag_C, (acc >= val) ? 1 : 0);
+ SetFlag(flag_Z, (acc == val) ? 1 : 0);
+ SetFlag(flag_N, (acc & flag_N ) ? 1 : 0);
}
void fCPX(Addressing addr, address val){
- if (X < idata.value){
- flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
- }
- else if (X == idata.value){
- flagClear(flag_N); flagSet(flag_Z); flagClear(flag_C);
- }
- else if (X > idata.value){
- flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
- }
+ SetFlag(flag_C, (X >= val) ? 1 : 0);
+ SetFlag(flag_Z, (X == val) ? 1 : 0);
+ SetFlag(flag_N, (X & flag_N ) ? 1 : 0);
}
void fCPY(Addressing addr, address val){
- if (Y < idata.value){
- flagSet(flag_N); flagClear(flag_Z); flagClear(flag_C);
- }
- else if (Y == idata.value){
- flagClear(flag_N); flagSet(flag_Z); flagClear(flag_C);
- }
- else if (Y > idata.value){
- flagClear(flag_N); flagClear(flag_Z); flagSet(flag_C);
- }
+ SetFlag(flag_C, (Y >= val) ? 1 : 0);
+ SetFlag(flag_Z, (Y == val) ? 1 : 0);
+ SetFlag(flag_N, (Y & flag_N ) ? 1 : 0);
}
-//NEED TO DOUBLE CHECK THIS INSTRUCTION
void fBIT(Addressing addr, address val){
SetFlag(flag_N, (idata.value & flag_N)?1:0);
SetFlag(flag_V, (idata.value & flag_V)?1:0);
diff --git a/src/cpu/table.c b/src/cpu/table.c
index ca14c1c..735ab80 100644
--- a/src/cpu/table.c
+++ b/src/cpu/table.c
@@ -34,7 +34,7 @@ void CallInstructionTable(int i, address val){
idata = fAddress(*r, val);
// Perform function
- func(*r, val);
+ func(*r, val); // TODO: MARKER FOR 3/12/2023
PC += idata.length;
}