diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-10-17 21:45:37 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-10-17 21:45:37 +0200 |
commit | 8f28495ab9a8ebf53868405541e907394895e51f (patch) | |
tree | 51b27870ed64522e1d54e4f031276e18fe181ee8 /asm/assembler.h | |
parent | 72ff79d76c7ec16ea1b95c72af0838f0e1150735 (diff) |
Add add
Diffstat (limited to 'asm/assembler.h')
-rw-r--r-- | asm/assembler.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/asm/assembler.h b/asm/assembler.h index ddea4af..3d3e9a9 100644 --- a/asm/assembler.h +++ b/asm/assembler.h @@ -2,6 +2,8 @@ #include "chunk.h" +#include <boost/endian/conversion.hpp> + #include <any> #include <functional> #include <iostream> @@ -47,8 +49,44 @@ class Immediate8 public: Immediate8(uint8_t value): m_value(value) {} uint8_t value() {return m_value;} + std::vector<uint8_t> getCode() {return {m_value};}; private: uint8_t m_value; }; +class Immediate32 +{ +public: + Immediate32(uint32_t value): m_value(value) {} + uint32_t value() { 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); + return result; + }; + +private: + uint32_t m_value; +}; + +class Register32 +{ +public: + Register32(const std::string& name): m_name(name) {} + std::string name() { return m_name; } + +private: + std::string m_name; +}; + +class Register64 +{ +public: + Register64(const std::string& name): m_name(name) {} + std::string name() { return m_name; } + +private: + std::string m_name; +}; + |