summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-11-30 19:19:22 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-11-30 19:19:22 +1100
commit40447eccd6db43d636ccc518ae7792b7b43834b5 (patch)
tree09471aa08737e6555dd060179b6a33944e931f51 /src
parent7a3307ad3785a6cd72c820ea6b44086817a20e81 (diff)
fixed BIT and branch instructions
Diffstat (limited to 'src')
-rw-r--r--src/cpu/instructions.c16
-rw-r--r--src/cpu/table.c12
-rw-r--r--src/main.c3
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);
diff --git a/src/main.c b/src/main.c
index 39ddbcc..f7a6a00 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,7 +12,8 @@ int main() {
while(1) {
CallInstructionTable(GetMemory(PC), 0);
PrintInfo();
- sleep(3);
+ //sleep(3);
+ getch();
}
TerminalClose();