summaryrefslogtreecommitdiffhomepage
path: root/asm/assembler.h
diff options
context:
space:
mode:
Diffstat (limited to 'asm/assembler.h')
-rw-r--r--asm/assembler.h77
1 files changed, 52 insertions, 25 deletions
diff --git a/asm/assembler.h b/asm/assembler.h
index 1fdc658..12e7c4e 100644
--- a/asm/assembler.h
+++ b/asm/assembler.h
@@ -6,8 +6,6 @@
#include "../minicc.h"
-#include <boost/endian/conversion.hpp>
-
#include <any>
#include <functional>
#include <iostream>
@@ -27,27 +25,34 @@ public:
class Immediate8
{
public:
- Immediate8(uint8_t value): m_value(value) {}
- uint8_t value() const {return m_value;}
- std::vector<uint8_t> getCode() {return {m_value};};
+ Immediate8(uint8_t value);
+ uint8_t value() const;
+ std::vector<uint8_t> getCode() const;
private:
uint8_t m_value;
};
+ class Immediate16
+ {
+ public:
+ Immediate16(uint16_t value);
+ uint16_t value() const;
+ std::vector<uint8_t> getCode() const;
+
+ private:
+ uint16_t m_value;
+ };
+
class Immediate64;
class Immediate32
{
public:
- Immediate32(uint32_t value): m_value(value) {}
+ Immediate32(uint32_t 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);
- return result;
- };
+ uint32_t value() const;
+ std::vector<uint8_t> getCode() const;
private:
uint32_t m_value;
@@ -56,13 +61,9 @@ public:
class Immediate64
{
public:
- Immediate64(uint64_t value): m_value(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);
- return result;
- };
+ Immediate64(uint64_t value);
+ uint64_t value() const;
+ std::vector<uint8_t> getCode() const;
private:
uint64_t m_value;
@@ -71,8 +72,18 @@ public:
class Register8
{
public:
- Register8(const std::string& name): m_name(name) {}
- std::string name() const { return m_name; }
+ Register8(const std::string& name);
+ std::string name() const;
+
+ private:
+ std::string m_name;
+ };
+
+ class Register16
+ {
+ public:
+ Register16(const std::string& name);
+ std::string name() const;
private:
std::string m_name;
@@ -81,8 +92,8 @@ public:
class Register32
{
public:
- Register32(const std::string& name): m_name(name) {}
- std::string name() const { return m_name; }
+ Register32(const std::string& name);
+ std::string name() const;
private:
std::string m_name;
@@ -91,8 +102,8 @@ public:
class Register64
{
public:
- Register64(const std::string& name): m_name(name) {}
- std::string name() const { return m_name; }
+ Register64(const std::string& name);
+ std::string name() const;
private:
std::string m_name;
@@ -114,6 +125,22 @@ public:
int32_t m_offs;
};
+ // 64 bit Ptr to 16 bit Memory
+ class Mem16Ptr64
+ {
+ public:
+ Mem16Ptr64(const std::string& reg, int32_t offs = 0);
+ Mem16Ptr64(const std::string& reg, const std::string& reg2, int32_t offs = 0);
+ std::string reg() const;
+ std::string reg2() const;
+ int32_t offs() const;
+
+ private:
+ std::string m_reg;
+ std::string m_reg2;
+ int32_t m_offs;
+ };
+
// 64 bit Ptr to 32 bit Memory
class Mem32Ptr64
{