diff options
-rw-r--r-- | src/cpu/instructions.c | 16 | ||||
-rw-r--r-- | src/cpu/table.c | 12 | ||||
-rw-r--r-- | src/main.c | 3 |
3 files changed, 16 insertions, 15 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); @@ -12,7 +12,8 @@ int main() { while(1) { CallInstructionTable(GetMemory(PC), 0); PrintInfo(); - sleep(3); + //sleep(3); + getch(); } TerminalClose(); |