diff options
| -rw-r--r-- | eater_cpu/cpp/disas.h | 13 | ||||
| -rw-r--r-- | eater_cpu/cpp/simpc_config.h | 2 | ||||
| -rw-r--r-- | eater_cpu/cpp/simpc_curses.cpp | 47 |
3 files changed, 29 insertions, 33 deletions
diff --git a/eater_cpu/cpp/disas.h b/eater_cpu/cpp/disas.h index 9685e15..3fd4670 100644 --- a/eater_cpu/cpp/disas.h +++ b/eater_cpu/cpp/disas.h @@ -5,21 +5,22 @@ #include <string> static std::string disas(uint8_t ins) { + const uint8_t arg = ins & 0x0f; switch (ins >> 4) { case 0: return "nop"; case 1: - return std::format("lda {}", ins & 0x0f); + return std::format("lda {}", arg); case 2: - return std::format("add {}", ins & 0x0f); + return std::format("add {}", arg); case 3: - return std::format("sub {}", ins & 0x0f); + return std::format("sub {}", arg); case 4: - return std::format("sta {}", ins & 0x0f); + return std::format("sta {}", arg); case 5: - return std::format("ldi {}", ins & 0x0f); + return std::format("ldi {}", arg); case 6: - return std::format("jmp"); + return std::format("jmp {}", arg); case 14: return std::format("out"); case 15: diff --git a/eater_cpu/cpp/simpc_config.h b/eater_cpu/cpp/simpc_config.h index cc00199..f100b08 100644 --- a/eater_cpu/cpp/simpc_config.h +++ b/eater_cpu/cpp/simpc_config.h @@ -1,4 +1,4 @@ #pragma once // #define TICKS_PER_CLOCK_PERIOD 1 -#define NCUR_DELAY_MS 10 +#define NCUR_DELAY_MS 100 diff --git a/eater_cpu/cpp/simpc_curses.cpp b/eater_cpu/cpp/simpc_curses.cpp index b6dd230..e129e8b 100644 --- a/eater_cpu/cpp/simpc_curses.cpp +++ b/eater_cpu/cpp/simpc_curses.cpp @@ -49,8 +49,6 @@ static bool resized = false; static void handle_key(); -// void simpc_ui_write(const std::unique_ptr<Veater_computer> &topp, uint64_t -// &i) { void simpc_ui_write(const std::unique_ptr<Veater_computer> &topp, uint64_t i) { // clk hi->lo doesn't do anything, just skip this. if (i != 0 && !topp->clk_in) @@ -61,17 +59,27 @@ void simpc_ui_write(const std::unique_ptr<Veater_computer> &topp, uint64_t i) { PRINT_ME_W(status_top, 1, 1, "Step: %10lu", i); PRINT_ME_W(status_top, 2, 1, "%-20s", paused ? "Paused" : "Running"); - PRINT_ME_W(clock_regs, 1, 1, "CLK: %4d\tPC: 0x%02X\tINS: 0x%02X\tHLT: %6d", - topp->clk_in, - // wrong - // topp->eater_computer->clk_in, - topp->eater_computer->PC_out, opcode, topp->halt); + PRINT_ME_W(clock_regs, 1, 1, "CLK: %2d\tState: 0x%02X\tHLT: %-2d", + topp->clk_in, topp->eater_computer->decoder__DOT__internal_state, + topp->halt); + + PRINT_ME_W(clock_regs, 2, 1, "BUS: %02X\tPC: @0x%02X\tINS: 0x%02X", + topp->eater_computer->bus, topp->eater_computer->PC_out, opcode); + + PRINT_ME_W(clock_regs, 3, 1, "A : 0x%02X\tB : 0x%02X\tALU: 0x%02X\tOUT: 0x%02X", + topp->eater_computer->A->r_datastore, + topp->eater_computer->B->r_datastore, + topp->eater_computer->alu->result, + topp->eater_computer->OUT->r_datastore); + + // "PC: 0x%02X, INS: 0x%02X", topp->eater_computer->PC_out, opcode; // const wchar_t flag_on = L'\u26ab'; // const wchar_t flag_off = L'\u26aa'; const char flag_on = 'X'; const char flag_off = ' '; + const int flagstart = 4; PRINT_ME_W( - clock_regs, 2, 1, + clock_regs, flagstart, 1, "| %c | %c | %c %c | %c %c | %c %c | %c %c | %c %c | %c | %c %c %c |", halt ? flag_on : flag_off, topp->eater_computer->flags.__PVT__MAR_in ? flag_on : flag_off, @@ -89,26 +97,13 @@ void simpc_ui_write(const std::unique_ptr<Veater_computer> &topp, uint64_t i) { topp->eater_computer->flags.__PVT__PC_count ? flag_on : flag_off, topp->eater_computer->flags.__PVT__PC_out ? flag_on : flag_off, topp->eater_computer->flags.__PVT__PC_in ? flag_on : flag_off); - PRINT_ME_W(clock_regs, 3, 1, + PRINT_ME_W(clock_regs, flagstart + 1, 1, "| H | M | R R | I I | A A | A S | B B | O | C C J | \n"); - PRINT_ME_W(clock_regs, 4, 1, + PRINT_ME_W(clock_regs, flagstart + 2, 1, "| L | A | A A | S S | I O | L U | I O | I | E O M | \n"); - PRINT_ME_W(clock_regs, 5, 1, + PRINT_ME_W(clock_regs, flagstart + 3, 1, "| T | I | I O | I O | | O B | | N | P | \n"); - // PRINT_ME_W( - // clock_regs, 2, 1, "A: 0x%02X\tD: 0x%02X\tM: 0x%02X\tRES: 0x%02X", - // topp->eater_computer->reg_A_int, topp->eater_computer->reg_D_int, - // topp->eater_computer->reg_pA_int, topp->eater_computer->result_int); - // PRINT_ME_W(clock_regs, 3, 1, "%c%8d\t%c %8d\t%c %8d\t%11d", - // topp->eater_computer->store_to_A_int ? '*' : ' ', - // topp->eater_computer->reg_A_int, - // topp->eater_computer->store_to_D_int ? '*' : ' ', - // topp->eater_computer->reg_D_int, - // topp->eater_computer->store_to_pA_int ? '*' : ' ', - // topp->eater_computer->reg_pA_int, - // topp->eater_computer->result_int); - for (int adr = 0; adr < 16; adr++) { const int ypos_base = 1; const int adr_factored = adr % 8; @@ -168,11 +163,11 @@ void simpc_ui_init(void) { // lines, cols, ypos, xpos status_top = newwin(4, 50, 0, 0); wrefresh(status_top); - clock_regs = newwin(7, 80, 3, 0); + clock_regs = newwin(9, 80, 3, 0); wrefresh(clock_regs); auto numlines = 8 + 2; auto romwidth = 41; - MEM = newwin(numlines, romwidth, 10, 0); + MEM = newwin(numlines, romwidth, 12, 0); wrefresh(MEM); nodelay(stdscr, TRUE); |
