summaryrefslogtreecommitdiffhomepage
path: root/asm/assembler.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-10-17 17:37:50 +0200
committerRoland Reichwein <mail@reichwein.it>2020-10-17 17:37:50 +0200
commit7b49d17f90f26394a116348befb5edcdffcedcb6 (patch)
treec32e76a9bea5851bfac92708fa626373573e4f06 /asm/assembler.h
parentf86999e137f43372236f2dccd1fe3572a85c0dcd (diff)
Add ret and int
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;
+};
+