From 1ec19679b3db209429b0897f6ccda6d09d018a70 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 Aug 2020 10:28:36 -0400 Subject: Did a ton of stuff. - Changed the file structure of the SuB Suite, so that all variable declarations, symbols, and constants are in a single file. - Moved the C library functionss into a separate file, and made them use stack frames. - Added support for using the emulator's assembler for realtime debugging, to enter it, get in to stepping mode by pressing Ctrl+s, press any other key, then press F1, The reason for having to press some other key before pressing F1 is because it only allows entering the assembler when the keyboard is not ready. - Added the ".res" directive to the emulator's assembler, the ".res" directive tells the assembler to reserve however many bytes specified by the operand. - Fixed some bugs in the emulator's assembler. --- sux.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 16 deletions(-) (limited to 'sux.c') diff --git a/sux.c b/sux.c index ae99a8b..f6d01e7 100644 --- a/sux.c +++ b/sux.c @@ -145,6 +145,11 @@ void *run(void *args) { #endif if (optype[opcode] != IMPL) { address.u64 = get_addr(cpu, &tmpaddr, opcode, prefix, thread); + + if (address.u64 > mem_size-1) { + addr[STEP_ADDR] = 1; + step = 1; + } setreg_sw(value.u8, 0, addr, address.u64, prefix, 0, RS); if (optype[opcode] == REL) { switch ((prefix >> 4) & 3) { @@ -531,10 +536,26 @@ void *run(void *args) { return NULL; } +void init_scr() { + if (!scr) { + scr = initscr(); + } + nodelay(stdscr, 0); + crmode(); + noecho(); + nl(); + curs_set(1); + scrollok(scr, 1); + start_color(); + use_default_colors(); + init_pair(1, COLOR_WHITE, -1); + attron(COLOR_PAIR(1) | A_BOLD); +} + int main(int argc, char **argv) { struct suxthr thr[THREADS]; char *tmp = malloc(2048); - addr = malloc(0x04000000); + addr = malloc(mem_size); #if bench inss = 0; #endif @@ -546,7 +567,7 @@ int main(int argc, char **argv) { } } else { #if debug - subdbg = !strcmp(argv[1], "programs/sub-suite/subeditor.s"); + subdbg = !strcmp(argv[1], "programs/sub-suite/subsuite.s"); #endif if (asmmon(argv[1]) == 2) { return 0; @@ -555,20 +576,8 @@ int main(int argc, char **argv) { sprintf(tmp, "\033[2J\033[H"); fwrite(tmp, sizeof(char), strlen(tmp), stdout); fflush(stdout); - if(!scr) { - scr = initscr(); - } - nodelay(stdscr, 0); - crmode(); - noecho(); - nl(); - curs_set(1); + init_scr(); werase(scr); - scrollok(scr, 1); - start_color(); - use_default_colors(); - init_pair(1, COLOR_WHITE, -1); - attron(COLOR_PAIR(1) | A_BOLD); wmove(scr, 0, 0); wrefresh(scr); pthread_t therads[THREADS]; @@ -628,7 +637,38 @@ int main(int argc, char **argv) { #if keypoll pthread_mutex_lock(&mutex); #endif - c = wgetch(scr); + if (step) { + keypad(scr, 1); + c = wgetch(scr); + if (c != 19 && c != 18 && c != 0x11 && !isalnum(c)) { + /*WINDOW *w; + int maxcol = getmaxx(scr)/2; + int maxrow = getmaxy(scr)/2;*/ + switch (c) { + case KEY_F(1): + /*w = newwin(maxrow, maxcol, maxrow, maxcol); + emumon(w); + delwin(w);*/ + endwin(); + puts("Starting asmmon()"); + asmmon("stdin"); + puts("Reinitializing screen."); + init_scr(); + wrefresh(scr); + break; + } + #if debug && !bench + wmove(scr, getmaxy(scr)-1, 0); + wclrtoeol(scr); + wprintw(scr, "c: %i", c); + wmove(scr, y, x); + #endif + c = 0; + } + keypad(scr, 0); + } else { + c = wgetch(scr); + } if (c == 19) { if (kbd_rdy) { c = wgetch(scr); @@ -643,6 +683,7 @@ int main(int argc, char **argv) { case ERR: addr[CTRL_ADDR] = 0; break; + case '\0': break; default: if (kbd_rdy && c < 0x100) { addr[RX_ADDR] = (uint8_t)c; -- cgit v1.2.3-13-gbd6f