summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-01-10 16:35:34 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-01-10 16:35:34 -0500
commit861d56e556b597115ad01b4b4cc0e5b932545ce9 (patch)
treed24d9718da054658a833b932595819c030065d1a /sux.c
parent1dfc78b8bf5b708cb1118a9d6646397772a1b894 (diff)
Added GPLv2.
We're now Free Software!!!
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c1230
1 files changed, 354 insertions, 876 deletions
diff --git a/sux.c b/sux.c
index 85280c1..1fc8fe2 100644
--- a/sux.c
+++ b/sux.c
@@ -1,15 +1,16 @@
#include "opcode.h"
#include <assert.h>
-#include <curses.h>
#include <ctype.h>
#include <string.h>
#include <pthread.h>
#define bench 0
-#define debug 1
-#define IO 0
+#define debug 0
+#define IO 1
#define keypoll 0
#if bench
#include <sys/time.h>
+#else
+#include <curses.h>
#endif
#define THREADS 1
@@ -27,7 +28,9 @@ uint8_t threads_done = 0;
uint8_t kbd_rdy = 0;
uint8_t wai = 0;
uint8_t irq = 0;
+#if !bench
WINDOW *scr;
+#endif
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t main_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
@@ -46,21 +49,26 @@ void *run(void *args) {
struct sux *cpu = &thr->sx;
uint8_t thread = thr->th;
uint64_t address = 0;
+ uint64_t tmpaddr = 0;
uint8_t prefix = 0;
uint8_t opcode = 0;
uint8_t end = 0;
+ uint8_t stksize;
uint64_t sum = 0;
uint64_t value = 0;
+ uint64_t reg = 0;
uint64_t iclk = 0;
uint64_t ins = 0;
uint64_t sign = 0;
char *s = malloc(2048);
+#if !bench
uint8_t lines = (6*thread)+2;
uint8_t bcd[4];
uint8_t idx = 3, iscol = 0;
- uint16_t tv = 0xFF50; /* Starting address of the Thread Vectors. */
int x = 0, y = 0;
uint8_t esc = 0;
+#endif
+ uint16_t tv = 0xFF50; /* Starting address of the Thread Vectors. */
#if bench
gettimeofday(&str[thread], 0);
#endif
@@ -90,35 +98,229 @@ void *run(void *args) {
kbd_rdy &= (uint8_t)~(1 << thread);
}
prefix = addr[cpu->pc[thread]];
- if ((prefix & 0x0F) == 0x07)
+ if ((prefix & 0x07) == 0x07)
cpu->pc[thread]++;
else
prefix = 0;
opcode = addr[cpu->pc[thread]];
+
#if debug && !bench
+ if (lines > 24*(thread+1)) {
+ lines = (24*thread)+2;
+ }
#if keypoll
pthread_mutex_lock(&mutex);
#endif
mvwprintw(scr, lines, 0, "pc: $%08llx, a: $%016llx, b: $%016llx, x: $%016llx, y: $%016llx"
- ", sp: $%04lx, ps: $%016llx, prefix: $%02x, opcode: $%02x, thread: %u, inst: %s \r"
+ ", sp: $%04lx, ps: $%016llx, prefix: $%02x, opcode: $%02x, thread: %u, inst: "
, cpu->pc[thread], cpu->a[thread], cpu->b[thread], cpu->x[thread], cpu->y[thread]
- , cpu->sp[thread], cpu->ps, prefix, opcode, thread, opname[opcode]);
- wrefresh(scr);
+ , cpu->sp[thread], cpu->ps, prefix, opcode, thread);
#if keypoll
pthread_mutex_unlock(&mutex);
#endif
- lines++;
- if (lines > 24*(thread+1))
- lines = (24*thread)+2;
#endif
+ uint8_t addrsize = (prefix & 8) == 8;
uint8_t rs = (prefix & 0x30) >> 4;
uint8_t regsize = (1 << rs);
uint8_t tmp;
address = cpu->pc[thread];
cpu->pc[thread]++;
iclk++;
+ switch (optype[opcode]) {
+ case IMPL:
+ break;
+ case IMM:
+ switch (opcode) {
+ case TXS:
+ case PHB:
+ case PHP:
+ case PHA:
+ case PHY:
+ case PHX:
+ case PLB:
+ case PLP:
+ case PLA:
+ case PLY:
+ case PLX:
+ break;
+ case STT:
+ case LSL:
+ case LSR:
+ case ROL:
+ case ROR:
+ case ASR:
+ case ENT:
+ address = cpu->pc[thread];
+ cpu->pc[thread]+=1;
+ break;
+ default:
+ address = cpu->pc[thread];
+ cpu->pc[thread]+=regsize;
+ break;
+ }
+ break;
+ case ZM:
+ case ZMX:
+ case ZMY:
+ address = addr[cpu->pc[thread]];
+ if (addrsize) {
+ address |= addr[cpu->pc[thread]+1] << 8;
+ address |= addr[cpu->pc[thread]+2] << 16;
+ address |= addr[cpu->pc[thread]+3] << 24;
+ cpu->pc[thread]+=4;
+ } else {
+ cpu->pc[thread]+=1;
+ }
+ tmpaddr = address;
+ if (optype[opcode] == ZMX)
+ address += cpu->x[thread];
+ if (optype[opcode] == ZMY)
+ address += cpu->y[thread];
+ break;
+ case IND:
+ case INDX:
+ case INDY:
+ address = addr[cpu->pc[thread]];
+ if (addrsize) {
+ address |= addr[cpu->pc[thread]+1] << 8;
+ address |= addr[cpu->pc[thread]+2] << 16;
+ address |= addr[cpu->pc[thread]+3] << 24;
+ cpu->pc[thread]+=4;
+ } else {
+ cpu->pc[thread]+=1;
+ }
+ tmpaddr = address;
+ if (optype[opcode] == INDX)
+ address += cpu->x[thread];
+ value = (uint64_t)addr[address]
+ | (uint64_t)addr[address+1] << 8
+ | (uint64_t)addr[address+2] << 16
+ | (uint64_t)addr[address+3] << 24
+ | (uint64_t)addr[address+4] << 32
+ | (uint64_t)addr[address+5] << 40
+ | (uint64_t)addr[address+6] << 48
+ | (uint64_t)addr[address+7] << 56;
+ if (optype[opcode] == INDY)
+ value += cpu->y[thread];
+ address = value;
+ value = 0;
+ iclk++;
+ break;
+ case ABS:
+ address = addr[cpu->pc[thread]];
+ address |= addr[cpu->pc[thread]+1] << 8;
+ if (addrsize) {
+ address |= (uint64_t)addr[cpu->pc[thread]+2] << 16;
+ address |= (uint64_t)addr[cpu->pc[thread]+3] << 24;
+ address |= (uint64_t)addr[cpu->pc[thread]+4] << 32;
+ address |= (uint64_t)addr[cpu->pc[thread]+5] << 40;
+ address |= (uint64_t)addr[cpu->pc[thread]+6] << 48;
+ address |= (uint64_t)addr[cpu->pc[thread]+7] << 56;
+ cpu->pc[thread]+=8;
+ iclk++;
+ } else {
+ cpu->pc[thread]+=2;
+ }
+
+ break;
+
+ }
+ value = addr[address];
+ if (regsize >= 2) {
+ value |= addr[address+1] << 8;
+ if (regsize >= 4) {
+ value |= addr[address+2] << 16;
+ value |= addr[address+3] << 24;
+ }
+ if (regsize >= 8) {
+ value |= (uint64_t)addr[address+4] << 32;
+ value |= (uint64_t)addr[address+5] << 40;
+ value |= (uint64_t)addr[address+6] << 48;
+ value |= (uint64_t)addr[address+7] << 56;
+ }
+ }
+ #if debug && !bench
+ int row, col;
+ #if keypoll
+ pthread_mutex_lock(&mutex);
+ #endif
+ getyx(scr,row, col);
+ char postfix[3];
+ char op[4];
+ op[0] = opname[opcode][0];
+ op[1] = opname[opcode][1];
+ op[2] = opname[opcode][2];
+ op[3] = '\0';
+ if (regsize == 1) {
+ postfix[0] = '\0';
+ postfix[1] = '\0';
+ postfix[2] = '\0';
+ } else {
+ postfix[0] = '.';
+ if (regsize == 2)
+ postfix[1] = 'W';
+ if (regsize == 4)
+ postfix[1] = 'D';
+ if (regsize == 8)
+ postfix[1] = 'Q';
+ postfix[2] = '\0';
+ }
+ switch (optype[opcode]) {
+ case IMPL:
+ mvwprintw(scr, lines, col, "%s \r" , opname[opcode]);
+ break;
+ case IMM:
+ if (regsize == 1) {
+ mvwprintw(scr, lines, col, "%s #$%02x \r" , op, value);
+ }
+ if (regsize == 2) {
+ mvwprintw(scr, lines, col, "%s%s #$%04x \r" , op, postfix, value);
+ }
+ if (regsize == 4) {
+ mvwprintw(scr, lines, col, "%s%s #$%08x \r" , op, postfix, value);
+ }
+ if (regsize == 8) {
+ mvwprintw(scr, lines, col, "%s%s #$%016llx\r" , op, postfix, value);
+ }
+ break;
+ case ZM:
+ case ZMX:
+ case ZMY:
+ if (optype[opcode] == ZMX)
+ tmpaddr = address - cpu->x[thread];
+ if (optype[opcode] == ZMY)
+ tmpaddr = address - cpu->y[thread];
+ if (addrsize)
+ mvwprintw(scr, lines, col, "%s%s $%08x%s \r" , op, postfix, tmpaddr, (optype[opcode] == ZM) ? "" : ((optype[opcode] == ZMX) ? ", x" : ", y"));
+ else
+ mvwprintw(scr, lines, col, "%s%s $%02x%s \r" , op, postfix, tmpaddr, (optype[opcode] == ZM) ? "" : ((optype[opcode] == ZMX) ? ", x" : ", y"));
+ break;
+ case IND:
+ case INDX:
+ case INDY:
+ if (addrsize)
+ mvwprintw(scr, lines, col, "%s%s ($%08x%s \r" , op, postfix, tmpaddr, (optype[opcode] == IND) ? ")" : ((optype[opcode] == INDX) ? ", x)" : "), y"));
+ else
+ mvwprintw(scr, lines, col, "%s%s ($%02x%s \r" , op, postfix, tmpaddr, (optype[opcode] == IND) ? ")" : ((optype[opcode] == INDX) ? ", x)" : "), y"));
+ break;
+ case ABS:
+ tmpaddr = address;
+ if (addrsize)
+ mvwprintw(scr, lines, col, "%s%s $%016llx\r" , op, postfix, value);
+ else
+ mvwprintw(scr, lines, col, "%s%s $%04x \r" , op, postfix, tmpaddr);
+ break;
+
+ }
+ mvwprintw(scr, 29, 0, "address: $%016llx\r", address);
+ wrefresh(scr);
+ #if keypoll
+ pthread_mutex_unlock(&mutex);
+ #endif
+ lines+=1;
+ #endif
switch(opcode) {
case CPS: /* Clear Processor Status. */
for (uint8_t i = 0; i < 8; i++) {
@@ -135,48 +337,8 @@ void *run(void *args) {
case AAB: /* Add Accumulator with carry by B register. */
case 0x03: /* ADC Absolute. */
case 0x05: /* ADC Zero Matrix. */
- if (opcode != AAB) {
- if (opcode == ADC) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x03) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x05) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- if (regsize >= 2) {
- value += (uint64_t)addr[address+1] << 8;
- }
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ if (opcode == AAB)
value = cpu->b[thread];
- }
sum = cpu->a[thread]+value+cpu->c[thread];
cpu->a[thread] = sum;
cpu->z[thread] = (sum == 0);
@@ -305,62 +467,13 @@ void *run(void *args) {
}
break;
case JMP: /* JMP Absolute. */
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
cpu->pc[thread] = address;
break;
case SBC: /* SBC Immediate. */
case SAB: /* Subtract Accumulator with carry by B register. */
case 0x13: /* SBC Absolute. */
case 0x15: /* SBC Zero Matrix. */
- if (opcode != SAB) {
- if (opcode == SBC) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x13) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x15) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- if (regsize >= 2) {
- value += (uint64_t)addr[address+1] << 8;
- }
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ if (opcode == SAB) {
value = cpu->b[thread];
}
sum = cpu->a[thread]-value-!cpu->c[thread];
@@ -438,25 +551,10 @@ void *run(void *args) {
case 0x44: /* JSR Indexed Indirect. */
case 0x54: /* JSR Indirect Indexed. */
case JSR: /* Jump to SubRoutine. */
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24;
- if (opcode == 0x34 || opcode == 0x44 || opcode == 0x54) {
- address = (uint64_t)addr[address]
- | (uint64_t)addr[address+1] << 8
- | (uint64_t)addr[address+2] << 16
- | (uint64_t)addr[address+3] << 24
- | (uint64_t)addr[address+4] << 32
- | (uint64_t)addr[address+5] << 40
- | (uint64_t)addr[address+6] << 48
- | (uint64_t)addr[address+7] << 56;
- if (opcode == 0x44)
- address += cpu->x[thread];
- if (opcode == 0x54)
- address += cpu->y[thread];
- }
- cpu->pc[thread]+=4;
+ if (addrsize)
+ stksize = 24;
+ else
+ stksize = 0;
for (int8_t i = 24; i >= 0; i-=8) {
if (i)
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread] >> i;
@@ -470,44 +568,8 @@ void *run(void *args) {
case ABA: /* bitwise And with Accumulator, and B register. */
case 0x23: /* AND Absolute. */
case 0x25: /* AND Zero Matrix. */
- if (opcode != ABA) {
- if (opcode == AND) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x23) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x25) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = (uint64_t)addr[address];
- if (regsize >= 2)
- value += (uint64_t)addr[address+1] << 8;
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
+ if (opcode == ABA) {
+ value = cpu->b[thread];
}
cpu->a[thread] &= value;
cpu->z[thread] = (value == 0);
@@ -516,9 +578,6 @@ void *run(void *args) {
(cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread));
break;
case STT: /* STart Thread. */
- address = cpu->pc[thread];
- cpu->pc[thread]++;
- value = addr[address];
cpu->crt |= value;
for (uint8_t i = 0; i < 7; i++) {
if ((value >> i) & 1) {
@@ -536,25 +595,6 @@ void *run(void *args) {
break;
case BPO: /* BPO Absolute. */
case 0x64: /* BPO Zero Matrix. */
- if (opcode == BPO) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (cpu->n[thread])
cpu->pc[thread] = address;
break;
@@ -562,45 +602,7 @@ void *run(void *args) {
case OAB: /* bitwise Or with Accumulator, and B register. */
case 0x33: /* ORA Absolute. */
case 0x35: /* ORA Zero Matrix. */
- if (opcode != OAB) {
- if (opcode == ORA) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x39) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x3B) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = (uint64_t)addr[address];
- if (regsize >= 2)
- value += (uint64_t)addr[address+1] << 8;
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ if (opcode == OAB) {
value = cpu->b[thread];
}
cpu->a[thread] |= value;
@@ -615,25 +617,6 @@ void *run(void *args) {
break;
case BNG: /* BNG Absolute. */
case 0x74: /* BNG Zero Matrix. */
- if (opcode == BNG) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (!cpu->n[thread])
cpu->pc[thread] = address;
break;
@@ -641,45 +624,7 @@ void *run(void *args) {
case XAB: /* bitwise Xor with Accumulator, and B register. */
case 0x43: /* XOR Absolute. */
case 0x45: /* XOR Zero Matrix. */
- if (opcode != XAB) {
- if (opcode == XOR) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x49) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x4B) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = (uint64_t)addr[address];
- if (regsize >= 2)
- value += (uint64_t)addr[address+1] << 8;
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ if (opcode == XAB) {
value = cpu->b[thread];
}
cpu->a[thread] ^= value;
@@ -694,25 +639,6 @@ void *run(void *args) {
break;
case BCS: /* BCS Absolute. */
case 0x84: /* BCS Zero Matrix. */
- if (opcode == BCS) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (cpu->c[thread])
cpu->pc[thread] = address;
break;
@@ -720,34 +646,7 @@ void *run(void *args) {
case LLB: /* Logical shift Left accumulator by B. */
case 0x53: /* LSL Absolute. */
case 0x55: /* LSL Zero Matrix. */
- if (opcode != LLB) {
- if (opcode == LSL) {
- address = cpu->pc[thread];
- cpu->pc[thread]++;
- }
- if (opcode == 0x53) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
-
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x55) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- } else {
+ if (opcode == LLB) {
value = cpu->b[thread];
}
sum = (value < 64) ? cpu->a[thread] << value : 0;
@@ -767,69 +666,33 @@ void *run(void *args) {
case STY: /* STY Absolute. */
case STX: /* STX Absolute. */
case STB: /* STB Absolute. */
- case 0x7B: /* STA Zero Matrix. */
- case 0x7D: /* STY Zero Matrix. */
- case 0x7E: /* STX Zero Matrix. */
- case 0x7F: /* STB Zero Matrix. */
- case 0x8B: /* STA Zero Matrix, Indexed with X. */
- case 0x8D: /* STY Zero Matrix, Indexed with X. */
- case 0x8F: /* STA Zero Matrix, Indexed with X. */
- case 0x9B: /* STA Zero Matrix, Indexed with Y. */
- case 0x9E: /* STX Zero Matrix, Indexed with Y. */
- case 0x9F: /* STA Zero Matrix, Indexed with Y. */
- case 0xAB: /* STA Indirect. */
- case 0xAD: /* STY Indirect. */
- case 0xAE: /* STX Indirect. */
- case 0xAF: /* STB Indirect. */
- case 0xBB: /* STA Indexed Indirect. */
- case 0xBD: /* STY Indexed Indirect. */
- case 0xBF: /* STB Indexed Indirect. */
- case 0xCB: /* STA Indirect Indexed. */
- case 0xCE: /* STX Indirect Indexed. */
- case 0xCF: /* STB Indirect Indexed. */
- if (opcode == STA || opcode == STY || opcode == STX || opcode == STB) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- if (opcode == 0xAB || opcode == 0xAD || opcode == 0xAE || opcode == 0xAF || opcode == 0xBB ||
- opcode == 0xBD || opcode == 0xBF || opcode == 0xCB || opcode == 0xCE || opcode == 0xCF) {
- address = (uint64_t)addr[address]
- | (uint64_t)addr[address+1] << 8
- | (uint64_t)addr[address+2] << 16
- | (uint64_t)addr[address+3] << 24
- | (uint64_t)addr[address+4] << 32
- | (uint64_t)addr[address+5] << 40
- | (uint64_t)addr[address+6] << 48
- | (uint64_t)addr[address+7] << 56;
- }
- if (opcode == 0x8B || opcode == 0x8D || opcode == 0x8F ||
- opcode == 0xBB || opcode == 0xBD || opcode == 0xBF)
- address += cpu->x[thread];
- if (opcode == 0x9B || opcode == 0x9E || opcode == 0x9F ||
- opcode == 0xCB || opcode == 0xCE || opcode == 0xCF)
- address += cpu->y[thread];
- cpu->pc[thread]+=4;
- iclk++;
- }
- if (opcode == STA || opcode == 0x7B || opcode == 0x8B || opcode == 0x9B)
+ case 0x49: /* STA Zero Matrix. */
+ case 0x4A: /* STY Zero Matrix. */
+ case 0x4B: /* STX Zero Matrix. */
+ case 0x4E: /* STB Zero Matrix. */
+ case 0x69: /* STA Zero Matrix, Indexed with X. */
+ case 0x6A: /* STY Zero Matrix, Indexed with X. */
+ case 0x6B: /* STX Zero Matrix, Indexed with Y. */
+ case 0x6E: /* STB Zero Matrix, Indexed with X. */
+ case 0x89: /* STA Zero Matrix, Indexed with Y. */
+ case 0x8A: /* STY Indirect. */
+ case 0x8B: /* STX Indirect. */
+ case 0x8E: /* STB Zero Matrix, Indexed with Y. */
+ case 0xA9: /* STA Indirect. */
+ case 0xAA: /* STY Indexed Indirect. */
+ case 0xAB: /* STX Indirect Indexed. */
+ case 0xAE: /* STB Indirect. */
+ case 0xC9: /* STA Indexed Indirect. */
+ case 0xCE: /* STB Indexed Indirect. */
+ case 0xE9: /* STA Indirect Indexed. */
+ case 0xEE: /* STB Indirect Indexed. */
+ if (opcode == STA || opcode == 0x49 || opcode == 0x69 || opcode == 0x89 || opcode == 0xA9 || opcode == 0xC9 || opcode == 0xE9)
value = cpu->a[thread];
- if (opcode == STY || opcode == 0x7D || opcode == 0x8D)
+ if (opcode == STY || opcode == 0x4A || opcode == 0x6A || opcode == 0x8A || opcode == 0xAA)
value = cpu->y[thread];
- if (opcode == STX || opcode == 0x7E || opcode == 0x9E)
+ if (opcode == STY || opcode == 0x4B || opcode == 0x6B || opcode == 0x8B || opcode == 0xAB)
value = cpu->x[thread];
- if (opcode == STB || opcode == 0x7F || opcode == 0x8F || opcode == 0x9F)
+ if (opcode == STB || opcode == 0x4E || opcode == 0x6E || opcode == 0x8E || opcode == 0xAE || opcode == 0xCE || opcode == 0xEE)
value = cpu->b[thread];
addr[address] = value & 0xFF;
#if IO
@@ -923,6 +786,7 @@ void *run(void *args) {
#endif
}
#else
+ #if !bench
if (address == TX_ADDR) {
if (esc) {
switch(addr[address]) {
@@ -955,7 +819,8 @@ void *run(void *args) {
x = 0;
else
x = ((bcd[1]*10) + bcd[0]);
- mvwprintw(scr, getmaxy(scr)-25, 0, "x: %i, y: %i ", x, y);
+ mvwprintw(scr, 30, 0, "x: %i, y: %i ", x, y);
+ wrefresh(scr);
idx = 3;
bcd[0] = 0;
bcd[1] = 0;
@@ -997,6 +862,7 @@ void *run(void *args) {
}
}
#endif
+ #endif
if (regsize >= 2)
addr[address+1] = value >> 8;
if (regsize >= 4) {
@@ -1012,25 +878,6 @@ void *run(void *args) {
break;
case BCC: /* BCC Absolute. */
case 0x94: /* BCC Zero Matrix. */
- if (opcode == BCC) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (!cpu->c[thread])
cpu->pc[thread] = address;
break;
@@ -1038,46 +885,26 @@ void *run(void *args) {
case LRB: /* Logical shift Right accumulator by B. */
case 0x63: /* LSR Absolute. */
case 0x65: /* LSR Zero Matrix. */
+ if (opcode == LRB) {
+ value = cpu->b[thread];
+ }
+ sum = (value < 64) ? cpu->a[thread] >> value : 0;
+ cpu->z[thread] = (sum == 0);
+ cpu->n[thread] = (sum >> 63);
+ cpu->c[thread] = cpu->a[thread] & 1;
+ cpu->a[thread] = sum;
+ (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));
+ (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread));
+ break;
case ASR: /* ASR Immediate. */
case ARB: /* Arithmetic shift Right accumulator by B. */
case 0xE3: /* ASR Absolute. */
case 0xE5: /* ASR Zero Matrix. */
- if (opcode != LRB || opcode != ARB) {
- if (opcode == LSR || opcode == ASR) {
- address = cpu->pc[thread];
- cpu->pc[thread]++;
- }
- if (opcode == 0x63 || opcode == 0xE3) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x65 || opcode == 0xE5) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- } else {
+ if (opcode == ARB)
value = cpu->b[thread];
- }
- if (opcode == ASR || opcode == ARB || opcode == 0xE3 || opcode == 0xE5) {
- sign = cpu->a[thread] & 0x8000000000000000;
- sum = (value < 64) ? (cpu->a[thread] >> value) | sign : 0;
- }
- if (opcode == LSR || opcode == LRB || opcode == 0x63 || opcode == 0x65) {
- sum = (value < 64) ? cpu->a[thread] >> value : 0;
- }
+ sign = cpu->a[thread] & 0x8000000000000000;
+ sum = (value < 64) ? (cpu->a[thread] >> value) | sign : 0;
cpu->z[thread] = (sum == 0);
cpu->n[thread] = (sum >> 63);
cpu->c[thread] = cpu->a[thread] & 1;
@@ -1090,73 +917,34 @@ void *run(void *args) {
cpu->c[thread] = 0;
(cpu->ps &= ~(C << 8*thread));
break;
- case 0x56: /* LDB Absolute. */
- case 0x59: /* LDA Absolute. */
- case 0x5A: /* LDY Absolute. */
- case 0x5C: /* LDX Absolute. */
case LDB: /* LDB Immediate. */
case LDA: /* LDA Immediate. */
case LDY: /* LDY Immediate. */
case LDX: /* LDX Immediate. */
- case 0x76: /* LDB Zero Matrix. */
- case 0x79: /* LDA Zero Matrix. */
- case 0x7A: /* LDY Zero Matrix. */
- case 0x7C: /* LDX Zero Matrix. */
- case 0x86: /* LDB Zero Matrix, Indexed with X. */
- case 0x89: /* LDA Zero Matrix, Indexed with X. */
- case 0x8A: /* LDY Zero Matrix, Indexed with X. */
- case 0x96: /* LDB Zero Matrix, Indexed with Y. */
- case 0x99: /* LDA Zero Matrix, Indexed with Y. */
- case 0x9C: /* LDX Zero Matrix, Indexed with Y. */
- case 0xA6: /* LDB Indirect. */
- case 0xA9: /* LDA Indirect. */
- case 0xAA: /* LDY Indirect. */
- case 0xAC: /* LDX Indirect. */
- case 0xB6: /* LDB Indexed Indirect. */
+ case 0x1E: /* LDB Absolute. */
+ case 0x19: /* LDA Absolute. */
+ case 0x1A: /* LDY Absolute. */
+ case 0x1B: /* LDX Absolute. */
+ case 0x3E: /* LDB Zero Matrix. */
+ case 0x39: /* LDA Zero Matrix. */
+ case 0x3A: /* LDY Zero Matrix. */
+ case 0x3B: /* LDX Zero Matrix. */
+ case 0x5E: /* LDB Zero Matrix, Indexed with X. */
+ case 0x59: /* LDA Zero Matrix, Indexed with X. */
+ case 0x5A: /* LDY Zero Matrix, Indexed with X. */
+ case 0x5B: /* LDX Zero Matrix, Indexed with Y. */
+ case 0x7E: /* LDB Zero Matrix, Indexed with Y. */
+ case 0x79: /* LDA Zero Matrix, Indexed with Y. */
+ case 0x7A: /* LDY Indirect. */
+ case 0x7B: /* LDX Indirect. */
+ case 0x9E: /* LDB Indirect. */
+ case 0x99: /* LDA Indirect. */
+ case 0x9A: /* LDY Indexed Indirect. */
+ case 0x9B: /* LDX Indirect Indexed. */
+ case 0xBE: /* LDB Indexed Indirect. */
case 0xB9: /* LDA Indexed Indirect. */
- case 0xBA: /* LDY Indexed Indirect. */
- case 0xC6: /* LDB Indirect Indexed. */
- case 0xC9: /* LDA Indirect Indexed. */
- case 0xCC: /* LDX Indirect Indexed. */
- if (opcode == LDB || opcode == LDA || opcode == LDY || opcode == LDX) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- } else if (opcode == 0x56 || opcode == 0x59 || opcode == 0x5A || opcode == 0x5C) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- if (opcode == 0xA6 || opcode == 0xA9 || opcode == 0xAA || opcode == 0xAC || opcode == 0xB6 ||
- opcode == 0xB9 || opcode == 0xBA || opcode == 0xC6 || opcode == 0xC9 || opcode == 0xCC) {
- address = (uint64_t)addr[address]
- | (uint64_t)addr[address+1] << 8
- | (uint64_t)addr[address+2] << 16
- | (uint64_t)addr[address+3] << 24
- | (uint64_t)addr[address+4] << 32
- | (uint64_t)addr[address+5] << 40
- | (uint64_t)addr[address+6] << 48
- | (uint64_t)addr[address+7] << 56;
- }
- if (opcode == 0x86 || opcode == 0x89 || opcode == 0x8A ||
- opcode == 0xB6 || opcode == 0xB9 || opcode == 0xBA)
- address += cpu->x[thread];
- if (opcode == 0x96 || opcode == 0x99 || opcode == 0x9C ||
- opcode == 0xC6 || opcode == 0xC9 || opcode == 0xCC)
- address += cpu->y[thread];
- cpu->pc[thread]+=4;
- iclk++;
- }
+ case 0xDE: /* LDB Indirect Indexed. */
+ case 0xD9: /* LDA Indirect Indexed. */
if (address == CTRL_ADDR) {
pthread_mutex_lock(&main_mutex);
pthread_cond_signal(&main_cond);
@@ -1180,13 +968,13 @@ void *run(void *args) {
value += (uint64_t)addr[address+6] << 48;
value += (uint64_t)addr[address+7] << 56;
}
- if (opcode == LDB || opcode == 0x56 || opcode == 0x76 || opcode == 0x86 || opcode == 0x96)
+ if (opcode == LDB || opcode == 0x1E || opcode == 0x3E || opcode == 0x5E || opcode == 0x7E || opcode == 0x9E || opcode == 0xBE || opcode == 0xDE)
cpu->b[thread] = value;
- if (opcode == LDA || opcode == 0x59 || opcode == 0x79 || opcode == 0x89 || opcode == 0x99)
+ if (opcode == LDA || opcode == 0x19 || opcode == 0x39 || opcode == 0x59 || opcode == 0x79 || opcode == 0x99 || opcode == 0xB9 || opcode == 0xD9)
cpu->a[thread] = value;
- if (opcode == LDY || opcode == 0x5A || opcode == 0x7A || opcode == 0x8A)
+ if (opcode == LDY || opcode == 0x1A || opcode == 0x3A || opcode == 0x5A || opcode == 0x7A || opcode == 0x9A)
cpu->y[thread] = value;
- if (opcode == LDX || opcode == 0x5C || opcode == 0x7C || opcode == 0x9C)
+ if (opcode == LDX || opcode == 0x1B || opcode == 0x3B || opcode == 0x5B || opcode == 0x7B || opcode == 0x9B)
cpu->x[thread] = value;
cpu->z[thread] = (value == 0);
cpu->n[thread] = (value >> 63);
@@ -1195,25 +983,6 @@ void *run(void *args) {
break;
case BEQ: /* BEQ Absolute. */
case 0xA4: /* BEQ Zero Matrix. */
- if (opcode == BEQ) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (cpu->z[thread])
cpu->pc[thread] = address;
break;
@@ -1221,33 +990,7 @@ void *run(void *args) {
case RLB: /* Rotate Left accumulator by B. */
case 0x73: /* ROL Absolute. */
case 0x75: /* ROL Zero Matrix. */
- if (opcode != RLB) {
- if (opcode == ROL) {
- address = cpu->pc[thread];
- cpu->pc[thread]++;
- }
- if (opcode == 0x73) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x75) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- } else {
+ if (opcode == RLB) {
value = cpu->b[thread];
}
sum = cpu->a[thread] << value;
@@ -1266,25 +1009,6 @@ void *run(void *args) {
break;
case BNE: /* BNE Absolute. */
case 0xB4: /* BNE Zero Matrix. */
- if (opcode == BNE) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (!cpu->z[thread])
cpu->pc[thread] = address;
break;
@@ -1292,33 +1016,7 @@ void *run(void *args) {
case RRB: /* Rotate Right accumulator by B. */
case 0x83: /* ROR Absolute. */
case 0x85: /* ROR Zero Matrix. */
- if (opcode != RRB) {
- if (opcode == ROR) {
- address = cpu->pc[thread];
- cpu->pc[thread]++;
- }
- if (opcode == 0x83) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x85) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- } else {
+ if (opcode == RRB) {
value = cpu->b[thread];
}
sum = cpu->a[thread] >> value;
@@ -1337,25 +1035,6 @@ void *run(void *args) {
break;
case BVS: /* BVS Absolute. */
case 0xC4: /* BVS Zero Matrix. */
- if (opcode == BVS) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (cpu->v[thread])
cpu->pc[thread] = address;
break;
@@ -1363,46 +1042,7 @@ void *run(void *args) {
case MAB: /* Multiply Accumulator by B. */
case 0x93: /* MUL Absolute. */
case 0x95: /* MUL Zero Matrix. */
- if (opcode != MAB) {
- if (opcode == MUL) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0x93) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0x95) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- if (regsize >= 2) {
- value += (uint64_t)addr[address+1] << 8;
- }
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ if (opcode == MAB) {
value = cpu->b[thread];
}
sum = cpu->a[thread]*value+cpu->c[thread];
@@ -1422,25 +1062,6 @@ void *run(void *args) {
break;
case BVC: /* BVC Absolute. */
case 0xD4: /* BVC Zero Matrix. */
- if (opcode == BVC) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
if (!cpu->v[thread])
cpu->pc[thread] = address;
break;
@@ -1449,44 +1070,6 @@ void *run(void *args) {
case 0xA3: /* DIV Absolute. */
case 0xA5: /* DIV Zero Matrix. */
if (opcode != DAB) {
- if (opcode == DIV) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- }
- if (opcode == 0xA3) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0xA5) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = addr[address];
- if (regsize >= 2) {
- value += (uint64_t)addr[address+1] << 8;
- }
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
cpu->b[thread] = cpu->a[thread] % value;
} else {
value = cpu->b[thread];
@@ -1504,7 +1087,11 @@ void *run(void *args) {
(cpu->ps &= ~(V << 8*thread));
break;
case RTS: /* ReTurn from Subroutine. */
- for (uint8_t i = 0; i < 32; i+=8) {
+ if (addrsize)
+ stksize = 32;
+ else
+ stksize = 8;
+ for (uint8_t i = 0; i < stksize; i+=8) {
cpu->sp[thread]++;
if (i)
cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i;
@@ -1517,93 +1104,46 @@ void *run(void *args) {
case CAB: /* Compare Accumulator, and B. */
case CPY: /* CPY Immediate. */
case CPX: /* CPX Immediate. */
- case 0x2B: /* CPY Absolute. */
- case 0x2D: /* CPX Absolute. */
+ case 0xCA: /* CPY Absolute. */
+ case 0xCB: /* CPX Absolute. */
case 0xB3: /* CMP Absolute. */
- case 0xE6: /* CPB Absolute. */
- case 0x3B: /* CPY Zero Matrix. */
- case 0x3D: /* CPX Zero Matrix. */
+ case 0x36: /* CPB Absolute. */
+ case 0xDA: /* CPY Zero Matrix. */
+ case 0xDB: /* CPX Zero Matrix. */
case 0xB5: /* CMP Zero Matrix. */
- case 0xF6: /* CPB Zero Matrix. */
- case 0xE9: /* CMP Indirect. */
+ case 0x46: /* CPB Zero Matrix. */
+ case 0xF1: /* CMP Indirect. */
case 0xEA: /* CPY Indirect. */
- case 0xEC: /* CPX Indirect. */
- case 0xDF: /* CPB Indirect. */
- case 0xEB: /* CMP Indexed Indirect. */
+ case 0xEB: /* CPX Indirect. */
+ case 0x56: /* CPB Indirect. */
+ case 0xF3: /* CMP Indexed Indirect. */
case 0xFA: /* CPY Indexed Indirect. */
- case 0xEF: /* CPB Indexed Indirect. */
- case 0xED: /* CMP Indirect Indexed. */
- case 0xFC: /* CPX Indirect Indexed. */
- case 0xFF: /* CPB Indirect Indexed. */
- if (opcode != CAB) {
- if (opcode == CMP || opcode == CPY || opcode == CPX || opcode == CPB) {
- address = cpu->pc[thread];
- cpu->pc[thread]+=regsize;
- } else if (opcode == 0xB3 || opcode == 0x2B || opcode == 0x2D) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- } else {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- if (opcode == 0xDF || opcode == 0xE9 || opcode == 0xEA || opcode == 0xEB || opcode == 0xEC ||
- opcode == 0xED || opcode == 0xEF || opcode == 0xFA || opcode == 0xFC || opcode == 0xFF) {
- address = (uint64_t)addr[address]
- | (uint64_t)addr[address+1] << 8
- | (uint64_t)addr[address+2] << 16
- | (uint64_t)addr[address+3] << 24
- | (uint64_t)addr[address+4] << 32
- | (uint64_t)addr[address+5] << 40
- | (uint64_t)addr[address+6] << 48
- | (uint64_t)addr[address+7] << 56;
- if (opcode == 0xEB || opcode == 0xEF || opcode == 0xFA)
- address += cpu->x[thread];
- if (opcode == 0xED || opcode == 0xFC || opcode == 0xFF)
- address += cpu->y[thread];
- }
- cpu->pc[thread]+=4;
- iclk++;
- }
- value = (uint64_t)addr[address];
- if (regsize >= 2)
- value += (uint64_t)addr[address+1] << 8;
- if (regsize >= 4) {
- value += (uint64_t)addr[address+2] << 16;
- value += (uint64_t)addr[address+3] << 24;
- }
- if (regsize >= 8) {
- value += (uint64_t)addr[address+4] << 32;
- value += (uint64_t)addr[address+5] << 40;
- value += (uint64_t)addr[address+6] << 48;
- value += (uint64_t)addr[address+7] << 56;
- }
- } else {
+ case 0x66: /* CPB Indexed Indirect. */
+ case 0xF5: /* CMP Indirect Indexed. */
+ case 0xFB: /* CPX Indirect Indexed. */
+ case 0x76: /* CPB Indirect Indexed. */
+ if (opcode == CAB) {
value = cpu->b[thread];
}
- if (opcode == CMP || opcode == CAB || opcode == 0xE5 || opcode == 0xF5)
- sum = cpu->a[thread]-value;
- if (opcode == CPY || opcode == 0xE2 || opcode == 0xF2)
- sum = cpu->y[thread]-value;
- if (opcode == CPX || opcode == 0xE4 || opcode == 0xF4)
- sum = cpu->x[thread]-value;
+ if (opcode == CPB || opcode == 0x36 || opcode == 0x46 || opcode == 0x56 || opcode == 0x66 || opcode == 0x76)
+ reg = cpu->b[thread];
+ if (opcode == CMP || opcode == CAB || opcode == 0xB3 || opcode == 0xB5 || opcode == 0xF1 || opcode == 0xF3 || opcode == 0xF5)
+ reg = cpu->a[thread];
+ if (opcode == CPY || opcode == 0xCA || opcode == 0xDA || opcode == 0xEA || opcode == 0xFA)
+ reg = cpu->y[thread];
+ if (opcode == CPX || opcode == 0xCB || opcode == 0xDB || opcode == 0xEB || opcode == 0xFB)
+ reg = cpu->x[thread];
+ sum = reg-value;
cpu->n[thread] = (sum & 0x8000000000000000) ? 1 : 0;
+ cpu->v[thread] = ((reg^value) & 0x8000000000000000) && ((reg^sum) & 0x8000000000000000);
cpu->z[thread] = (sum == 0) ? 1 : 0;
cpu->c[thread] = (sum > value) ? 1 : 0;
- (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));
+ (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread));
+ (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread));
(cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread));
break;
case ENT: /* ENd Thread. */
- value = addr[address];
cpu->crt &= ~value;
for (uint8_t i = 0; i < 7; i++)
if ((value >> i) & 1)
@@ -1648,27 +1188,6 @@ void *run(void *args) {
case 0x14: /* JMP Indexed Indirect. */
case 0x24: /* JMP Indirect Indexed. */
case 0xD0: /* JMP Zero Matrix. */
- address = (uint32_t)addr[cpu->pc[thread]]
- |(uint32_t)addr[cpu->pc[thread]+1] << 8
- |(uint32_t)addr[cpu->pc[thread]+2] << 16
- |(uint32_t)addr[cpu->pc[thread]+3] << 24;
-
- if (opcode == 0x04 || opcode == 0x14 || opcode == 0x24) {
- address = (uint64_t)addr[address]
- | (uint64_t)addr[address+1] << 8
- | (uint64_t)addr[address+2] << 16
- | (uint64_t)addr[address+3] << 24
- | (uint64_t)addr[address+4] << 32
- | (uint64_t)addr[address+5] << 40
- | (uint64_t)addr[address+6] << 48
- | (uint64_t)addr[address+7] << 56;
- if (opcode == 0x14)
- address += cpu->x[thread];
- if (opcode == 0x24)
- address += cpu->y[thread];
- }
- cpu->pc[thread]+=4;
- iclk++;
cpu->pc[thread] = address;
break;
@@ -1697,16 +1216,11 @@ void *run(void *args) {
(cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread));
break;
case JSL: /* Jump to Subroutine Long. */
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- for (int8_t i = 56; i >= 0; i-=8) {
+ if (addrsize)
+ stksize = 56;
+ else
+ stksize = 8;
+ for (int8_t i = stksize; i >= 0; i-=8) {
if (i)
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread] >> i;
else
@@ -1717,63 +1231,25 @@ void *run(void *args) {
break;
case 0xC3: /* INC Absolute. */
case 0xC5: /* INC Zero Matrix. */
- if (opcode == 0xC3) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0xC5) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
addr[address]++;
break;
case NOP: /* No OPeration. */
break;
case RTL: /* ReTurn from subroutine Long. */
- for (uint8_t i = 0; i < 64; i+=8) {
+ if (addrsize)
+ stksize = 64;
+ else
+ stksize = 16;
+ for (uint8_t i = 0; i < stksize; i+=8) {
cpu->sp[thread]++;
- if (i < 56)
- cpu->pc[thread] = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i;
- else if (i == 56)
- cpu->pc[thread] = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i + 1;
+ if (i)
+ cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i;
else
cpu->pc[thread] = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]];
}
break;
case 0xD3: /* DEC Absolute. */
case 0xD5: /* DEC Zero Matrix. */
- if (opcode == 0xD3) {
- address = (uint64_t)addr[cpu->pc[thread]]
- | (uint64_t)addr[cpu->pc[thread]+1] << 8
- | (uint64_t)addr[cpu->pc[thread]+2] << 16
- | (uint64_t)addr[cpu->pc[thread]+3] << 24
- | (uint64_t)addr[cpu->pc[thread]+4] << 32
- | (uint64_t)addr[cpu->pc[thread]+5] << 40
- | (uint64_t)addr[cpu->pc[thread]+6] << 48
- | (uint64_t)addr[cpu->pc[thread]+7] << 56;
- cpu->pc[thread]+=8;
- iclk++;
- }
- if (opcode == 0xD5) {
- address = addr[cpu->pc[thread]]
- | addr[cpu->pc[thread]+1] << 8
- | addr[cpu->pc[thread]+2] << 16
- | addr[cpu->pc[thread]+3] << 24;
- cpu->pc[thread]+=4;
- iclk++;
- }
addr[address]--;
break;
case BRK: /* BReaK. */
@@ -1810,18 +1286,17 @@ void *run(void *args) {
break;
}
ins++;
- usleep(100000);
#if debug && !bench
#if keypoll
pthread_mutex_lock(&mutex);
#endif
- mvwprintw(scr, getmaxy(scr)-lines, 0, "Operand: $%llx"
+ /*mvwprintw(scr, getmaxy(scr)-lines, 0, "Operand: $%llx"
", $%04llx: $%02x, $%04llx: $%02x"
", $1000: $%02x, $1001: $%02x "
, value
, RX_ADDR, addr[RX_ADDR], TX_ADDR, addr[TX_ADDR]
- , addr[0x1000], addr[0x1001]);
- mvwprintw(scr, (24*thread)+1, 0, "Instructions executed: %llu, Clock cycles: %llu\r", ins, iclk);
+ , addr[0x1000], addr[0x1001]);*/
+ mvwprintw(scr, (6*thread)+1, 0, "Instructions executed: %llu, Clock cycles: %llu\r", ins, iclk);
wrefresh(scr);
#if keypoll
pthread_mutex_unlock(&mutex);
@@ -1830,12 +1305,12 @@ void *run(void *args) {
#if bench
if (ins >= BENCH_INST) {
end = 1;
- pthread_mutex_lock(&mutex);
+ pthread_mutex_lock(&main_mutex);
threads_done++;
inst[thread] = ins;
clk[thread] = iclk;
pthread_cond_signal(&main_cond);
- pthread_mutex_unlock(&mutex);
+ pthread_mutex_unlock(&main_mutex);
gettimeofday(&en[thread], 0);
}
#endif
@@ -1861,6 +1336,7 @@ int main(int argc, char **argv) {
sprintf(tmp, "\033[2J\033[H");
fwrite(tmp, sizeof(char), strlen(tmp), stdout);
fflush(stdout);
+#if !bench
if(!scr)
scr = initscr();
nodelay(stdscr, 0);
@@ -1876,11 +1352,13 @@ int main(int argc, char **argv) {
init_pair(1, COLOR_WHITE, -1);
attron(COLOR_PAIR(1) | A_BOLD);
wmove(scr, 0, 0);
+#endif
for (int i = 0; i < THREADS; i++) {
thr[i].sx.sp[i] = 0xFFFF;
thr[i].sx.stk_st[i] = i+1;
if (i) {
thr[i].sx.a[i] = 0;
+ thr[i].sx.b[i] = 0;
thr[i].sx.x[i] = 0;
thr[i].sx.y[i] = 0;
thr[i].sx.pc[i] = (uint64_t)addr[0xFF50+(8*(i-1))]
@@ -1893,6 +1371,7 @@ int main(int argc, char **argv) {
| (uint64_t)addr[0xFF57+(8*(i-1))] << 56;
} else {
thr[i].sx.a[i] = 0;
+ thr[i].sx.b[i] = 0;
thr[i].sx.x[i] = 0;
thr[i].sx.y[i] = 0;
thr[i].sx.pc[i] = (uint64_t)addr[0xFFC0]
@@ -1916,10 +1395,12 @@ int main(int argc, char **argv) {
assert(!result);
}
int c = 0;
+#if !bench
werase(scr);
+#endif
while (threads_done < THREADS) {
- int x, y, i = 0;
#if !bench
+ int x, y, i = 0;
if ((c != EOF && c !=-1)) {
pthread_mutex_lock(&main_mutex);
curs_set(0);
@@ -1945,6 +1426,7 @@ int main(int argc, char **argv) {
default:
addr[RX_ADDR] = (uint8_t)c;
addr[CTRL_ADDR] = 1;
+ kbd_rdy = 1;
#if !keypoll
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
@@ -1963,10 +1445,6 @@ int main(int argc, char **argv) {
}
#if bench
if (threads_done == THREADS) {
- #if en_nc
- scr = NULL;
- endwin();
- #endif
double tm_sec, tm_usec, tm[THREADS], ttm;
double clkspd;
double mhz;