summaryrefslogtreecommitdiffhomepage
path: root/asm/assembler.h
diff options
context:
space:
mode:
Diffstat (limited to 'asm/assembler.h')
-rw-r--r--asm/assembler.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/asm/assembler.h b/asm/assembler.h
index b9c39a6..42b5f8d 100644
--- a/asm/assembler.h
+++ b/asm/assembler.h
@@ -1,6 +1,7 @@
#pragma once
-#include "chunk.h"
+//#include "chunk.h"
+//#include "segment.h"
#include <any>
#include <functional>
@@ -9,11 +10,19 @@
#include <string>
#include <unordered_map>
-using AsmArgs = std::vector<std::any>; // 0th element is mnemonic
+using AsmArgs = std::vector<std::any>;
using FactoryFunction = std::function<std::shared_ptr<Op>(AsmArgs&)>;
+// mnemonic: mnemonic including argument types
bool registerOp(const std::string& mnemonic, FactoryFunction f);
+// Create Op from a registered mnemonic
+// mnemonic: just the mnemonic name
+std::shared_ptr<Op> makeOp(const std::string& mnemonic, AsmArgs& args);
+
+// overload for empty list of arguments
+std::shared_ptr<Op> makeOp(const std::string& mnemonic);
+
template<typename T>
std::string mangleNameOne(const std::string& s)
{
@@ -29,3 +38,15 @@ std::string mangleName(const std::string& s)
return mangleName<Targs...>(s + "_" + typeid(T).name());
}
+std::string mangleName(const std::string& s, AsmArgs& args);
+
+class Immediate8
+{
+public:
+ Immediate8(uint8_t value): m_value(value) {}
+ uint8_t value() {return m_value;}
+
+private:
+ uint8_t m_value;
+};
+