disassembler in ncurses mode
This commit is contained in:
parent
17ab6d8e67
commit
437ac02bce
2 changed files with 34 additions and 3 deletions
|
@ -107,7 +107,7 @@ void console_ncurses::resize_terminal()
|
||||||
|
|
||||||
create_win_border(0, 0, 80, 25, "terminal", &w_main_b, &w_main, false);
|
create_win_border(0, 0, 80, 25, "terminal", &w_main_b, &w_main, false);
|
||||||
|
|
||||||
create_win_border(0, 27, 80, 3, "panel", &w_panel_b, &w_panel, false);
|
create_win_border(0, 27, 100, 4, "panel", &w_panel_b, &w_panel, false);
|
||||||
|
|
||||||
scrollok(w_main -> win, TRUE);
|
scrollok(w_main -> win, TRUE);
|
||||||
|
|
||||||
|
@ -134,8 +134,13 @@ void console_ncurses::panel_update_thread()
|
||||||
|
|
||||||
uint16_t current_instr = b->readWord(current_PC);
|
uint16_t current_instr = b->readWord(current_PC);
|
||||||
|
|
||||||
|
auto data = c->disassemble(current_PC);
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lck(ncurses_mutex);
|
std::unique_lock<std::mutex> lck(ncurses_mutex);
|
||||||
|
|
||||||
|
werase(w_panel->win);
|
||||||
|
|
||||||
|
//
|
||||||
wattron(w_panel->win, COLOR_PAIR(1 + run_mode));
|
wattron(w_panel->win, COLOR_PAIR(1 + run_mode));
|
||||||
|
|
||||||
for(uint8_t b=0; b<22; b++)
|
for(uint8_t b=0; b<22; b++)
|
||||||
|
@ -158,12 +163,38 @@ void console_ncurses::panel_update_thread()
|
||||||
|
|
||||||
wattron(w_panel->win, COLOR_PAIR(0));
|
wattron(w_panel->win, COLOR_PAIR(0));
|
||||||
|
|
||||||
|
// disassembler
|
||||||
|
auto registers = data["registers"];
|
||||||
|
auto psw = data["psw"][0];
|
||||||
|
|
||||||
|
std::string instruction_values;
|
||||||
|
for(auto iv : data["instruction-values"])
|
||||||
|
instruction_values += (instruction_values.empty() ? "" : ",") + iv;
|
||||||
|
|
||||||
|
std::string work_values;
|
||||||
|
for(auto wv : data["work-values"])
|
||||||
|
work_values += (work_values.empty() ? "" : ",") + wv;
|
||||||
|
|
||||||
|
std::string instruction = data["instruction-text"].at(0);
|
||||||
|
|
||||||
|
mvwprintw(w_panel->win, 2, 1, "R0: %s, R1: %s, R2: %s, R3: %s, R4: %s, R5: %s, SP: %s, PC: %s",
|
||||||
|
registers[0].c_str(), registers[1].c_str(), registers[2].c_str(), registers[3].c_str(), registers[4].c_str(), registers[5].c_str(),
|
||||||
|
registers[6].c_str(), registers[7].c_str());
|
||||||
|
mvwprintw(w_panel->win, 3, 1, "PSW: %s, instr: %s",
|
||||||
|
psw.c_str(),
|
||||||
|
instruction_values.c_str());
|
||||||
|
mvwprintw(w_panel->win, 3, 46, "%s - %s",
|
||||||
|
instruction.c_str(),
|
||||||
|
work_values.c_str());
|
||||||
|
|
||||||
|
// speed
|
||||||
uint64_t cur_instr_cnt = c->get_instructions_executed_count();
|
uint64_t cur_instr_cnt = c->get_instructions_executed_count();
|
||||||
|
|
||||||
mvwprintw(w_panel->win, 1, 1 + 39, "%8ld", (cur_instr_cnt - prev_instr_cnt) * refresh_rate);
|
mvwprintw(w_panel->win, 1, 1 + 39, "%8ld", (cur_instr_cnt - prev_instr_cnt) * refresh_rate);
|
||||||
|
|
||||||
prev_instr_cnt = cur_instr_cnt;
|
prev_instr_cnt = cur_instr_cnt;
|
||||||
|
|
||||||
|
// ncurses
|
||||||
wmove(w_main->win, ty, tx);
|
wmove(w_main->win, ty, tx);
|
||||||
|
|
||||||
mydoupdate();
|
mydoupdate();
|
||||||
|
|
4
cpu.h
4
cpu.h
|
@ -58,14 +58,14 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
operand_parameters addressing_to_string(const uint8_t mode_register, const uint16_t pc, const bool word_mode) const;
|
operand_parameters addressing_to_string(const uint8_t mode_register, const uint16_t pc, const bool word_mode) const;
|
||||||
std::map<std::string, std::vector<std::string> > disassemble(const uint16_t addr) const;
|
|
||||||
void disassemble(void) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit cpu(bus *const b, uint32_t *const event);
|
explicit cpu(bus *const b, uint32_t *const event);
|
||||||
~cpu();
|
~cpu();
|
||||||
|
|
||||||
void setDisassemble(const bool state);
|
void setDisassemble(const bool state);
|
||||||
|
void disassemble(void) const;
|
||||||
|
std::map<std::string, std::vector<std::string> > disassemble(const uint16_t addr) const;
|
||||||
|
|
||||||
bus *getBus() { return b; }
|
bus *getBus() { return b; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue