-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemStore.h
69 lines (58 loc) · 1.55 KB
/
MemStore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include "Pch.h"
#include "Utilities.h"
#include "RegisterError.h"
#include "StackError.h"
#include "Opcode.h"
class Opcode;
//Flags register settings
struct Flags {
bool CF;
bool ZF;
bool SF;
bool OF;
bool PF;
bool AF;
bool IF;
bool DF;
};
/*
* This class managed all the Interpreter memory, such as Registers etc...
*/
class MemStore {
public:
MemStore();
void setRegister(string reg, unsigned int value);
unsigned int getRegister(string reg);
int getRegisterSize(string reg);
bool isRegister(string reg);
void push(unsigned int value);
unsigned int pop();
void cleanFlags();
void addToHistory(Opcode* opcode, string line);
void removeFromHistory();
Opcode* getFromHistory(unsigned int place);
void incEIP();
void editValue(string name, unsigned int value);
unsigned int getValue(string name);
int getValueSize(string name);
void checkSize(string name_1, string name_2);
void printMemory();
void printHistory();
void jmp(unsigned int place);
void addIdentifier(string name, unsigned int value);
unsigned int getIdentifier(string name);
bool isID(string name);
void addVar(string name, unsigned int value, int size);
tuple<int, unsigned int> getVar(string name);
void setVar(string name, unsigned int value);
int getVarSize(string name);
bool isVar(string name);
struct Flags _flags;
private:
map<tuple<string, string, string, string>, unsigned int> _registers;
vector<unsigned int> _stack;
vector<tuple<Opcode*, string>> _history;
map<string, unsigned int> _identifiers;
map<string, tuple<int, unsigned int>> _variables;
};