summaryrefslogtreecommitdiffhomepage
path: root/asm
diff options
context:
space:
mode:
Diffstat (limited to 'asm')
-rw-r--r--asm/assembler.cpp10
-rw-r--r--asm/assembler.h6
-rw-r--r--asm/chunk.h2
3 files changed, 15 insertions, 3 deletions
diff --git a/asm/assembler.cpp b/asm/assembler.cpp
index 7a9f6cf..d6ab230 100644
--- a/asm/assembler.cpp
+++ b/asm/assembler.cpp
@@ -49,3 +49,13 @@ std::shared_ptr<Op> makeOp(const std::string& mnemonic)
AsmArgs dummy; // empty list of arguments
return makeOp(mnemonic, dummy);
}
+
+std::shared_ptr<Label> makeLabel(const std::string& name)
+{
+ return std::make_shared<Label>(name);
+}
+
+std::shared_ptr<Data> makeData(const std::vector<uint8_t>& data)
+{
+ return std::make_shared<Data>(data);
+}
diff --git a/asm/assembler.h b/asm/assembler.h
index 42b5f8d..ddea4af 100644
--- a/asm/assembler.h
+++ b/asm/assembler.h
@@ -1,7 +1,6 @@
#pragma once
-//#include "chunk.h"
-//#include "segment.h"
+#include "chunk.h"
#include <any>
#include <functional>
@@ -23,6 +22,9 @@ 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);
+std::shared_ptr<Label> makeLabel(const std::string& name);
+std::shared_ptr<Data> makeData(const std::vector<uint8_t>& data);
+
template<typename T>
std::string mangleNameOne(const std::string& s)
{
diff --git a/asm/chunk.h b/asm/chunk.h
index 723e711..cc45ea9 100644
--- a/asm/chunk.h
+++ b/asm/chunk.h
@@ -29,7 +29,7 @@ private:
class Data: public Chunk
{
public:
- Data(std::vector<uint8_t> data): m_data(data) {}
+ Data(const std::vector<uint8_t>& data): m_data(data) {}
virtual ~Data(){}
std::vector<uint8_t> getCode() override