diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-30 18:36:23 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-30 18:36:23 +1100 |
commit | 7a3307ad3785a6cd72c820ea6b44086817a20e81 (patch) | |
tree | 93bc1480214ea3a8a6386293d900162529a75061 /src/cpu | |
parent | 016c44a28a975d04b48fd77dd112d8095876bee8 (diff) |
fixed branching instructions
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/instructions.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index 7cbf5ed..50941a8 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -157,35 +157,59 @@ void fJMP(Addressing addr, address val){ void fBCC(Addressing addr, address val){ //FINISH ALL BRANCH INSTRUCTIONS //signed char val down to BVC - if (getFlag(flag_C) == 0) PC += val; + if (getFlag(flag_C) == 0) + PC += val; + else + PC += idata.length; } void fBCS(Addressing addr, address val){ - if (getFlag(flag_C) == 1) PC += val; + if (getFlag(flag_C) == 1) + PC += val; + else + PC += idata.length; } void fBEQ(Addressing addr, address val){ - if (getFlag(flag_Z) == 1) PC += val; + if (getFlag(flag_Z) == 1) + PC += val; + else + PC += idata.length; } void fBNE(Addressing addr, address val){ - if (getFlag(flag_Z) == 0) PC += val; + if (getFlag(flag_Z) == 0) + PC += val; + else + PC += idata.length; } void fBMI(Addressing addr, address val){ - if (getFlag(flag_N) == 1) PC += val; + if (getFlag(flag_N) == 1) + PC += val; + else + PC += idata.length; } void fBPL(Addressing addr, address val){ - if (getFlag(flag_N) == 0) PC += val; + if (getFlag(flag_N) == 0) + PC += val; + else + PC += idata.length; } void fBVS(Addressing addr, address val){ - if (getFlag(flag_V) == 1) PC += val; + if (getFlag(flag_V) == 1) + PC += val; + else + PC += idata.length; } void fBVC(Addressing addr, address val){ - if (getFlag(flag_V) == 0) PC += val; + if (getFlag(flag_V) == 0) + PC += val; + else + PC += idata.length; } void fCMP(Addressing addr, address val){ |