diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-03 21:06:45 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-03 21:06:45 +1100 |
commit | 09288876a8080b2a643a8c644eb116c021f0c397 (patch) | |
tree | cd4595978df9058c98f54eba2b2d312176c28169 /src/cpu/instructions.c | |
parent | fe180c8df4f656dc788af4d478dbbb53c0e5253b (diff) |
changed compare instructions
Diffstat (limited to 'src/cpu/instructions.c')
-rw-r--r-- | src/cpu/instructions.c | 37 |
1 files changed, 9 insertions, 28 deletions
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); |