Fixing call to some isntructions

This commit is contained in:
Melefo
2021-06-07 17:45:05 +02:00
parent 06cdafbf16
commit eec17c9321
5 changed files with 213 additions and 97 deletions
+33 -16
View File
@@ -256,33 +256,49 @@ namespace ComSquare::Debugger
QStringList labels = QStringList();
uint16_t offset = 0;
for (uint16_t i = 0; i < 0x20; i++)
if (this->_pc != 0)
{
auto pc = this->_internalRegisters.pc;
auto instruction = this->_getInstruction();
std::string operand;
this->_ui.logger->setItem(i, 0, new QTableWidgetItem(instruction.name.c_str()));
operand = this->_getOperand(std::get<0>(instruction.operands));
this->_ui.logger->setItem(i, 1, new QTableWidgetItem(operand.c_str()));
if (operand.empty())
this->_ui.logger->item(i, 1)->setData(Qt::BackgroundRole, QColor(220, 220, 220));
operand = this->_getOperand(std::get<1>(instruction.operands));
this->_ui.logger->setItem(i, 2, new QTableWidgetItem(operand.c_str()));
if (operand.empty())
this->_ui.logger->item(i, 2)->setData(Qt::BackgroundRole, QColor(220, 220, 220));
this->_internalRegisters.pc = this->_pc;
this->_appendInstruction(0);
labels.append(Utility::to_hex(this->_pc).c_str());
this->_internalRegisters.pc = pc;
}
else
labels.append("$0000");
for (uint16_t i = 1; i < 0x20; i++)
{
auto pc = this->_internalRegisters.pc;
offset += this->_appendInstruction(i);
labels.append(Utility::to_hex(pc).c_str());
offset += instruction.size;
}
this->_ui.logger->setVerticalHeaderLabels(labels);
for (int i = 0; i < 3; i++)
this->_ui.logger->item(0, i)->setData(Qt::BackgroundRole, QColor(200, 255, 148));
this->_ui.logger->item(1, i)->setData(Qt::BackgroundRole, QColor(200, 255, 148));
this->_internalRegisters.pc -= offset;
}
int APUDebug::_appendInstruction(int row)
{
auto instruction = this->_getInstruction();
std::string operand;
this->_ui.logger->setItem(row, 0, new QTableWidgetItem(instruction.name.c_str()));
operand = this->_getOperand(std::get<0>(instruction.operands));
this->_ui.logger->setItem(row, 1, new QTableWidgetItem(operand.c_str()));
if (operand.empty())
this->_ui.logger->item(row, 1)->setData(Qt::BackgroundRole, QColor(220, 220, 220));
operand = this->_getOperand(std::get<1>(instruction.operands));
this->_ui.logger->setItem(row, 2, new QTableWidgetItem(operand.c_str()));
if (operand.empty())
this->_ui.logger->item(row, 2)->setData(Qt::BackgroundRole, QColor(220, 220, 220));
return instruction.size;
}
std::string APUDebug::_getOperand(Operand ope)
{
switch (ope) {
@@ -354,6 +370,7 @@ namespace ComSquare::Debugger
void APUDebug::update(unsigned cycles)
{
this->_pc = this->_internalRegisters.pc;
try {
if (this->_isPaused)
return;
+7 -1
View File
@@ -94,7 +94,7 @@ namespace ComSquare::Debugger
{"ROL", 2, {DirectAddr, None}},
{"ROL", 3, {AbsoluteAddr, None}},
{"PUSH", 1, {A, None}},
{"CBNE", 3, {ImmediateData, ImmediateData}},
{"CBNE", 3, {DirectAddrByX, ImmediateData}},
{"BRA", 2, {ImmediateData, None}},
{"BMI", 2, {ImmediateData, None}},
{"TCALL", 1, {None, None}},
@@ -306,6 +306,12 @@ namespace ComSquare::Debugger
{"STOP", 1, {None, None}}
}};
//! @brief Position of the last instruction executed
uint16_t _pc;
//! @brief Add instruction to disassembly
int _appendInstruction(int row);
//! @brief The QT window for this debugger.
ClosableWindow<APUDebug> *_window;