Skip to content

Commit

Permalink
Add disassembler option for tabs between the opcode and operands. Imp…
Browse files Browse the repository at this point in the history
…lements #462.
  • Loading branch information
calc84maniac committed Jul 9, 2024
1 parent 31dff66 commit 6074f6f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
3 changes: 2 additions & 1 deletion gui/qt/debugger/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ static bool disasmPut(struct zdis_ctx *ctx, enum zdis_put kind, int32_t val, boo
*disasm.cur += static_cast<char>(val);
break;
case ZDIS_PUT_MNE_SEP:
disasm.instr.operands = disasm.tab ? '\t' : ' ';
disasm.cur = &disasm.instr.operands;
break;
case ZDIS_PUT_ARG_SEP:
Expand Down Expand Up @@ -188,7 +189,7 @@ void disasmGet(bool useCpuMode) {
static char tmpbuf[20];
size_t size = cpu.registers.PC - static_cast<uint32_t>(disasm.base);
disasm.instr.data = disasm.instr.data.substr(0, size * 2);
disasm.instr.operands.clear();
disasm.instr.operands = disasm.tab ? '\t' : ' ';
int precision;
if (size % 3 == 0) {
size /= 3;
Expand Down
15 changes: 8 additions & 7 deletions gui/qt/debugger/disasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ typedef struct {
} highlight;
int32_t base;
int32_t next;
bool adl;
bool il;
bool uppercase;
bool implicit;
bool bytes;
bool addr;
bool bold_sym;
bool adl : 1;
bool il : 1;
bool uppercase : 1;
bool implicit : 1;
bool bytes : 1;
bool addr : 1;
bool bold_sym : 1;
bool tab : 1;
map_t map;
map_value_t reverse;
std::string comma;
Expand Down
4 changes: 3 additions & 1 deletion gui/qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U
connect(ui->checkCharging, &QCheckBox::toggled, this, &MainWindow::batterySetCharging);
connect(ui->sliderBattery, &QSlider::valueChanged, this, &MainWindow::batterySet);
connect(ui->checkAddSpace, &QCheckBox::toggled, this, &MainWindow::setDebugDisasmSpace);
connect(ui->checkOperandTab, &QCheckBox::toggled, this, &MainWindow::setDebugDisasmTab);
connect(ui->checkDisableSoftCommands, &QCheckBox::toggled, this, &MainWindow::setDebugSoftCommands);
connect(ui->buttonZero, &QPushButton::clicked, this, &MainWindow::debugZeroCycles);
connect(ui->buttonCertID, &QPushButton::clicked, this, &MainWindow::setCalcId);
Expand Down Expand Up @@ -585,6 +586,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U
ui->checkSaveRestore->setChecked(m_config->value(SETTING_SAVE_ON_CLOSE, true).toBool());
setFont(m_config->value(SETTING_DEBUGGER_TEXT_SIZE, 9).toInt());
setDebugDisasmSpace(m_config->value(SETTING_DEBUGGER_DISASM_SPACE, false).toBool());
setDebugDisasmTab(m_config->value(SETTING_DEBUGGER_DISASM_TAB, false).toBool());
setDebugDisasmAddrCol(m_config->value(SETTING_DEBUGGER_ADDR_COL, true).toBool());
setDebugDisasmDataCol(m_config->value(SETTING_DEBUGGER_DATA_COL, true).toBool());
setDebugDisasmBoldSymbols(m_config->value(SETTING_DEBUGGER_BOLD_SYMBOLS, false).toBool());
Expand Down Expand Up @@ -2442,7 +2444,7 @@ void MainWindow::disasmLine() {
}
sit++;
} else {
line = QString(QStringLiteral("%1 %2%3%4 %5 %6 %7"))
line = QString(QStringLiteral("%1 %2%3%4 %5 %6%7"))
.arg(disasm.addr ? int2hex(static_cast<uint32_t>(disasm.base), 6) : QString(),
disasm.highlight.watchR ? QStringLiteral("R") : QStringLiteral(" "),
disasm.highlight.watchW ? QStringLiteral("W") : QStringLiteral(" "),
Expand Down
2 changes: 2 additions & 0 deletions gui/qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ class MainWindow : public QMainWindow {
void setDebugDisasmDataCol(bool state);
void setDebugDisasmAddrCol(bool state);
void setDebugDisasmSpace(bool state);
void setDebugDisasmTab(bool state);
void setDebugDisasmImplict(bool state);
void setDebugDisasmUppercase(bool state);
void setDebugDisasmBoldSymbols(bool state);
Expand Down Expand Up @@ -718,6 +719,7 @@ class MainWindow : public QMainWindow {
// Settings definitions
static const QString SETTING_DEBUGGER_TEXT_SIZE;
static const QString SETTING_DEBUGGER_DISASM_SPACE;
static const QString SETTING_DEBUGGER_DISASM_TAB;
static const QString SETTING_DEBUGGER_RESTORE_ON_OPEN;
static const QString SETTING_DEBUGGER_SAVE_ON_CLOSE;
static const QString SETTING_DEBUGGER_RESET_OPENS;
Expand Down
16 changes: 13 additions & 3 deletions gui/qt/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9791,7 +9791,7 @@ QPushButton:pressed {
<string>Disassembly</string>
</property>
<layout class="QGridLayout" name="gridLayout_23">
<item row="1" column="0">
<item row="2" column="0">
<widget class="QCheckBox" name="checkDisasmDataCol">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
Expand All @@ -9812,12 +9812,22 @@ QPushButton:pressed {
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkOperandTab">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Tab between opcode / operands</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkAddSpace">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Opcode / operand space</string>
<string>Space between operands</string>
</property>
</widget>
</item>
Expand All @@ -9828,7 +9838,7 @@ QPushButton:pressed {
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="checkDisasmAddr">
<property name="text">
<string>Show address column</string>
Expand Down
10 changes: 10 additions & 0 deletions gui/qt/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const QString MainWindow::SETTING_DEBUGGER_RESET_OPENS = QStringLiteral("De
const QString MainWindow::SETTING_DEBUGGER_ENABLE_SOFT = QStringLiteral("Debugger/enable_soft_commands");
const QString MainWindow::SETTING_DEBUGGER_BOLD_SYMBOLS = QStringLiteral("Debugger/disasm_bold_symbols");
const QString MainWindow::SETTING_DEBUGGER_DISASM_SPACE = QStringLiteral("Debugger/disasm_add_space");
const QString MainWindow::SETTING_DEBUGGER_DISASM_TAB = QStringLiteral("Debugger/disasm_use_tab");
const QString MainWindow::SETTING_DEBUGGER_ADDR_COL = QStringLiteral("Debugger/disasm_addr_column");
const QString MainWindow::SETTING_DEBUGGER_DATA_COL = QStringLiteral("Debugger/disasm_data_column");
const QString MainWindow::SETTING_DEBUGGER_IMPLICT = QStringLiteral("Debugger/disasm_implict");
Expand Down Expand Up @@ -356,6 +357,15 @@ void MainWindow::setDebugDisasmSpace(bool state) {
}
}

void MainWindow::setDebugDisasmTab(bool state) {
ui->checkOperandTab->setChecked(state);
m_config->setValue(SETTING_DEBUGGER_DISASM_TAB, state);
disasm.tab = state;
if (guiDebug) {
disasmUpdate();
}
}

void MainWindow::setLcdDma(bool state) {
ui->checkDma->setChecked(state);
ui->checkGamma->setEnabled(state);
Expand Down

0 comments on commit 6074f6f

Please sign in to comment.