-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassembunny.hpp
More file actions
66 lines (48 loc) · 808 Bytes
/
assembunny.hpp
File metadata and controls
66 lines (48 loc) · 808 Bytes
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
#include <iostream>
#include <map>
#include <vector>
enum ParamType { Reg, Imm };
struct Param {
ParamType t{Reg};
int v{' '};
};
class Assembunny;
struct Instruction {
Assembunny* interpreter{nullptr};
char c{'-'};
Param p[2];
int&
reg(int);
int
val(int);
};
class Assembunny {
std::map<char, int> regs;
std::vector<Instruction> ins;
std::string out;
int outLimit{INT_MAX};
char
invert(char);
public:
Assembunny(std::istream& is);
Assembunny&
optAdd();
Assembunny&
optMul();
Assembunny&
optRemoveInfiniteLoops();
Assembunny&
run();
int
get(char);
int&
ref(char);
Assembunny&
set(char, int);
Assembunny&
setOutputBufferLimit(int);
std::string
getOuputBuffer();
Assembunny&
clearOutputBuffer();
};