summaryrefslogtreecommitdiff
path: root/src/cpu/instructions
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-05-08 09:49:43 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-05-08 09:49:43 +1000
commitc1d5bf8ab7648418fa7120ea4868205f3cf7e857 (patch)
tree1ec819cd36dbf4793e62f375eb4a98f3c60f2b26 /src/cpu/instructions
parent093e29e4544f16f7058b6e8cf824ef789f864410 (diff)
instructions done, plus minor changes
Diffstat (limited to 'src/cpu/instructions')
-rw-r--r--src/cpu/instructions/definitions.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/cpu/instructions/definitions.h b/src/cpu/instructions/definitions.h
index 937ca10..98345c5 100644
--- a/src/cpu/instructions/definitions.h
+++ b/src/cpu/instructions/definitions.h
@@ -2,7 +2,8 @@
// Definition of all instruction functions, handling effect of instruction and flags.
AddData idata;
-
+#define GET_STACK getMemory(0x01FF - S)
+#define SET_STACK(z) setMemory(0x01FF - S, z)
/* TO DO
@@ -280,40 +281,50 @@ void fTXS(Addressing addr, address val){ idata = fAddress(addr, val);
}
void fPHA(Addressing addr, address val){ idata = fAddress(addr, val);
- setMemory(0x01FF-S, acc);
+ SET_STACK(acc);
S++;
}
void fPHP(Addressing addr, address val){ idata = fAddress(addr, val);
- setMemory(0x01FF-S, P);
+ SET_STACK(P);
S++;
}
void fPLA(Addressing addr, address val){ idata = fAddress(addr, val);
S--;
- acc = getMemory(0x01FF-S);
+ acc = GET_STACK;
}
void fPLP(Addressing addr, address val){ idata = fAddress(addr, val);
S--;
- P = getMemory(0x01FF-S);
+ P = GET_STACK;
}
// Subroutine Instructions
// NEED TO FINISH THESE
void fJSR(Addressing addr, address val){ idata = fAddress(addr, val);
- Memory[0x01FF-S] = (idata.add-1);
+ SET_STACK(((PC-1) & 0xFF00) >> 8);
+ S++;
+ SET_STACK((PC-1) & 0x00FF);
S++;
PC = idata.add;
}
void fRTS(Addressing addr, address val){ idata = fAddress(addr, val);
-
+ S--;
+ PC = (address)(GET_STACK + 1);
+ S--;
+ PC += ((address)(GET_STACK)) << 8;
}
void fRTI(Addressing addr, address val){ idata = fAddress(addr, val);
-
+ S--;
+ P = GET_STACK; //NEED TO FIX
+ S--;
+ PC = (address)(GET_STACK);
+ S--;
+ PC += (address)(GET_STACK << 8);
}
// Set/Reset Insutrctions
@@ -352,7 +363,14 @@ void fNOP(Addressing addr, address val){ idata = fAddress(addr, val);
}
void fBRK(Addressing addr, address val){ idata = fAddress(addr, val);
- flagSet(flag_B);
+ SET_STACK((((PC+2) & 0xFF00) >> 8));
+ S++;
+ SET_STACK((PC+2) & 0x00FF);
+ S++;
+ SET_STACK(P);
+ S++;
+ PC = (address)(getMemory(0xFFFE));
+ PC += ((address)(getMemory(0xFFFF)) << 8);
}
#ifdef ILLEGAL