Provide access to peripheral #defines in assembler
MODIFY
src/assembler/assembler.h
src/assembler/assembler.h
@@ -61,10 +61,10 @@ public:
void setSegmentBase(Section seg, uint32_t base) { m_sectionBasePointers[seg] = base; }
- virtual AssembleResult assemble(const QStringList& programLines) const = 0;
- AssembleResult assembleRaw(const QString& program) const {
+ virtual AssembleResult assemble(const QStringList& programLines, const SymbolMap* symbols = nullptr) const = 0;
+ AssembleResult assembleRaw(const QString& program, const SymbolMap* symbols = nullptr) const {
const auto programLines = program.split(QRegExp("[\r\n]"));
- return assemble(programLines);
+ return assemble(programLines, symbols);
}
virtual DisassembleResult disassemble(const Program& program, const uint32_t baseAddress = 0) const = 0;
@@ -316,12 +316,15 @@ class Assembler : public AssemblerBase {
public:
Assembler(const ISAInfoBase* isa) : m_isa(isa) {}
- AssembleResult assemble(const QStringList& programLines) const override {
+ AssembleResult assemble(const QStringList& programLines, const SymbolMap* symbols = nullptr) const override {
AssembleResult result;
// Per default, emit to .text until otherwise specified
setCurrentSegment(".text");
m_symbolMap.clear();
+ if (symbols) {
+ m_symbolMap = *symbols;
+ }
// Tokenize each source line and separate symbol from remainder of tokens
runPass(tokenizedLines, SourceProgram, pass0, programLines);

MODIFY
src/edittab.cpp
src/edittab.cpp
#include "ccmanager.h"
#include "compilererrordialog.h"
#include "editor/codeeditor.h"
+#include "io/iomanager.h"
#include "processorhandler.h"
#include "ripessettings.h"
#include "symbolnavigator.h"
@@ -215,7 +216,8 @@ void EditTab::sourceCodeChanged() {
}
void EditTab::assemble() {
- auto res = ProcessorHandler::get()->getAssembler()->assembleRaw(m_ui->codeEditor->document()->toPlainText());
+ auto res = ProcessorHandler::get()->getAssembler()->assembleRaw(m_ui->codeEditor->document()->toPlainText(),
+ &IOManager::get().assemblerSymbols());
*m_sourceErrors = res.errors;
if (m_sourceErrors->size() == 0) {
m_activeProgram = std::make_shared<Program>(res.program);

MODIFY
src/io/iomanager.h
src/io/iomanager.h
@@ -51,7 +51,7 @@ public:
* @brief assemblerSymbols
* @returns as cSymbols, but as a map which can be directly loaded into the assembler.
*/
- std::map<QString, uint32_t> assemblerSymbols() const { return m_assemblerSymbols; }
+ const std::map<QString, uint32_t>& assemblerSymbols() const { return m_assemblerSymbols; }
std::vector<std::pair<QString, uint32_t>> assemblerSymbolsForPeriph(IOBase* peripheral) const;
signals:

Provide access to peripheral #defines in assembler