From da637ed3e40fbc6ae14a1634697685437d8f313f Mon Sep 17 00:00:00 2001 From: Anonymus Raccoon Date: Fri, 27 Mar 2020 00:02:32 +0100 Subject: [PATCH] Implementing a basic dissasembly, emulation of the x and m flags are not present yet --- sources/CPU/CPU.hpp | 2 +- sources/Debugger/CPUDebug.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sources/CPU/CPU.hpp b/sources/CPU/CPU.hpp index 9c32d6c..679b8b3 100644 --- a/sources/CPU/CPU.hpp +++ b/sources/CPU/CPU.hpp @@ -574,7 +574,7 @@ namespace ComSquare::CPU {&CPU::LDA, 5, "lda", AddressingMode::AbsoluteIndexedByXLong, 4}, // BF {&CPU::BRK, 7, "cpy #-#", AddressingMode::Implied, 2}, // C0 {&CPU::BRK, 7, "cmp #-#", AddressingMode::Implied, 2}, // C1 - {&CPU::REP, 3, "rep", AddressingMode::Immediate8bits, 3}, // C2 + {&CPU::REP, 3, "rep", AddressingMode::Immediate8bits, 2}, // C2 {&CPU::BRK, 7, "cmp #-#", AddressingMode::Implied, 2}, // C3 {&CPU::BRK, 7, "cpy #-#", AddressingMode::Implied, 2}, // C4 {&CPU::BRK, 7, "cmp #-#", AddressingMode::Implied, 2}, // C5 diff --git a/sources/Debugger/CPUDebug.cpp b/sources/Debugger/CPUDebug.cpp index d362008..a642956 100644 --- a/sources/Debugger/CPUDebug.cpp +++ b/sources/Debugger/CPUDebug.cpp @@ -26,12 +26,12 @@ namespace ComSquare::Debugger this->_ui.setupUi(this->_window); + this->disassembledInstructions = this->_disassemble(0x808000, 0x7FFF); this->_ui.disasembly->setModel(&this->_model); this->_ui.disasembly->setShowGrid(false); this->_ui.disasembly->verticalHeader()->hide(); this->_ui.disasembly->horizontalHeader()->hide(); this->_ui.disasembly->horizontalHeader()->setStretchLastSection(true); - this->disassembledInstructions = this->_disassemble(0x808000, this->_cartridgeHeader.romSize); QMainWindow::connect(this->_ui.actionPause, &QAction::triggered, this, &CPUDebug::pause); QMainWindow::connect(this->_ui.actionStep, &QAction::triggered, this, &CPUDebug::step); @@ -228,9 +228,9 @@ namespace ComSquare::Debugger DisassembledInstruction CPUDebug::_parseInstruction(uint24_t pc) { - uint24_t opcode = this->_bus->read(pc++, true); + uint24_t opcode = this->_bus->read(pc, true); Instruction instruction = this->_instructions[opcode]; - std::string argument = this->_getInstructionParameter(instruction, pc); + std::string argument = this->_getInstructionParameter(instruction, pc + 1); return DisassembledInstruction(instruction, pc, argument, opcode); } @@ -300,6 +300,11 @@ QVariant DisassemblyModel::data(const QModelIndex &index, int role) const switch (index.column()) { case 0: return QString(ComSquare::Utility::to_hex(instruction.address).c_str()); + case 1: + return QString(instruction.name.c_str()); + case 2: + return QString(instruction.argument.c_str()); + default: + return QVariant(); } - return QString(); } \ No newline at end of file