diff --git a/src/ast/nodes/RegNode.cpp b/src/ast/nodes/RegNode.cpp new file mode 100644 index 0000000..fc88e33 --- /dev/null +++ b/src/ast/nodes/RegNode.cpp @@ -0,0 +1,15 @@ +// +// Created by christoph on 21.03.23. +// + +#include "RegNode.h" + +RegNode::RegNode(uint8_t reg) : reg(reg) {} + +auto RegNode::compile() const -> uint8_t { + if (reg > 0b110) { + throw "Compile Error: Invalid Register!"; + } + + return reg; +} diff --git a/src/ast/nodes/RegNode.h b/src/ast/nodes/RegNode.h new file mode 100644 index 0000000..0833d03 --- /dev/null +++ b/src/ast/nodes/RegNode.h @@ -0,0 +1,22 @@ +// +// Created by christoph on 21.03.23. +// + +#ifndef LOGISIMASSEMBLER_REGNODE_H +#define LOGISIMASSEMBLER_REGNODE_H + +#include "../Node.h" + +class RegNode : public Node { +public: + RegNode(uint8_t reg); + + ~RegNode() override = default; + + [[nodiscard]] auto compile() const -> uint8_t override; + +private: + uint8_t reg; +}; + +#endif //LOGISIMASSEMBLER_REGNODE_H diff --git a/src/ast/nodes/RootNode.cpp b/src/ast/nodes/RootNode.cpp new file mode 100644 index 0000000..82fa134 --- /dev/null +++ b/src/ast/nodes/RootNode.cpp @@ -0,0 +1,9 @@ +// +// Created by christoph on 21.03.23. +// + +#include "RootNode.h" + +auto RootNode::compile() const -> uint8_t { + return 0; +} diff --git a/src/ast/nodes/RootNode.h b/src/ast/nodes/RootNode.h new file mode 100644 index 0000000..1416acb --- /dev/null +++ b/src/ast/nodes/RootNode.h @@ -0,0 +1,19 @@ +// +// Created by christoph on 21.03.23. +// + +#ifndef LOGISIMASSEMBLER_ROOTNODE_H +#define LOGISIMASSEMBLER_ROOTNODE_H + +#include "../Node.h" + +class RootNode : public Node { +public: + RootNode() = default; + + ~RootNode() override = default; + + [[nodiscard]] auto compile() const -> uint8_t override; +}; + +#endif //LOGISIMASSEMBLER_ROOTNODE_H