summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-12-07 12:21:35 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-12-07 12:21:35 -0500
commit8b20b35bf5506ff74b7337e35d6827064eace425 (patch)
tree70d52e2f59057a6d2d93aaa7d287031afc0973dc /sux.c
parent8d0f46d4e62af5d66ff3cce872256163a41b54bf (diff)
Added six instructions for transfering data
between the three main registers. These instructions are: TAY: Transfer Accumulator to Y. TAX: Transfer Accumulator to X. TYX: Transfer Y to X. TYA: Transfer Y to Accumulator. TXA: Transfer X to Accumulator. TXY: Transfer X to Y.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/sux.c b/sux.c
index 4df60cb..08f5ebe 100644
--- a/sux.c
+++ b/sux.c
@@ -17,7 +17,6 @@ uint8_t threads_done = 0;
uint8_t lines[THREADS];
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-pthread_barrier_t bar;
struct suxthr {
struct sux sx;
uint8_t th;
@@ -175,6 +174,39 @@ void *run(void *args) {
addr[0xFF91] = cpu->sp >> 8;
}
break;
+ case TAY: /* Transfer Accumulator to Y. */
+ case TAX: /* Transfer Accumulator to Y. */
+ case TYX: /* Transfer Y to X. */
+ case TYA: /* Transfer Y to Accumulator. */
+ case TXA: /* Transfer X to Accumulator. */
+ case TXY: /* Transfer X to Y. */
+ if (opcode == TAY)
+ cpu->y[thread] = cpu->a[thread];
+ if (opcode == TAX)
+ cpu->x[thread] = cpu->a[thread];
+ if (opcode == TYX)
+ cpu->x[thread] = cpu->y[thread];
+ if (opcode == TYA)
+ cpu->a[thread] = cpu->y[thread];
+ if (opcode == TXA)
+ cpu->a[thread] = cpu->x[thread];
+ if (opcode == TXY)
+ cpu->y[thread] = cpu->x[thread];
+ if (opcode == TYA || opcode == TXA) {
+ cpu->z[thread] = (cpu->a[thread] == 0);
+ cpu->n[thread] = (cpu->a[thread] >> 63);
+ }
+ if (opcode == TAY || opcode == TXY) {
+ cpu->z[thread] = (cpu->y[thread] == 0);
+ cpu->n[thread] = (cpu->y[thread] >> 63);
+ }
+ if (opcode == TAX || opcode == TYX) {
+ cpu->z[thread] = (cpu->x[thread] == 0);
+ cpu->n[thread] = (cpu->x[thread] >> 63);
+ }
+ (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread));
+ (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread));
+ break;
case PHX: /* PusH X register to stack. */
tmp = addr[cpu->pc[thread]++];
if (tmp > 7)
@@ -1413,7 +1445,6 @@ int main(int argc, char **argv) {
inst[i] = 0;
}
pthread_t therads[THREADS];
- pthread_barrier_init(&bar, NULL, THREADS);
int result;
puts("\033[2J\033[H");
for (int i = 0; i < THREADS; i++) {
@@ -1425,7 +1456,6 @@ int main(int argc, char **argv) {
pthread_cond_wait(&cond, &mutex);
}
pthread_mutex_unlock(&mutex);
- pthread_barrier_destroy(&bar);
#if bench
if (threads_done == THREADS) {
double tm_sec, tm_usec, tm[THREADS], ttm;