summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-10-06 08:02:23 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-10-06 08:02:23 -0400
commit8aa8586b03568d3a3d6eba39269a1b79510bc835 (patch)
treeb674ea424fd816fe4219b4423c2e3544b1ff58ce /sux.c
parent8c880c339000010260a927c3a0f28f9049b8a0b8 (diff)
- Made the stack pointer 64 bit, rather than 16 bit.
This is to allow for making the stack bigger for anything that needs to change the size of it. - Made the SuB Suite set the stack pointer to the end of the usable RAM, and allow for changing the stack size. In this case, the size of the stack is currently set to 192K, with the end of the heap being just below the stack.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sux.c b/sux.c
index acd834e..adca16f 100644
--- a/sux.c
+++ b/sux.c
@@ -228,7 +228,6 @@ void *run(void *args) {
uint8_t rs = (prefix >> 4) & 3;
uint8_t size = (/***/1 << rs) - 1;
uint8_t check_io = (am != IMM);
- uint64_t sp = (cpu->sp & 0xFFFF) | (cpu->stk_st << 16);
#if debug && !bench
#if keypoll
pthread_mutex_lock(&mutex);
@@ -265,16 +264,16 @@ void *run(void *args) {
case PHB_IMP: push(cpu, cpu->b , size, thread); break; /* PusH B register to stack. */
case PHY_IMP: push(cpu, cpu->y , size, thread); break; /* PusH Y register to stack. */
case PHX_IMP: push(cpu, cpu->x , size, thread); break; /* PusH X register to stack. */
- case TAY_IMP: cpu->y = transfer(cpu, cpu->a, value.u64, opcode, prefix, thread); break; /* Transfer Accumulator to Y. */
- case TAX_IMP: cpu->x = transfer(cpu, cpu->a, value.u64, opcode, prefix, thread); break; /* Transfer Accumulator to Y. */
- case TYX_IMP: cpu->x = transfer(cpu, cpu->y, value.u64, opcode, prefix, thread); break; /* Transfer Y to X. */
- case TYA_IMP: cpu->a = transfer(cpu, cpu->y, value.u64, opcode, prefix, thread); break; /* Transfer Y to Accumulator. */
- case TXA_IMP: cpu->a = transfer(cpu, cpu->x, value.u64, opcode, prefix, thread); break; /* Transfer X to Accumulator. */
- case TXY_IMP: cpu->y = transfer(cpu, cpu->x, value.u64, opcode, prefix, thread); break; /* Transfer X to Y. */
- case TAB_IMP: cpu->b = transfer(cpu, cpu->a, value.u64, opcode, prefix, thread); break; /* Transfer Accumulator to B. */
- case TSX_IMP: cpu->x = transfer(cpu, sp, value.u64, opcode, prefix, thread); break; /* Transfer Stack pointer to X. */
- case TBA_IMP: cpu->a = transfer(cpu, cpu->b, value.u64, opcode, prefix, thread); break; /* Transfer B to Accumulator. */
- case TXS_IMM: cpu->sp = transfer(cpu, cpu->x, value.u64, opcode, prefix, thread); break; /* Transfer X to Stack pointer. */
+ case TAY_IMP: cpu->y = transfer(cpu, cpu->a , value.u64, thread); break; /* Transfer Accumulator to Y. */
+ case TAX_IMP: cpu->x = transfer(cpu, cpu->a , value.u64, thread); break; /* Transfer Accumulator to Y. */
+ case TYX_IMP: cpu->x = transfer(cpu, cpu->y , value.u64, thread); break; /* Transfer Y to X. */
+ case TYA_IMP: cpu->a = transfer(cpu, cpu->y , value.u64, thread); break; /* Transfer Y to Accumulator. */
+ case TXA_IMP: cpu->a = transfer(cpu, cpu->x , value.u64, thread); break; /* Transfer X to Accumulator. */
+ case TXY_IMP: cpu->y = transfer(cpu, cpu->x , value.u64, thread); break; /* Transfer X to Y. */
+ case TAB_IMP: cpu->b = transfer(cpu, cpu->a , value.u64, thread); break; /* Transfer Accumulator to B. */
+ case TSX_IMP: cpu->x = transfer(cpu, cpu->sp, value.u64, thread); break; /* Transfer Stack pointer to X. */
+ case TBA_IMP: cpu->a = transfer(cpu, cpu->b , value.u64, thread); break; /* Transfer B to Accumulator. */
+ case TXS_IMM: cpu->sp = transfer(cpu, cpu->x , value.u64, thread); break; /* Transfer X to Stack pointer. */
case BRA_REL: /* BRA Relative. */
case JMP_AB: /* JMP Absolute. */
case JMP_Z: /* JMP Zero Matrix. */
@@ -656,8 +655,7 @@ int main(int argc, char **argv) {
uint16_t vec = 0xFFC0;
uint8_t offset;
for (int i = 0; i < THREADS; i++) {
- thr[i].sx.sp = 0xFFFF;
- thr[i].sx.stk_st = i+1;
+ thr[i].sx.sp = (i << 16) | 0xFFFF;
offset = (i) ? ((i-1) << 3) : 0;
vec = (i) ? 0xFF50 : 0xFFC0;
thr[i].sx.a = 0;