|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
#include "Assembleur.h"
|
|
|
|
#include "Assembleur.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdexcept>
|
|
|
|
@@ -79,11 +80,11 @@ std::uint32_t Assembleur::ParseOperationImmediate(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, const std::string& a_Label) {
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, const std::string& a_Label) {
|
|
|
|
return IToInt(a_Instruction) | ParseLabel(a_Label);
|
|
|
|
return IToInt(a_Instruction) | ParseLabel(a_Label) & 0x3FFFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label) {
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label) {
|
|
|
|
return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | ParseLabel(a_Label);
|
|
|
|
return IToInt(a_Instruction) | a_R1 << 23 | a_R2 << 20 | ParseLabel(a_Label) & 0xFFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
|
|
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
|
|
|
@@ -91,7 +92,7 @@ std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::uint32_t Assembleur::ParseIO(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_R3) {
|
|
|
|
std::uint32_t Assembleur::ParseIO(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_R3) {
|
|
|
|
return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | a_R3 << 18;
|
|
|
|
return IToInt(a_Instruction) | a_R1 << 23 | a_R2 << 20 | a_R3 << 17;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -122,6 +123,9 @@ std::uint32_t Assembleur::ParseInstruction(const std::string& a_Str, std::uint32
|
|
|
|
std::string ins;
|
|
|
|
std::string ins;
|
|
|
|
ss >> ins;
|
|
|
|
ss >> ins;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// to lower case
|
|
|
|
|
|
|
|
std::transform(ins.begin(), ins.end(), ins.begin(), [](unsigned char c) { return std::tolower(c); });
|
|
|
|
|
|
|
|
|
|
|
|
auto it = INSTRUCTION_KEYS.find(ins);
|
|
|
|
auto it = INSTRUCTION_KEYS.find(ins);
|
|
|
|
if (it == INSTRUCTION_KEYS.end()) {
|
|
|
|
if (it == INSTRUCTION_KEYS.end()) {
|
|
|
|
throw std::invalid_argument("[Line " + std::to_string(a_RealLine) + "] " + "Instruction \"" + ins + "\" not found !");
|
|
|
|
throw std::invalid_argument("[Line " + std::to_string(a_RealLine) + "] " + "Instruction \"" + ins + "\" not found !");
|
|
|
|
|