forked from mortbopet/Ripes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mips32i_assembler Add mipsassembler_common.h Add instructions and pseudoinstructions at mips_i_ext Add mipsrelocations.h for hi and lo Update instruction.h for Signed and Unsigned for Mips
- Loading branch information
1 parent
ff7b0f3
commit 15fef62
Showing
7 changed files
with
541 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
create_ripes_lib(assembler LINK_TO_RIPES_LIB) | ||
|
||
target_sources(assembler_lib | ||
PRIVATE | ||
mips32i_assembler.h mips32i_assembler.cpp | ||
mipsrelocations.h | ||
mips_i_ext.h | ||
mipsassembler_common.h | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "mips32i_assembler.h" | ||
#include "gnudirectives.h" | ||
#include "mipsrelocations.h" | ||
#include "ripessettings.h" | ||
|
||
#include <QByteArray> | ||
#include <algorithm> | ||
|
||
#include "rv_c_ext.h" | ||
#include "rv_m_ext.h" | ||
|
||
#include "mips_i_ext.h" | ||
|
||
namespace Ripes { | ||
namespace Assembler { | ||
|
||
MIPS32I_Assembler::MIPS32I_Assembler(const ISAInfo<ISA::MIPS32I> *isa) | ||
: Assembler<Reg_T>(isa) { | ||
auto [instrs, pseudos] = initInstructions(isa); | ||
|
||
auto directives = gnuDirectives(); | ||
auto relocations = mipsRelocations<Reg_T>(); | ||
initialize(instrs, pseudos, directives, relocations); | ||
|
||
// Initialize segment pointers and monitor settings changes to segment | ||
// pointers | ||
connect(RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_TEXTSTART), | ||
&SettingObserver::modified, this, [this](const QVariant &value) { | ||
setSegmentBase(".text", value.toULongLong() /*4194304*/); | ||
}); | ||
RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_TEXTSTART)->trigger(); | ||
connect(RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_DATASTART), | ||
&SettingObserver::modified, this, [this](const QVariant &value) { | ||
setSegmentBase(".data", /*value.toULongLong()*/ 268500992); | ||
}); | ||
RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_DATASTART)->trigger(); | ||
connect(RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_BSSSTART), | ||
&SettingObserver::modified, this, [this](const QVariant &value) { | ||
setSegmentBase(".bss", value.toULongLong()); | ||
}); | ||
RipesSettings::getObserver(RIPES_SETTING_ASSEMBLER_BSSSTART)->trigger(); | ||
} | ||
|
||
std::tuple<MIPS32I_Assembler::_InstrVec, MIPS32I_Assembler::_PseudoInstrVec> | ||
MIPS32I_Assembler::initInstructions(const ISAInfo<ISA::MIPS32I> *isa) const { | ||
_InstrVec instructions; | ||
_PseudoInstrVec pseudoInstructions; | ||
|
||
MIPS_I<Reg_T>::enable(isa, instructions, pseudoInstructions); | ||
return {instructions, pseudoInstructions}; | ||
} | ||
|
||
} // namespace Assembler | ||
} // namespace Ripes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <functional> | ||
|
||
#include "assembler.h" | ||
#include "rvassembler_common.h" | ||
|
||
namespace Ripes { | ||
namespace Assembler { | ||
|
||
class MIPS32I_Assembler : public QObject, public Assembler<uint32_t> { | ||
Q_OBJECT | ||
|
||
public: | ||
using Reg_T = uint32_t; | ||
MIPS32I_Assembler(const ISAInfo<ISA::MIPS32I> *isa); | ||
|
||
private: | ||
std::tuple<_InstrVec, _PseudoInstrVec> | ||
initInstructions(const ISAInfo<ISA::MIPS32I> *isa) const; | ||
|
||
protected: | ||
QChar commentDelimiter() const override { return '#'; } | ||
}; | ||
|
||
} // namespace Assembler | ||
} // namespace Ripes |
Oops, something went wrong.