-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.h
65 lines (45 loc) · 969 Bytes
/
vm.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
#define M_ROOT 0
#define M_CHILD 1
#define S_NRM 0
#define S_INT 1
#define S_OOG 2
#define S_IMA 3
#define S_IIE 4
#define I_ADD 0
#define I_ADDI 1
#define I_MUL 2
#define I_MULI 3
#define I_SET 4
#define I_JMP 5
#define I_JLE 6
#define I_INT 7
#define I_JIT 8
#define I_MLN 9
#define I_REM 10
#define I_RUN 11
#define I_LMT 12
#define I_OLDIP 13
#define I_INVALID 14
uint8_t INSTRUCTION_ARGS[] = {2,2,2,2,2,1,3,0,1,1,2,2,2,1};
const char *istrings[] = {"I_ADD", "I_ADDI", "I_MUL", "I_MULI", "I_SET", "I_JMP", "I_JLE", "I_INT", "I_JIT", "I_MLN", "I_REM", "I_RUN", "I_LMT", "I_OLDIP"};
typedef struct {
uint64_t start;
uint64_t length;
} Sector;
typedef struct {
uint64_t length;
uint64_t* data;
} Memory;
typedef struct {
uint8_t mode;
uint8_t state;
uint64_t ip;
uint64_t oldip;
uint8_t interrupt;
Memory* memory;
Memory* external_memory;
uint64_t gas;
Memory* gas_map;
uint64_t num_sectors;
Sector* memory_map;
} VM;