From 7b49d17f90f26394a116348befb5edcdffcedcb6 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 17 Oct 2020 17:37:50 +0200 Subject: Add ret and int --- asm/assembler.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'asm/assembler.h') 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 #include @@ -9,11 +10,19 @@ #include #include -using AsmArgs = std::vector; // 0th element is mnemonic +using AsmArgs = std::vector; using FactoryFunction = std::function(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 makeOp(const std::string& mnemonic, AsmArgs& args); + +// overload for empty list of arguments +std::shared_ptr makeOp(const std::string& mnemonic); + template std::string mangleNameOne(const std::string& s) { @@ -29,3 +38,15 @@ std::string mangleName(const std::string& s) return mangleName(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; +}; + -- cgit v1.2.3