Basic arithmetic and jump labels
This commit is contained in:
9
include/execute/flags.hpp
Normal file
9
include/execute/flags.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace Execute
|
||||
{
|
||||
struct Flags
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
19
include/execute/registers.hpp
Normal file
19
include/execute/registers.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
namespace Execute
|
||||
{
|
||||
struct Registers
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
int A;
|
||||
int B;
|
||||
int C;
|
||||
int D;
|
||||
};
|
||||
int registers[4];
|
||||
};
|
||||
};
|
||||
}
|
||||
16
include/execute/state.hpp
Normal file
16
include/execute/state.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Execute
|
||||
{
|
||||
struct State
|
||||
{
|
||||
unsigned currentStatement;
|
||||
unsigned nextStatement;
|
||||
std::unordered_map<std::string, unsigned> const & labelStatementIndice;
|
||||
|
||||
|
||||
State(std::unordered_map<std::string, unsigned> const & labelStatementIndice);
|
||||
};
|
||||
}
|
||||
33
include/execute/virtualmachine.hpp
Normal file
33
include/execute/virtualmachine.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <execute/flags.hpp>
|
||||
#include <execute/registers.hpp>
|
||||
#include <execute/state.hpp>
|
||||
#include <interpret/code.hpp>
|
||||
|
||||
namespace Execute
|
||||
{
|
||||
class VirtualMachine
|
||||
{
|
||||
private:
|
||||
Flags flags;
|
||||
Registers registers;
|
||||
State state;
|
||||
bool terminated;
|
||||
|
||||
Interpret::Code const & code;
|
||||
|
||||
void Step();
|
||||
|
||||
public:
|
||||
void Run();
|
||||
void SingleStep();
|
||||
|
||||
Flags const & GetFlags() const;
|
||||
Registers const & GetRegisters() const;
|
||||
State const & GetState() const;
|
||||
Interpret::Statement const * const GetCurrentStatement() const;
|
||||
|
||||
bool IsTerminated() const;
|
||||
|
||||
VirtualMachine(Interpret::Code const & code);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user