diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-20 10:59:18 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-20 10:59:18 +0100 |
commit | 7250bbe5ae2d2ee6b0334bc462aab73f7d8dac0e (patch) | |
tree | b910e778baa3e2434215abbb50e45e64aa92970c /asm/assembler.h | |
parent | 05faf77202d0f8762160f135e714961d2c456cca (diff) |
Assembler bugfixes - tests run successfully now
Diffstat (limited to 'asm/assembler.h')
-rw-r--r-- | asm/assembler.h | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/asm/assembler.h b/asm/assembler.h index ea23fbc..8cdaa31 100644 --- a/asm/assembler.h +++ b/asm/assembler.h @@ -28,18 +28,21 @@ public: { public: Immediate8(uint8_t value): m_value(value) {} - uint8_t value() {return m_value;} + uint8_t value() const {return m_value;} std::vector<uint8_t> getCode() {return {m_value};}; private: uint8_t m_value; }; + class Immediate64; + class Immediate32 { public: Immediate32(uint32_t value): m_value(value) {} - uint32_t value() { return m_value; } + Immediate32(const Immediate64&); ///< Convert from Immediate64 if data is small enough + uint32_t value() const { return m_value; } std::vector<uint8_t> getCode() { std::vector<uint8_t> result(size_t(4)); *(reinterpret_cast<uint32_t*>(result.data())) = boost::endian::native_to_little(m_value); @@ -54,7 +57,7 @@ public: { public: Immediate64(uint64_t value): m_value(value) {} - uint64_t value() { return m_value; } + uint64_t value() const { return m_value; } std::vector<uint8_t> getCode() { std::vector<uint8_t> result(size_t(8)); *(reinterpret_cast<uint64_t*>(result.data())) = boost::endian::native_to_little(m_value); @@ -69,7 +72,7 @@ public: { public: Register8(const std::string& name): m_name(name) {} - std::string name() { return m_name; } + std::string name() const { return m_name; } private: std::string m_name; @@ -79,7 +82,7 @@ public: { public: Register32(const std::string& name): m_name(name) {} - std::string name() { return m_name; } + std::string name() const { return m_name; } private: std::string m_name; @@ -89,7 +92,7 @@ public: { public: Register64(const std::string& name): m_name(name) {} - std::string name() { return m_name; } + std::string name() const { return m_name; } private: std::string m_name; @@ -100,10 +103,10 @@ public: { public: Mem8Ptr64(const std::string& reg, int32_t offs = 0): m_reg(reg), m_offs(offs) {} - Mem8Ptr64(const std::string& reg, const std::string& reg2 = ""s, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} - std::string reg() { return m_reg; } - std::string reg2() { return m_reg2; } - int32_t offs() { return m_offs; } + Mem8Ptr64(const std::string& reg, const std::string& reg2, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} + std::string reg() const { return m_reg; } + std::string reg2() const { return m_reg2; } + int32_t offs() const { return m_offs; } private: std::string m_reg; @@ -116,10 +119,10 @@ public: { public: Mem32Ptr64(const std::string& reg, int32_t offs = 0): m_reg(reg), m_offs(offs) {} - Mem32Ptr64(const std::string& reg, const std::string& reg2 = ""s, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} - std::string reg() { return m_reg; } - std::string reg2() { return m_reg2; } - int32_t offs() { return m_offs; } + Mem32Ptr64(const std::string& reg, const std::string& reg2, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} + std::string reg() const { return m_reg; } + std::string reg2() const { return m_reg2; } + int32_t offs() const { return m_offs; } private: std::string m_reg; @@ -132,10 +135,10 @@ public: { public: Mem64Ptr64(const std::string& reg, int32_t offs = 0): m_reg(reg), m_offs(offs) {} - Mem64Ptr64(const std::string& reg, const std::string& reg2 = ""s, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} - std::string reg() { return m_reg; } - std::string reg2() { return m_reg2; } - int32_t offs() { return m_offs; } + Mem64Ptr64(const std::string& reg, const std::string& reg2, int32_t offs = 0): m_reg(reg), m_reg2(reg2), m_offs(offs) {} + std::string reg() const { return m_reg; } + std::string reg2() const { return m_reg2; } + int32_t offs() const { return m_offs; } private: std::string m_reg; @@ -147,7 +150,7 @@ public: { public: Label(const std::string& name): m_name(name) {} - std::string name() { return m_name; } + std::string name() const { return m_name; } private: std::string m_name; |