From cd08c7e030dd269ffd0d3bdb6170e15998c796ec Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 19 Dec 2019 22:53:43 -0500 Subject: Fixed some bugs in both the assembly language monitor, and the cursor movement routines for SuBAsm. --- sux.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 120 insertions(+), 8 deletions(-) (limited to 'sux.c') diff --git a/sux.c b/sux.c index 96068a8..0b8da2e 100644 --- a/sux.c +++ b/sux.c @@ -1,11 +1,12 @@ #include "opcode.h" #include #include +#include #include #include #define bench 0 -#define debug 1 -#define IO 0 +#define debug 0 +#define IO 1 #define keypoll 0 #if bench #include @@ -55,6 +56,8 @@ void *run(void *args) { uint64_t sign = 0; char *s = malloc(2048); 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; @@ -97,9 +100,9 @@ void *run(void *args) { #if keypoll pthread_mutex_lock(&mutex); #endif - mvwprintw(scr, lines, 0, "pc: 0x%08llx, a: 0x%016llx, x: 0x%016llx, y: 0x%016llx" - ", sp: 0x%04lx, ps: 0x%016llx, prefix: 0x%02x, opcode: 0x%02x, thread: %u, inst: %s \r" - , cpu->pc[thread], cpu->a[thread], cpu->x[thread], cpu->y[thread] + 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" + , 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); #if keypoll @@ -799,6 +802,38 @@ void *run(void *args) { wmove(scr, y, x); esc = 0; break; + case 'H': + if (!bcd[2] && !bcd[3]) + y = 0; + else + y = ((bcd[3]*10) + bcd[2]); + if (!bcd[0] && !bcd[1]) + x = 0; + else + x = ((bcd[1]*10) + bcd[0]); + idx = 3; + wmove(scr, y, x); + bcd[0] = 0; + bcd[1] = 0; + bcd[2] = 0; + bcd[3] = 0; + esc = 0; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + bcd[idx--] = (addr[address] - '0'); + break; + default: + iscol = (addr[address] == ';'); + break; } } else { if (addr[address] == CURSES_BACKSPACE || addr[address] == '\b') { @@ -826,6 +861,78 @@ void *run(void *args) { pthread_mutex_unlock(&mutex); #endif } + #else + if (address == TX_ADDR) { + if (esc) { + switch(addr[address]) { + case 'A': + if (y > 0) + y--; + esc = 0; + break; + case 'B': + if (y < getmaxy(scr)) + y++; + esc = 0; + break; + case 'C': + if (x < getmaxx(scr)) + x++; + esc = 0; + break; + case 'D': + if (x > 0) + x--; + esc = 0; + break; + case 'H': + if (!bcd[2] && !bcd[3]) + y = 0; + else + y = ((bcd[3]*10) + bcd[2]); + if (!bcd[0] && !bcd[1]) + x = 0; + else + x = ((bcd[1]*10) + bcd[0]); + idx = 3; + bcd[0] = 0; + bcd[1] = 0; + bcd[2] = 0; + bcd[3] = 0; + esc = 0; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + bcd[idx--] = (addr[address] - '0'); + break; + default: + iscol = (addr[address] == ';'); + break; + } else { + if (addr[address] == CURSES_BACKSPACE || addr[address] == '\b') { + if (x > 0) { + x--; + } + } else if (addr[address] == '\033') { + esc = 1; + } else { + if (addr[address] == '\n') { + x = 0; + y+=1; + } else { + x+=1; + } + } + } + } #endif if (regsize >= 2) addr[address+1] = value >> 8; @@ -1444,7 +1551,7 @@ void *run(void *args) { break; case 0xF1: /* DEC Absolute. */ case 0xF3: /* DEC Zero Matrix. */ - if (opcode == 0xE1) { + if (opcode == 0xF1) { address = (uint64_t)addr[cpu->pc[thread]] | (uint64_t)addr[cpu->pc[thread]+1] << 8 | (uint64_t)addr[cpu->pc[thread]+2] << 16 @@ -1456,7 +1563,7 @@ void *run(void *args) { cpu->pc[thread]+=8; iclk++; } - if (opcode == 0xE3) { + if (opcode == 0xF3) { address = addr[cpu->pc[thread]] | addr[cpu->pc[thread]+1] << 8 | addr[cpu->pc[thread]+2] << 16 @@ -1504,7 +1611,12 @@ void *run(void *args) { #if keypoll pthread_mutex_lock(&mutex); #endif - mvwprintw(scr, getmaxy(scr)-lines, 0, "Operand: $%llx", address); + 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); wrefresh(scr); #if keypoll -- cgit v1.2.3-13-gbd6f