-
Notifications
You must be signed in to change notification settings - Fork 14
/
vm.h
36 lines (29 loc) · 788 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
#ifndef VM_H_
#define VM_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
NOOP = 0,
IADD = 1, // int add
ISUB = 2,
IMUL = 3,
ILT = 4, // int less than
IEQ = 5, // int equal
BR = 6, // branch
BRT = 7, // branch if true
BRF = 8, // branch if true
ICONST = 9, // push constant integer
LOAD = 10, // load from local context
GLOAD = 11, // load from global memory
STORE = 12, // store in local context
GSTORE = 13, // store in global memory
PRINT = 14, // print stack top
POP = 15, // throw away top of stack
HALT = 16
} VM_CODE;
void vm_exec(int *code, int count, int startip, int nglobals, int trace);
#ifdef __cplusplus
}
#endif
#endif