Adding an error message on invalid instructions

This commit is contained in:
Zoe Roux
2021-02-04 12:07:26 +01:00
parent 04f9b9a8fc
commit 845a8c26f0
11 changed files with 78 additions and 17 deletions
+13 -1
View File
@@ -9,6 +9,7 @@
#include <QPainter>
#include <iostream>
#include <utility>
#include <QMessageBox>
using namespace ComSquare::CPU;
@@ -134,8 +135,19 @@ namespace ComSquare::Debugger
return ret;
}
void CPUDebug::pause()
void CPUDebug::showError(const DebuggableError &error)
{
QMessageBox msg;
msg.setIcon(QMessageBox::Critical);
msg.setText("Invalid rom action");
msg.setInformativeText(error.what());
msg.exec();
}
void CPUDebug::pause(bool forcePause)
{
if (forcePause && this->_isPaused)
return;
this->_isPaused = !this->_isPaused;
if (this->_isPaused)
this->_ui.actionPause->setText("Continue");
+3 -1
View File
@@ -248,8 +248,10 @@ namespace ComSquare::Debugger
std::string _getAbsoluteIndirectLongValue(uint24_t pc);
public:
//! @brief Show an error dialog related to an exception.
void showError(const DebuggableError &error);
//! @brief Pause/Resume the CPU.
void pause();
void pause(bool forcePause = false);
//! @brief Step - Execute a single instruction.
void step();
//! @brief Next - Continue running instructions until the next line is reached.
+2 -2
View File
@@ -251,7 +251,7 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getAbsoluteIndirectValue(uint24_t pc)
{
uint24_t value = this->_bus->read(pc) + (this->_bus->read(pc + 1, true) << 8u);
uint24_t value = this->_bus->read(pc, true) + (this->_bus->read(pc + 1, true) << 8u);
return "(" + Utility::to_hex(value, Utility::HexString::AsmPrefix) + ")";
}
@@ -266,7 +266,7 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getAbsoluteIndirectIndexedByXValue(uint24_t pc)
{
uint24_t value = this->_bus->read(pc) + (this->_bus->read(pc + 1, true) << 8u);
uint24_t value = this->_bus->read(pc, true) + (this->_bus->read(pc + 1, true) << 8u);
return "(" + Utility::to_hex(value, Utility::HexString::AsmPrefix) + ", x)";
}
}
+8 -1
View File
@@ -148,6 +148,13 @@ namespace ComSquare::Debugger
return true;
}
uint8_t MemoryBusDebug::read(uint24_t addr)
{
if (this->forceSilence)
return MemoryBus::read(addr);
return this->read(addr, false);
}
uint8_t MemoryBusDebug::read(uint24_t addr, bool silence)
{
if (!silence && !this->forceSilence) {
@@ -159,7 +166,7 @@ namespace ComSquare::Debugger
this->_model.log(BusLog(false, addr, accessor, value, value));
}
}
return MemoryBus::read(addr);
return MemoryBus::read(addr, silence);
}
void MemoryBusDebug::write(uint24_t addr, uint8_t data)
+6 -1
View File
@@ -127,7 +127,12 @@ namespace ComSquare::Debugger
//! @brief Read data at a global address and log it to the debugger.
//! @param addr The address to read from.
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
uint8_t read(uint24_t addr, bool silence = false) override;
uint8_t read(uint24_t addr) override;
//! @brief Read data at a global address and log it to the debugger.
//! @param addr The address to read from.
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
uint8_t read(uint24_t addr, bool silence) override;
//! @brief Write a data to a global address and log it to the debugger.
//! @param addr The address to write to.