#pragma once #include #include #include #include #include "Token.h" class Instruction; class Architecture; class Compiler; class Language; typedef ehs::Serializer (*TranslateIns)(const Instruction *, const ehs::Byte *); class EHS_LIB_IO Instruction { private: friend class Architecture; Architecture *arch; ehs::UInt_64 id; ehs::Str_8 name; TranslateIns translation; public: Instruction(); Instruction(ehs::Str_8 name); Instruction(Instruction &&ins) noexcept; Instruction(const Instruction &ins); Instruction &operator=(Instruction &&ins) noexcept; Instruction &operator=(const Instruction &ins); const Architecture *GetArchitecture() const; ehs::UInt_64 GetId() const; ehs::Str_8 GetName() const; void SetTranslation(TranslateIns newTranslation); ehs::Serializer Translate(const ehs::Byte *data) const; }; struct AssignBase { const ehs::UInt_8 type = 0; }; struct AssignRR { AssignBase base = { 1 }; bool isDstAddress = false; ehs::UInt_64 dstReg = 0; bool isSrcAddress = false; ehs::UInt_64 srcReg = 0; }; struct AssignRI { AssignBase base = { 2 }; ehs::UInt_64 dstReg = 0; ehs::UInt_64 srcImm = 0; };