From 7250bbe5ae2d2ee6b0334bc462aab73f7d8dac0e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 20 Nov 2020 10:59:18 +0100 Subject: Assembler bugfixes - tests run successfully now --- asm/assembler.h | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'asm/assembler.h') 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 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 getCode() { std::vector result(size_t(4)); *(reinterpret_cast(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 getCode() { std::vector result(size_t(8)); *(reinterpret_cast(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; -- cgit v1.2.3