summaryrefslogtreecommitdiffhomepage
path: root/asm/assembler.h
diff options
context:
space:
mode:
Diffstat (limited to 'asm/assembler.h')
-rw-r--r--asm/assembler.h38
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;
+};
+