From 3029d54edf8baabb2841f9a6f3d88bfc993ae3e8 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 19 Dec 2019 01:02:09 -0500 Subject: Added the B register, which is used for storing the remainder during a DIV instruction. I also added the TAB, and TBA instructions, for transfering between the Accumulator, and the B register. --- sux.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sux.c') diff --git a/sux.c b/sux.c index 70b8a92..96068a8 100644 --- a/sux.c +++ b/sux.c @@ -4,8 +4,8 @@ #include #include #define bench 0 -#define debug 0 -#define IO 1 +#define debug 1 +#define IO 0 #define keypoll 0 #if bench #include @@ -222,7 +222,9 @@ void *run(void *args) { case TYA: /* Transfer Y to Accumulator. */ case TXA: /* Transfer X to Accumulator. */ case TXY: /* Transfer X to Y. */ + case TAB: /* Transfer Accumulator to B. */ case TSX: /* Transfer Stack pointer to X. */ + case TBA: /* Transfer B to Accumulator. */ case TXS: /* Transfer X to Stack pointer. */ if (opcode == TAY) cpu->y[thread] = cpu->a[thread]; @@ -236,10 +238,17 @@ void *run(void *args) { cpu->a[thread] = cpu->x[thread]; if (opcode == TXY) cpu->y[thread] = cpu->x[thread]; + if (opcode == TAB) { + cpu->b[thread] = cpu->a[thread]; + cpu->z[thread] = (cpu->b[thread] == 0); + cpu->n[thread] = (cpu->b[thread] >> 63); + } if (opcode == TSX) { cpu->x[thread] = cpu->sp[thread] & 0xFFFF; cpu->x[thread] = cpu->stk_st[thread] << 16; } + if (opcode == TBA) + cpu->a[thread] = cpu->b[thread]; if (opcode == TXS) { cpu->sp[thread] = cpu->x[thread]; if (prefix == 0x17 && (value == thread+1 || value > 8)) { @@ -248,7 +257,7 @@ void *run(void *args) { cpu->pc[thread]+=2; } } - if (opcode == TYA || opcode == TXA) { + if (opcode == TYA || opcode == TXA || opcode == TBA) { cpu->z[thread] = (cpu->a[thread] == 0); cpu->n[thread] = (cpu->a[thread] >> 63); } @@ -1207,6 +1216,7 @@ void *run(void *args) { value += (uint64_t)addr[address+6] << 48; value += (uint64_t)addr[address+7] << 56; } + cpu->b[thread] = cpu->a[thread] % value; sum = cpu->a[thread]/value; cpu->a[thread] = sum; cpu->z[thread] = (sum == 0); -- cgit v1.2.3-13-gbd6f