summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-12-09 21:13:40 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-12-09 21:13:40 -0500
commit1700d8d10453ffe046438de0e6fbd496def915a1 (patch)
treecd222f66ad948f472b192fa967bf00f59e13179d
parentf0e217bbc7d646742e3a83dbeb36332ded9f9df4 (diff)
- Made the emulator's debugger use individual windows.
I mainly did this to be able to display all 16 main registers, but also to simplify the debugger.
-rw-r--r--disasm.c332
-rw-r--r--io.c8
-rw-r--r--sux.c85
-rw-r--r--sux.h8
4 files changed, 258 insertions, 175 deletions
diff --git a/disasm.c b/disasm.c
index e0f4fbc..b79d55b 100644
--- a/disasm.c
+++ b/disasm.c
@@ -12,26 +12,161 @@
mne##_RR: case mne##_RM: case mne##_MR: case mne##_MM
-void print_regs(struct sux *cpu, uint8_t lines, uint8_t thread) {
+void print_info(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t thread) {
for (uint8_t i = (24*thread)+2; i <= 24*(thread+1); i++) {
- wmove(scr, i, 0);
- waddch(scr, (i == lines) ? '>' : ' ');
+ wmove(w, i, 0);
+ waddch(w, (i == lines) ? '>' : ' ');
}
- wmove(scr, lines, 1);
- wclrtoeol(scr);
- wprintw(scr, "pc: $%04"PRIX64 , cpu->pc);
- wprintw(scr, ", a: $%08"PRIX64, cpu->a);
- wprintw(scr, ", b: $%08"PRIX64, cpu->b);
- wprintw(scr, ", x: $%08"PRIX64, cpu->x);
- wprintw(scr, ", y: $%08"PRIX64, cpu->y);
- wprintw(scr, ", e: $%08"PRIX64, cpu->e);
- wprintw(scr, ", sp: $%"PRIX64, cpu->sp);
- wprintw(scr, ", ps: %c%c---%c%c%c", cpu->ps.u8[thread] & N ? 'N' : '-'
- , cpu->ps.u8[thread] & V ? 'V' : '-'
- , cpu->ps.u8[thread] & I ? 'I' : '-'
- , cpu->ps.u8[thread] & Z ? 'Z' : '-'
- , cpu->ps.u8[thread] & C ? 'C' : '-');
- wprintw(scr, ", inst: ");
+ wmove(w, lines, 1);
+ wclrtoeol(w);
+ wprintw(w, "pc: $%04"PRIX64 , cpu->pc);
+ wprintw(w, ", ps: %c%c---%c%c%c", cpu->ps.u8[thread] & N ? 'N' : '-'
+ , cpu->ps.u8[thread] & V ? 'V' : '-'
+ , cpu->ps.u8[thread] & I ? 'I' : '-'
+ , cpu->ps.u8[thread] & Z ? 'Z' : '-'
+ , cpu->ps.u8[thread] & C ? 'C' : '-');
+ wprintw(w, ", inst: ");
+}
+
+
+void print_regs(struct sux *cpu, WINDOW *w) {
+ for (int i = 0; i < 9; i++) {
+ wmove(w, i, 0);
+ wclrtoeol(w);
+ }
+ wmove(w, 0, 0);
+ wprintw(w, "Registers:\n");
+ wprintw(w, " a: $%016"PRIX64", b: $%016"PRIX64"\n", cpu->a, cpu->b);
+ wprintw(w, " x: $%016"PRIX64", y: $%016"PRIX64"\n", cpu->x, cpu->y);
+ wprintw(w, " e: $%016"PRIX64", c: $%016"PRIX64"\n", cpu->e, cpu->c);
+ wprintw(w, " d: $%016"PRIX64", s: $%016"PRIX64"\n", cpu->d, cpu->s);
+ wprintw(w, " f: $%016"PRIX64", sp: $%016"PRIX64"\n", cpu->f, cpu->sp);
+ wprintw(w, " bp: $%016"PRIX64", r11: $%016"PRIX64"\n", cpu->bp, cpu->r11);
+ wprintw(w, "r12: $%016"PRIX64", r13: $%016"PRIX64"\n", cpu->r12, cpu->r13);
+ wprintw(w, "r14: $%016"PRIX64", r15: $%016"PRIX64"\n", cpu->r14, cpu->r15);
+}
+
+static void sub_dbg(struct sux *cpu, WINDOW *w, uint64_t address, uint64_t *ortho_addr, uint8_t thread) {
+ uint8_t ln = 5;
+ uint16_t line_idx = 0;
+ uint32_t tmpad = 0x20247;
+ int row, col;
+ uint8_t iscursor = 0;
+ union reg ptr;
+ ptr.u64 = 0;
+ uint32_t adr;
+ if (address == CTRL_ADDR || ortho_addr[1] == CTRL_ADDR || addr[STEP_ADDR]) {
+ adr = read_value(cpu, 0, tmpad, 7, 0, 0);
+ tmpad += 8;
+ wmove(w, 1, 0);
+ wprintw(w, "scr_row: %02u, scr_col: %02u, scr_str: %02u, scr_end: %02u", addr[0], addr[1], addr[2], addr[3]);
+ wmove(w, 2, 0);
+ wprintw(w, "bitabl: ");
+ for (uint8_t i = 0; i < 16; i++) {
+ wprintw(w, "%s", showbits(addr[adr+i], 7, 0));
+ }
+ mvwprintw(w, ln++, 0, "buffer: ");
+ wmove(w, ln++, 0);
+ uint8_t maxrow = 10;
+ int line_offset = (addr[0]-(maxrow-1) >= 0) ? addr[0]-(maxrow-1) : 0;
+ adr = read_value(cpu, 0, tmpad, 7, 0, 0);
+ for (uint8_t i = 0; i < maxrow; i++) {
+ line_idx = (i+addr[2]+line_offset << 6) + (i+addr[2]+line_offset << 4);
+ for (uint8_t j = 0; j < 0x50; j++) {
+ wprintw(w, "%02X", addr[adr+j+line_idx]);
+ if ((addr[0] == i+line_offset) && addr[1] == j) {
+ iscursor=1;
+ getyx(w,row, col);
+ wmove(w, ln++, 0);
+ wclrtoeol(w);
+ wmove(w, row+1, col-2);
+ wprintw(w, "/\\");
+ wmove(w, row, col);
+ }
+ }
+ wprintw(w, ", i: %02X", i);
+ if (!iscursor) {
+ wmove(w, ln, 0);
+ wclrtoeol(w);
+ }
+ iscursor = 0;
+ wmove(w, ln++, 0);
+ }
+ }
+ /*wclrtoeol(w);
+ wprintw(w, "rega: $%02X, ", addr[0x0A]);
+ wprintw(w, "regb: $%02X, ", addr[0x0B]);
+ wprintw(w, "regc: $%02X, ", addr[0x0C]);
+ wprintw(w, "regd: $%02X, ", addr[0x0D]);
+ wprintw(w, "rege: $%02X, ", addr[0x0E]);
+ wprintw(w, "regf: $%02X, ", addr[0x0F]);
+ wprintw(w, "regg: $%02X", addr[0x10]);*/
+
+ wmove(w, 3, 0);
+ wclrtoeol(w);
+
+ adr = 0x25;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, "ptr1: $%04"PRIX64, ptr.u64);
+
+ adr = 0x2D;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", ptr2: $%04"PRIX64, ptr.u64);
+
+ adr = 0x35;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", ptr3: $%04"PRIX64, ptr.u64);
+
+ adr = 0x02049A;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", idx0: $%04"PRIX64, ptr.u64);
+
+ adr = 0x334BA;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", valbuf: $%016"PRIX64, ptr.u64);
+
+
+ wmove(w, 4, 0);
+ wclrtoeol(w);
+ adr = 0x200CA;
+ ptr.u64 = read_value(cpu, 0, adr, 3, 0, 0);
+ wprintw(w, "t_id: $%02X", ptr.u8[0]);
+ wprintw(w, ", t_type: $%02X", ptr.u8[1]);
+ wprintw(w, ", t_space: $%02X", ptr.u8[2]);
+ wprintw(w, ", t_tab: $%02X", ptr.u8[3]);
+ adr += 4;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", t_val: $%"PRIX64, ptr.u64);
+ adr += 8;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", t_str: $%"PRIX64, ptr.u64);
+ adr += 8;
+ ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
+ wprintw(w, ", t_sym: $%"PRIX64, ptr.u64);
+
+
+ /*
+ wmove(w, 47, 0);
+ wclrtoeol(w);
+ wprintw(w, "a: $%02X,", addr[0x0A]);
+ wprintw(w, " b: $%02X,", addr[0x0B]);
+ wprintw(w, " c: $%02X,", addr[0x0C]);
+ wprintw(w, " d: $%02X,", addr[0x0D]);
+ wprintw(w, " e: $%02X,", addr[0x0E]);
+ wprintw(w, " f: $%02X", addr[0x0F]);
+ tmpad += 8;
+ adr = read_value(cpu, 0, tmpad, 7, 0, 0);
+ line_idx = 0;
+ wprintw(w, "cmd_buf:");
+ for (uint8_t i = 0; i < 1; i++) {
+ wmove(w, ln++, 0);
+ wclrtoeol(w);
+ line_idx = (i << 4)+(i << 6);
+ for (uint8_t j = 0; j < 0x50; j++) {
+ wprintw(w, "%02X", addr[adr+j+line_idx]);
+ }
+ wprintw(w, ", i: %02X", i);
+ }*/
}
static uint64_t get_offset(uint64_t value, uint8_t size, char **sign) {
@@ -146,7 +281,7 @@ static int is_2op(uint8_t opcode) {
return 0;
}
-static void disasm_ortho(struct sux *cpu, uint8_t opcode, uint8_t prefix, uint8_t prefix2, uint64_t *value, char *inst_name, char *postfix, operand *op, uint8_t rs, uint8_t thread) {
+static void disasm_ortho(struct sux *cpu, WINDOW *w, uint8_t opcode, uint8_t prefix, uint8_t prefix2, uint64_t *value, char *inst_name, char *postfix, operand *op, uint8_t rs, uint8_t thread) {
char opr[2][256];
char address[2][17];
char *rind[2] = {"", ""};
@@ -280,9 +415,9 @@ static void disasm_ortho(struct sux *cpu, uint8_t opcode, uint8_t prefix, uint8_
} else if (is_2op(opcode)) {
op2 = opr[1];
}
- wprintw(scr, "%s%s%s %s%s %s", inst_name, postfix, os, opr[0], (op_count == 2) ? "," : "", op2);
- wmove(scr, 29, 0);
- wclrtoeol(scr);
+ wprintw(w, "%s%s%s %s%s %s", inst_name, postfix, os, opr[0], (op_count == 2) ? "," : "", op2);
+ wmove(w, getmaxy(w)-2, 0);
+ wclrtoeol(w);
for (int i = 0; i < 2; i++) {
if (op[i].type) {
sprintf(address[i], "$%04"PRIX64, value[i]);
@@ -290,11 +425,11 @@ static void disasm_ortho(struct sux *cpu, uint8_t opcode, uint8_t prefix, uint8_
sprintf(address[i], "none");
}
}
- wprintw(scr, "destination address: %s, source address: %s", address[0], address[1]);
+ wprintw(w, "destination address: %s, source address: %s", address[0], address[1]);
}
-void disasm(struct sux *cpu, uint8_t lines, uint8_t opcode, uint8_t prefix, uint8_t ext_prefix, uint8_t prefix2, uint8_t *op_type, uint8_t *op_id, uint8_t thread) {
+void disasm(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t opcode, uint8_t prefix, uint8_t ext_prefix, uint8_t prefix2, uint8_t *op_type, uint8_t *op_id, uint8_t thread) {
uint64_t value;
uint64_t address = 0;
operand ortho_op[2];
@@ -384,9 +519,9 @@ void disasm(struct sux *cpu, uint8_t lines, uint8_t opcode, uint8_t prefix, uint
}
switch (inst_type) {
case BREG :
- case IMPL : wprintw(scr, "%s%s" , inst_name, postfix); break;
- case EIND : wprintw(scr, "%s%s (E)" , op, postfix); break;
- case IMM : wprintw(scr, "%s%s #$%0*"PRIX64 , op, postfix, (addrsize+1) << 1, value); break;
+ case IMPL : wprintw(w, "%s%s" , inst_name, postfix); break;
+ case EIND : wprintw(w, "%s%s (E)" , op, postfix); break;
+ case IMM : wprintw(w, "%s%s #$%0*"PRIX64 , op, postfix, (addrsize+1) << 1, value); break;
case AIND :
case AINDX:
case AINDY:
@@ -398,145 +533,26 @@ void disasm(struct sux *cpu, uint8_t lines, uint8_t opcode, uint8_t prefix, uint
case ABSX :
case ABSY :
case ZM :
- case ABS : wprintw(scr, "%s%s %s%s%s$%0*" PRIX64"%s" , op, postfix, ind, of, sign, (addrsize+1) << 1, value, idx); break;
- case REL : wprintw(scr, "%s%s %s$%0*"PRIX64 , op, postfix, sign, (addrsize+1) << 1, value); break;
+ case ABS : wprintw(w, "%s%s %s%s%s$%0*" PRIX64"%s" , op, postfix, ind, of, sign, (addrsize+1) << 1, value, idx); break;
+ case REL : wprintw(w, "%s%s %s$%0*"PRIX64 , op, postfix, sign, (addrsize+1) << 1, value); break;
}
} else {
inst_name = ortho_opname[opcode];
memcpy(op, inst_name, 3);
- disasm_ortho(cpu, opcode, prefix, prefix2, ortho_addr, op, postfix, ortho_op, (1 << rs), thread);
- }
-
- if (address == TX_ADDR || address == RX_ADDR) {
- wmove(scr, 27, 0);
- wprintw(scr, "TX_ADDR: $%02X, RX_ADDR: $%02X", addr[TX_ADDR], addr[RX_ADDR]);
+ disasm_ortho(cpu, w, opcode, prefix, prefix2, ortho_addr, op, postfix, ortho_op, (1 << rs), thread);
}
+ int y = getmaxy(w);
if (ext_prefix != 0x1D) {
- wmove(scr, 29, 0);
- wclrtoeol(scr);
- wprintw(scr, "address: $%04"PRIX64, address);
+ wmove(w, y-2, 0);
+ wclrtoeol(w);
+ wprintw(w, "address: $%04"PRIX64, address);
+ }
+ if (address == TX_ADDR || ortho_addr[0] == TX_ADDR || address == RX_ADDR || ortho_addr[1] == RX_ADDR) {
+ wmove(w, y-1, 0);
+ wprintw(w, "TX_ADDR: $%02X, RX_ADDR: $%02X", addr[TX_ADDR], addr[RX_ADDR]);
}
if (subdbg) {
- uint8_t ln = 33;
- uint16_t line_idx = 0;
- uint32_t tmpad = 0x20247;
- int row, col;
- uint8_t iscursor = 0;
- union reg ptr;
- ptr.u64 = 0;
- uint32_t adr;
- if (address == CTRL_ADDR || addr[STEP_ADDR]) {
- adr = read_value(cpu, 0, tmpad, 7, 0, 0);
- tmpad += 8;
- wprintw(scr, ", scr_row: %02u, scr_col: %02u, scr_str: %02u, scr_end: %02u", addr[0], addr[1], addr[2], addr[3]);
- wmove(scr, 32, 0);
- wprintw(scr, "bitabl: ");
- for (uint8_t i = 0; i < 16; i++) {
- wprintw(scr, "%s", showbits(addr[adr+i], 7, 0));
- }
- mvwprintw(scr, ln++, 0, "buffer: ");
- wmove(scr, ln++, 0);
- uint8_t maxrow = 10;
- int line_offset = (addr[0]-(maxrow-1) >= 0) ? addr[0]-(maxrow-1) : 0;
- adr = read_value(cpu, 0, tmpad, 7, 0, 0);
- for (uint8_t i = 0; i < maxrow; i++) {
- line_idx = (i+addr[2]+line_offset << 6) + (i+addr[2]+line_offset << 4);
- for (uint8_t j = 0; j < 0x50; j++) {
- wprintw(scr, "%02X", addr[adr+j+line_idx]);
- if ((addr[0] == i+line_offset) && addr[1] == j) {
- iscursor=1;
- getyx(scr,row, col);
- wmove(scr, ln++, 0);
- wclrtoeol(scr);
- wmove(scr, row+1, col-2);
- wprintw(scr, "/\\");
- wmove(scr, row, col);
- }
- }
- wprintw(scr, ", i: %02X", i);
- if (!iscursor) {
- wmove(scr, ln, 0);
- wclrtoeol(scr);
- }
- iscursor = 0;
- wmove(scr, ln++, 0);
- }
- }
- /*wclrtoeol(scr);
- wprintw(scr, "rega: $%02X, ", addr[0x0A]);
- wprintw(scr, "regb: $%02X, ", addr[0x0B]);
- wprintw(scr, "regc: $%02X, ", addr[0x0C]);
- wprintw(scr, "regd: $%02X, ", addr[0x0D]);
- wprintw(scr, "rege: $%02X, ", addr[0x0E]);
- wprintw(scr, "regf: $%02X, ", addr[0x0F]);
- wprintw(scr, "regg: $%02X", addr[0x10]);*/
-
- wmove(scr, 30, 0);
- wclrtoeol(scr);
-
- adr = 0x25;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, "ptr1: $%04"PRIX64, ptr.u64);
-
- adr = 0x2D;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", ptr2: $%04"PRIX64, ptr.u64);
-
- adr = 0x35;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", ptr3: $%04"PRIX64, ptr.u64);
-
- adr = 0x02049A;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", idx0: $%04"PRIX64, ptr.u64);
-
- adr = 0x334BA;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", valbuf: $%016"PRIX64, ptr.u64);
-
-
- wmove(scr, 31, 0);
- wclrtoeol(scr);
- adr = 0x200CA;
- ptr.u64 = read_value(cpu, 0, adr, 3, 0, 0);
- wprintw(scr, "t_id: $%02X", ptr.u8[0]);
- wprintw(scr, ", t_type: $%02X", ptr.u8[1]);
- wprintw(scr, ", t_space: $%02X", ptr.u8[2]);
- wprintw(scr, ", t_tab: $%02X", ptr.u8[3]);
- adr += 4;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", t_val: $%"PRIX64, ptr.u64);
- adr += 8;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", t_str: $%"PRIX64, ptr.u64);
- adr += 8;
- ptr.u64 = read_value(cpu, 0, adr, 7, 0, 0);
- wprintw(scr, ", t_sym: $%"PRIX64, ptr.u64);
-
-
- /*
- wmove(scr, 47, 0);
- wclrtoeol(scr);
- wprintw(scr, "a: $%02X,", addr[0x0A]);
- wprintw(scr, " b: $%02X,", addr[0x0B]);
- wprintw(scr, " c: $%02X,", addr[0x0C]);
- wprintw(scr, " d: $%02X,", addr[0x0D]);
- wprintw(scr, " e: $%02X,", addr[0x0E]);
- wprintw(scr, " f: $%02X", addr[0x0F]);
- tmpad += 8;
- adr = read_value(cpu, 0, tmpad, 7, 0, 0);
- line_idx = 0;
- wprintw(scr, "cmd_buf:");
- for (uint8_t i = 0; i < 1; i++) {
- wmove(scr, ln++, 0);
- wclrtoeol(scr);
- line_idx = (i << 4)+(i << 6);
- for (uint8_t j = 0; j < 0x50; j++) {
- wprintw(scr, "%02X", addr[adr+j+line_idx]);
- }
- wprintw(scr, ", i: %02X", i);
- }*/
-
+ sub_dbg(cpu, dbg_win, address, ortho_addr, thread);
}
}
diff --git a/io.c b/io.c
index 4e69f7e..e19f194 100644
--- a/io.c
+++ b/io.c
@@ -85,6 +85,9 @@ int get_key(WINDOW *scr) {
puts("Reinitializing screen.");
init_scr();
wrefresh(scr);
+ #if debug
+ wrefresh(regs);
+ #endif
break;
}
#if debug && !bench
@@ -304,6 +307,11 @@ void io(uint64_t address, uint8_t rw) {
}
kbd_rdy = 1;
wrefresh(scr);
+ #if debug
+ wrefresh(regs);
+ wrefresh(inst_win);
+ wrefresh(dbg_win);
+ #endif
addr[RX_ADDR] = get_key(scr);
kbd_rdy = 0;
break;
diff --git a/sux.c b/sux.c
index 25bd8c5..de88b92 100644
--- a/sux.c
+++ b/sux.c
@@ -37,6 +37,9 @@ uint8_t kbd_rdy;
uint8_t end = 0;
WINDOW *scr;
+WINDOW *regs;
+WINDOW *inst_win;
+WINDOW *dbg_win;
struct suxthr {
struct sux sx;
@@ -173,15 +176,16 @@ void *run(void *args) {
#if keypoll
pthread_mutex_lock(&mutex);
#endif
- print_regs(cpu, lines, thread);
+ print_info(cpu, inst_win, lines, thread);
+ print_regs(cpu, regs);
#if keypoll
pthread_mutex_unlock(&mutex);
#endif
#endif
- uint32_t instr = read_value(cpu, 0, cpu->pc, 4, 1, 0);
- uint8_t *tmp_inst = (uint8_t *)&instr;
+ uint32_t inst = read_value(cpu, 0, cpu->pc, 4, 1, 0);
+ uint8_t *tmp_inst = (uint8_t *)&inst;
uint8_t inst_len = 0;
- prefix = ((instr & 3) == 3) ? tmp_inst[inst_len++] : 0;
+ prefix = ((inst & 3) == 3) ? tmp_inst[inst_len++] : 0;
ext_prefix = ((tmp_inst[inst_len] & 0xF) == 0xD) ? tmp_inst[inst_len++] : 0;
opcode = tmp_inst[inst_len++];
op_id = (ext_prefix == 0x1D) ? tmp_inst[inst_len++] : 0;
@@ -253,7 +257,7 @@ void *run(void *args) {
#if keypoll
pthread_mutex_lock(&mutex);
#endif
- disasm(cpu, lines, opcode, prefix, ext_prefix, prefix2, operand_type, ortho_id, thread);
+ disasm(cpu, inst_win, lines, opcode, prefix, ext_prefix, prefix2, operand_type, ortho_id, thread);
lines+=1;
#if keypoll
pthread_mutex_unlock(&mutex);
@@ -290,10 +294,14 @@ void *run(void *args) {
int c = 0;
#if debug
wrefresh(scr);
+ wrefresh(regs);
+ wrefresh(inst_win);
#endif
for (; step && c != 19 && !end; c = get_key(scr));
#if debug
wrefresh(scr);
+ wrefresh(regs);
+ wrefresh(inst_win);
#endif
}
#endif
@@ -301,13 +309,16 @@ void *run(void *args) {
#if keypoll
pthread_mutex_lock(&mutex);
#endif
- wmove(scr, (6*thread)+1, 0);
- wprintw(scr, "Instructions executed: %"PRIu64, ins);
+ wmove(inst_win, (6*thread)+1, 0);
+ wprintw(inst_win, "Instructions executed: %"PRIu64, ins);
#if getclk
- wprintw(scr, ", Clock cycles: %"PRIu64, cpu->clk);
+ wprintw(inst_win, ", Clock cycles: %"PRIu64, cpu->clk);
#endif
if (step || !subdbg) {
wrefresh(scr);
+ wrefresh(regs);
+ wrefresh(inst_win);
+ wrefresh(dbg_win);
}
#if keypoll
pthread_mutex_unlock(&mutex);
@@ -343,7 +354,34 @@ void init_scr() {
start_color();
use_default_colors();
init_pair(1, COLOR_WHITE, -1);
- attron(COLOR_PAIR(1) | A_BOLD);
+ wattron(scr, COLOR_PAIR(1) | A_BOLD);
+
+ #if debug
+ int x;
+ int y;
+ getmaxyx(scr, y, x);
+ if (!regs) {
+ regs = newwin(24, 80, 1, (x/2));
+ }
+ nodelay(regs, 0);
+ keypad(regs, 1);
+ scrollok(regs, 1);
+ wattron(regs, COLOR_PAIR(1) | A_BOLD);
+ if (!inst_win) {
+ inst_win = newwin(28, (x/2)-20, 0, 0);
+ }
+ nodelay(inst_win, 0);
+ keypad(inst_win, 1);
+ scrollok(inst_win, 1);
+ wattron(inst_win, COLOR_PAIR(1) | A_BOLD);
+ if (!dbg_win) {
+ dbg_win = newwin(33, x, y-33, 0);
+ }
+ nodelay(dbg_win, 0);
+ keypad(dbg_win, 1);
+ scrollok(dbg_win, 1);
+ wattron(dbg_win, COLOR_PAIR(1) | A_BOLD);
+ #endif
}
int main(int argc, char **argv) {
@@ -368,13 +406,26 @@ int main(int argc, char **argv) {
return 0;
}
}
- sprintf(tmp, "\033[2J\033[H");
+ /*sprintf(tmp, "\033[2J\033[H");
fwrite(tmp, sizeof(char), strlen(tmp), stdout);
- fflush(stdout);
+ fflush(stdout);*/
init_scr();
werase(scr);
wmove(scr, 0, 0);
wrefresh(scr);
+ #if debug
+ werase(regs);
+ wmove(regs, 0, 0);
+ wrefresh(regs);
+
+ werase(inst_win);
+ wmove(inst_win, 0, 0);
+ wrefresh(inst_win);
+
+ werase(dbg_win);
+ wmove(dbg_win, 0, 0);
+ wrefresh(dbg_win);
+ #endif
pthread_t therads[THREADS];
int result;
uint16_t vec = 0xFFC0;
@@ -412,10 +463,14 @@ int main(int argc, char **argv) {
thr[i].sx.sp = (i << 16) | 0xFFFF;
offset = (i) ? ((i-1) << 3) : 0;
vec = (i) ? 0xFF50 : 0xFFC0;
- thr[i].sx.a = 0;
- thr[i].sx.b = 0;
- thr[i].sx.x = 0;
- thr[i].sx.y = 0;
+ thr[i].sx.a = 0, thr[i].sx.b = 0;
+ thr[i].sx.x = 0, thr[i].sx.y = 0;
+ thr[i].sx.e = 0, thr[i].sx.c = 0;
+ thr[i].sx.d = 0, thr[i].sx.s = 0;
+ thr[i].sx.f = 0, thr[i].sx.bp = 0;
+ thr[i].sx.r11 = 0, thr[i].sx.r12 = 0;
+ thr[i].sx.r12 = 0, thr[i].sx.r13 = 0;
+ thr[i].sx.r14 = 0, thr[i].sx.r15 = 0;
thr[i].sx.pc = read_value(&thr[i].sx, 0, vec+offset, 7, 0, 0);
thr[i].th = i;
#if !IO
diff --git a/sux.h b/sux.h
index 6d4d283..9af8128 100644
--- a/sux.h
+++ b/sux.h
@@ -24,6 +24,9 @@
extern uint8_t kbd_rdy;
extern WINDOW *scr;
+extern WINDOW *regs;
+extern WINDOW *inst_win;
+extern WINDOW *dbg_win;
#if debug
extern uint8_t subdbg;
@@ -52,8 +55,9 @@ extern pthread_cond_t cond;
extern pthread_cond_t main_cond;
#if debug
-extern void print_regs(struct sux *cpu, uint8_t lines, uint8_t thread);
-extern void disasm(struct sux *cpu, uint8_t lines, uint8_t opcode, uint8_t prefix, uint8_t ext_prefix, uint8_t prefix2, uint8_t *op_type, uint8_t *op_id, uint8_t thread);
+extern void print_info(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t thread);
+extern void print_regs(struct sux *cpu, WINDOW *w);
+extern void disasm(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t opcode, uint8_t prefix, uint8_t ext_prefix, uint8_t prefix2, uint8_t *op_type, uint8_t *op_id, uint8_t thread);
#endif
/*#define KEYBUF_SIZE 0x40