summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c73
1 files changed, 57 insertions, 16 deletions
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;