-
Notifications
You must be signed in to change notification settings - Fork 0
/
A9M.inc
259 lines (171 loc) · 3.26 KB
/
A9M.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
; --- * --- * ---
; A9M
; The [AR]cane-[9I]ne [MA]chine,
; or [ANIMA],
; and sometimes [A9MA]
;
; LIBRE SOFTWARE
; Licensed under GNU GPL3
; be a bro and inherit
;
; CONTRIBUTORS
; lyeb,
; --- * --- * ---
; deps
library ARPATH '/forge/'
use '.inc' A9M::vmem
use '.inc' A9M::vcstring
use '.inc' A9M::vhash
library.import
; --- * --- * ---
; info
TITLE A9M
VERSION v0.00.6b
AUTHOR 'IBN-3DILA'
; --- * --- * ---
; ROM
if ~ defined A9M.ROMPATH
define A9M.ROMPATH "%ARPATH%/forge/A9M/ROM/"
end if
; --- * --- * ---
; GBL
IO.CTAGIT A9MTAG,'35;1','A9M'
; ^name of interpreter
define A9M.ipret
; for use by all ;>
A9M.debug = 0
; --- * --- * ---
; makes conditions with
; expanded symbols
macro A9M.make_chk base,name,[item] {
common
define A9M.#base#.chk.#name
forward match any , item \{
spacecat A9M.#base#.chk.#name,any
\}
}
; --- * --- * ---
; insert I/O code
library ARPATH '/forge/'
use '.inc' A9M::SHARE::OUTBUF
library.import
; --- * --- * ---
; insert memory levels code
library ARPATH '/forge/'
use '.inc' A9M::L0
use '.inc' A9M::L1
use '.inc' A9M::L2
use '.inc' A9M::FE
library.import
; --- * --- * ---
; reset default clan state
macro A9M.reset {
A9M.L0.reset
A9M.L1.reset
A9M.L2.reset
}
; --- * --- * ---
; read into virtual
;
; TODO:
;
; * read pehead
;
; * read pescap
;
; * strip comments
;
; * string scap
macro A9M.read fpath?= {
; fpath passed as arg?
match any , fpath? \{
define A9M.FPATH any
\}
; ^ensure we *have* a file!
match , A9M.FPATH \{
display $0A,A9MTAG,\
'missing read input'
err
\}
; setup
A9M.reset
; read file into vmem
vmem.orc A9M.FSRC,A9M.FPATH
; ^decl out file
vmem.owc A9M.FDST,'p3',blk $00
; ^dbout
if A9M.debug
out@EX $0A,A9MTAG,\
~IO.FILEIT A9M.FPATH,IO.comma
match id , A9M.FSRC \{
hexsay id\#.len,32
\}
display ' bytes',$0A,$0A
end if
; consume file and clear
A9M.L0.orc
A9M.FPATH equ
; invoke footer
match buffers , A9M.$$ \{
A9M.foot buffers
\}
}
; --- * --- * ---
; exec at end of program
; generally used as a final
; write to out
macro A9M.foot [buff] {
; invoke module footers
common
; perform final write
forward match id , buff \{
; match dst , A9M.FDST \\{
; hexsay dst\\#.ptr,$10
; out@nl
;
; \\}
vmem.bstore A9M.FDST,id\#.size,dword
vmem.align A9M.FDST
vmem.write A9M.FDST,ptr buff
vmem.align A9M.FDST
\}
; dbout
common if A9M.debug
display $0A,'__________________',$0A,$0A
display 'fout:',$0A
vmem.bprich A9M.FDST,1
err
end if
}
; --- * --- * ---
; debug out
macro A9M.dbout ct& {
; ^optionally cout ;>
if A9M.debug
display ct
end if
}
; --- * --- * ---
; ^outs ident lvl
macro A9M.dbout.nest_pad {
repeat A9M.L0.fulnest
A9M.dbout '. '
end repeat
}
; --- * --- * ---
; ^outs branch beg
macro A9M.dbout.branch ct& {
match any , ct \{
A9M.dbout '\-->',ct
\}
match , ct \{
A9M.dbout '\-->'
\}
}
; --- * --- * ---
; ^combo
macro A9M.dbout.nest_branch ct& {
A9M.dbout.nest_pad
A9M.dbout.branch ct
}
; --- * --- * ---