Memory added plus basic memory operations

This commit is contained in:
2019-11-23 14:53:56 +01:00
parent 99f616e1e4
commit 22bb974a05
17 changed files with 232 additions and 68 deletions

19
include/execute/error.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
namespace Execute
{
struct RuntimeError
{
};
struct StackUnderflow : RuntimeError
{
};
struct StackOverflow : RuntimeError
{
};
}

View File

@@ -11,7 +11,9 @@ namespace Execute
unsigned nextStatement;
std::unordered_map<std::string, unsigned> const & labelStatementIndice;
std::vector<InterruptFn> const interrupts;
std::vector<std::uint8_t> memory;
unsigned stackPointer;
State(std::unordered_map<std::string, unsigned> const & labelStatementIndice);
State(std::unordered_map<std::string, unsigned> const & labelStatementIndice, unsigned const memorySize);
};
}

View File

@@ -17,6 +17,8 @@ namespace Execute
void Step();
VirtualMachine(Interpret::Code const & code, unsigned const memorySize);
public:
void Run();
void SingleStep();
@@ -28,6 +30,6 @@ namespace Execute
bool IsTerminated() const;
VirtualMachine(Interpret::Code const & code);
static VirtualMachine CreateFromCode(Interpret::Code const & code);
};
}