diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-10-17 17:54:20 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-10-17 17:54:20 +0200 |
commit | 72ff79d76c7ec16ea1b95c72af0838f0e1150735 (patch) | |
tree | 88cd1f3aaf7138c685d89df470ccf7613eae4716 /asm | |
parent | 7b49d17f90f26394a116348befb5edcdffcedcb6 (diff) |
Handle Labels and Data
Diffstat (limited to 'asm')
-rw-r--r-- | asm/assembler.cpp | 10 | ||||
-rw-r--r-- | asm/assembler.h | 6 | ||||
-rw-r--r-- | asm/chunk.h | 2 |
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 |