43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
enum TypeInstruction : std::uint8_t {
|
|
Arithmetique = 0,
|
|
Memoire = 1,
|
|
SautControle = 3,
|
|
};
|
|
|
|
struct Instruction {
|
|
TypeInstruction m_Instruction;
|
|
std::uint8_t m_SubInstruction;
|
|
};
|
|
|
|
class Assembleur {
|
|
private:
|
|
std::map<std::string, std::uint32_t> m_Labels;
|
|
|
|
public:
|
|
void AddLabel(const std::string& a_Label, std::uint32_t a_Line);
|
|
|
|
std::uint32_t ParseInstruction(const std::string& a_Str, std::uint32_t a_Line, std::uint32_t a_RealLine);
|
|
|
|
private:
|
|
std::uint32_t ParseLabel(const std::string& a_Label);
|
|
|
|
std::uint32_t IToInt(Instruction a_Instruction);
|
|
|
|
std::uint32_t ParseOperation(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_R3);
|
|
|
|
std::uint32_t ParseOperationImmediate(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_C1);
|
|
|
|
std::uint32_t ParseJump(Instruction a_Instruction, const std::string& a_Label);
|
|
|
|
std::uint32_t ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label);
|
|
|
|
std::uint32_t ParseJump(Instruction a_Instruction);
|
|
|
|
std::uint32_t ParseIO(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2);
|
|
}; |