-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.h
38 lines (35 loc) · 1.15 KB
/
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
#ifndef NATOLANG_VM_H
#define NATOLANG_VM_H
#include <stdint.h>
enum {
/* opcodes w/ operand */
ARG, // load imm th function param to acc
ADJ, // adjust sp
IMM, // load immediate val to acc
J, // jump to immediate val
JS, // jump to immediate val and push pc to stack
JZ, // jump to immediate val if zero
JNZ, // jump to immediate val if not zero
ADI, SBI, MUI, DII, MDI, // math op w/ immediate val
EQI, NEI, GTI, LTI, GEI, LEI, // comp
ANI, ORI, // logic
/* opcodes w/o operand */
ADD, SUB, MUL, DIV, MOD, // math op
EQ, NE, GT, LT, GE, LE, // comp
AND, OR, NOT, // logic
LD, // load val at addr in acc to acc
SV, // save acc to stacktop addr
LA, // load acc th function param to acc
PSH, // push acc to stack
POP, // pop stack to acc
SRE, // end subroutine: restore fp & sp
SRS, // start subroutine: push fp on to stack, set fp to sp
PSI, // print stacktop value as int
PSC, // print stacktop value as char
PAI, // print acc value as int
PAC, // print acc value as char
GC, // get char to acc
EXT, // exit
NOP, // no-op
};
#endif // NATOLANG_VM_H