summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-04-19 13:31:49 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-04-19 13:31:49 -0400
commite093aba79dd1ed88cb490b7cd69c81f0b14bea11 (patch)
tree7c37fe806b5e6fa7f82edcf2379cf4a424fa0c19 /sux.c
parent0a7a2a7a8f95730811117bd2aa904f1843f65071 (diff)
Removed most of the commented code, and optimized the
emulator some more. I optimized the emulator by replacing the main loop from a conditional while loop, to an unconditional for loop.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sux.c b/sux.c
index 4dffc37..d81a88d 100644
--- a/sux.c
+++ b/sux.c
@@ -36,7 +36,6 @@ uint64_t inss;
uint8_t threads_done = 0;
uint8_t kbd_rdy = 0;
uint8_t step = 0;
-uint8_t irq = 0;
#if !bench
@@ -64,7 +63,6 @@ void *run(void *args) {
uint64_t address = 0;
uint8_t prefix = 0;
uint8_t opcode = 0;
- uint8_t end = 0;
uint64_t sum = 0;
uint64_t value = 0;
uint64_t reg = 0;
@@ -72,7 +70,7 @@ void *run(void *args) {
uint64_t iclk = 0;
#endif
uint64_t ins = 0;
- uint64_t sign = 0;
+ uint8_t sign = 0;
uint8_t tmp;
uint8_t tmp2;
#if !bench
@@ -99,7 +97,7 @@ void *run(void *args) {
pthread_mutex_unlock(&mutex);
#endif
#endif
- while (!end) {
+ for (;;) {
address = 0;
prefix = addr[cpu->pc[thread]];
if ((prefix & 0x03) != 0x03) {
@@ -130,13 +128,9 @@ void *run(void *args) {
wprintw(scr,
", sp: $%04X"
", ps: $%02"PRIX64
- /*", prefix: $%02X"
- ", opcode: $%02X"*/
", inst: "
, cpu->sp[thread]
, cpu->ps);
- /*, prefix
- , opcode);*/
#if keypoll
pthread_mutex_unlock(&mutex);
#endif
@@ -855,7 +849,7 @@ void *run(void *args) {
case ASR_AB: /* ASR Absolute. */
case ASR_Z: /* ASR Zero Matrix. */
sign = cpu->a[thread] >> 63;
- sum = (value < 64) ? (cpu->a[thread] >> value) | sign : 0;
+ sum = (value < 64) ? (cpu->a[thread] >> value) | ((uint64_t)sign << 63) : 0;
setflag(sum == 0, Z);
setflag(sum >> 63, N);
setflag(cpu->a[thread] & 1, C);
@@ -1258,7 +1252,6 @@ void *run(void *args) {
#endif
#elif bench
if (ins >= BENCH_INST) {
- end = 1;
pthread_mutex_lock(&main_mutex);
threads_done++;
inst[thread] = ins;
@@ -1268,6 +1261,7 @@ void *run(void *args) {
pthread_cond_signal(&main_cond);
pthread_mutex_unlock(&main_mutex);
gettimeofday(&en[thread], 0);
+ break;
}
#endif
}