Reload program when changing processors if processor ISAs match
MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -216,7 +216,6 @@ void EditTab::onProcessorChanged() {
// Notify a possible assembler change to the code editor - opcodes might have been added or removed which must be
// reflected in the syntax highlighter
m_ui->codeEditor->setSourceType(m_currentSourceType, ProcessorHandler::getAssembler()->getOpcodes());
- assemble();
}
void EditTab::emitProgramChanged() {

MODIFY
src/isa/isainfo.h
src/isa/isainfo.h
#pragma once
#include <QMap>
+#include <QSet>
#include <QString>
#include <set>
@@ -58,6 +59,17 @@ public:
bool extensionEnabled(const QString& ext) const { return enabledExtensions().contains(ext); }
bool supportsExtension(const QString& ext) const { return supportedExtensions().contains(ext); }
+ /**
+ * ISA equality is defined as a separate function rather than the == operator, given that we might need to check for
+ * ISA equivalence, without having instantiated the other ISA. As such, it being uninstantiated does not allow
+ * compoarison of extensions.
+ */
+ bool eq(const ISAInfoBase* other, const QStringList& otherExts) const {
+ const auto ext1 = QSet(this->enabledExtensions().begin(), this->enabledExtensions().end());
+ const auto ext2 = QSet(otherExts.begin(), otherExts.end());
+ return this->name() == other->name() && ext1 == ext2;
+ }
+
protected:
ISAInfoBase() {}
};

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -163,10 +163,13 @@ void ProcessorHandler::createAssemblerForCurrentISA() {
void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList& extensions,
RegisterInitialization setup) {
- m_program = nullptr;
m_currentID = id;
RipesSettings::setValue(RIPES_SETTING_PROCESSOR_ID, id);
+ // Keep current program if the ISA between the two processors are identical
+ const bool keepProgram = m_currentProcessor && (m_currentProcessor->implementsISA()->eq(
+ ProcessorRegistry::getDescription(id).isa, extensions));
+
// Processor initializations
m_currentProcessor = ProcessorRegistry::constructProcessor(m_currentID, extensions);
m_currentProcessor->isExecutableAddress = [=](uint32_t address) { return _isExecutableAddress(address); };
@@ -193,6 +196,12 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
m_currentProcessor->verifyAndInitialize();
createAssemblerForCurrentISA();
+ if (keepProgram && m_program) {
+ loadProgram(m_program);
+ } else {
+ m_program = nullptr;
+ }
+
emit processorChanged();
}

Reload program when changing processors if processor ISAs match