From e093aba79dd1ed88cb490b7cd69c81f0b14bea11 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 19 Apr 2020 13:31:49 -0400 Subject: 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. --- sux.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'sux.c') 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 } -- cgit v1.2.3-13-gbd6f