diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-30 19:19:22 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-30 19:19:22 +1100 |
commit | 40447eccd6db43d636ccc518ae7792b7b43834b5 (patch) | |
tree | 09471aa08737e6555dd060179b6a33944e931f51 /src/cpu | |
parent | 7a3307ad3785a6cd72c820ea6b44086817a20e81 (diff) |
fixed BIT and branch instructions
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/instructions.c | 16 | ||||
-rw-r--r-- | src/cpu/table.c | 12 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index 50941a8..36e2a41 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -158,56 +158,56 @@ 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; + PC += (char)val; else PC += idata.length; } void fBCS(Addressing addr, address val){ if (getFlag(flag_C) == 1) - PC += val; + PC += (char)val; else PC += idata.length; } void fBEQ(Addressing addr, address val){ if (getFlag(flag_Z) == 1) - PC += val; + PC += (char)val; else PC += idata.length; } void fBNE(Addressing addr, address val){ if (getFlag(flag_Z) == 0) - PC += val; + PC += (char)val; else PC += idata.length; } void fBMI(Addressing addr, address val){ if (getFlag(flag_N) == 1) - PC += val; + PC += (char)val; else PC += idata.length; } void fBPL(Addressing addr, address val){ if (getFlag(flag_N) == 0) - PC += val; + PC += (char)val; else PC += idata.length; } void fBVS(Addressing addr, address val){ if (getFlag(flag_V) == 1) - PC += val; + PC += (char)val; else PC += idata.length; } void fBVC(Addressing addr, address val){ if (getFlag(flag_V) == 0) - PC += val; + PC += (char)val; else PC += idata.length; } diff --git a/src/cpu/table.c b/src/cpu/table.c index 9597657..27ec8f2 100644 --- a/src/cpu/table.c +++ b/src/cpu/table.c @@ -26,10 +26,10 @@ void CallInstructionTable(int i, address val){ Addressing* r = (InstructionTable + ((sizeof(uintptr_t)*256) + (sizeof(Addressing) * i))); // Set val - if (fAddressGetLength(*r) > 0) - val += GetMemory(PC+1); - if (fAddressGetLength(*r) > 1) - val += GetMemory(PC+2) << 8; + if (fAddressGetLength(*r) >= 2) + val += (address)GetMemory(PC+1); + if (fAddressGetLength(*r) == 3) + val += (address)GetMemory(PC+2) << 8; // Set idata idata = fAddress(*r, val); @@ -193,8 +193,8 @@ void InitInstructionTable(){ SetInstructionTable(0xC4, (uintptr_t)&fCPY, eZeroPage); SetInstructionTable(0xCC, (uintptr_t)&fCPY, eAbsolute); //BIT(Addressing, address); - SetInstructionTable(0x4C, (uintptr_t)&fBIT, eZeroPage); - SetInstructionTable(0x6C, (uintptr_t)&fBIT, eAbsolute); + SetInstructionTable(0x24, (uintptr_t)&fBIT, eZeroPage); + SetInstructionTable(0x2C, (uintptr_t)&fBIT, eAbsolute); // Shift and Rotate Instructions //ASL(Addressing, address); |