summaryrefslogtreecommitdiff
path: root/src/cpu/instructions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/instructions.c')
-rw-r--r--src/cpu/instructions.c37
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);