-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.inc
97 lines (85 loc) · 1.36 KB
/
defs.inc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
TITLE Constant definitions, Macro definition, Proto definitions and more!
SPACE = 20h
TAB = 9h
LF = 0Ah
STACK_MAX = 4096
HEAP_MAX = 4096
INS_MAX = 4096
ARG_MAX = 4096
OPNUM = 24
I_PUSH = 0
I_COPY = 1
I_SLIDE = 2
I_DUP = 3
I_SWAP = 4
I_DISCARD = 5
I_ADD = 6
I_SUB = 7
I_MUL = 8
I_DIV = 9
I_MOD = 10
I_STORE = 11
I_LOAD = 12
I_LABEL = 13
I_CALL = 14
I_JMP = 15
I_JZ = 16
I_JS = 17
I_RET = 18
I_END = 19
I_OCHAR = 20
I_ONUM = 21
I_ICHAR = 22
I_INUM = 23
M_GetChar TEXTEQU <INVOKE GetNextChar, fileHandle>
M_GetArg TEXTEQU <INVOKE GetArg, fileHandle>
ifSp MACRO val:REQ
cmp val, SPACE
ENDM
ifTb MACRO val:REQ
cmp val, TAB
ENDM
ifLf MACRO val:REQ
cmp val, LF
ENDM
GetNext MACRO lbl1:REQ, lbl2:REQ, lbl3:REQ
LOCAL Top
Top:
M_GetChar
jz Finished ; EOF
ifSp curTok ; Contents of buffer
je lbl1 ; Space read
ifTb curTok
je lbl2 ; Tab read
ifLf curTok
je lbl3 ; Lf read
jmp Top ; Non-token char
ENDM
PutIns MACRO val:REQ
push esi
mov esi, iCount
mov BYTE PTR insBuf[esi], val
inc iCount
pop esi
jmp IMP
ENDM
PutArg MACRO val:REQ
push esi
mov esi, aCount
mov DWORD PTR argBuf[esi * TYPE SDWORD], val
inc aCount
pop esi
ENDM
PutWithArg MACRO val:REQ
M_GetArg
jz Finished ; Error in reading argument
PutArg eax
PutIns val
ENDM
PutIA MACRO val:REQ
PutArg 0
PutIns val
ENDM
FetchArg MACRO reg
mov reg, argBuf[esi * 4]
ENDM