diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-19 01:02:09 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-19 01:07:44 -0500 |
commit | 3029d54edf8baabb2841f9a6f3d88bfc993ae3e8 (patch) | |
tree | a6d13de021ef642eeefcc3d0804764d86f72365d /sux.c | |
parent | ca5f89b8f043b180c26ef2494cab52121ba97328 (diff) |
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.
Diffstat (limited to 'sux.c')
-rw-r--r-- | sux.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -4,8 +4,8 @@ #include <string.h> #include <pthread.h> #define bench 0 -#define debug 0 -#define IO 1 +#define debug 1 +#define IO 0 #define keypoll 0 #if bench #include <sys/time.h> @@ -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); |