cleanup, compilation semantics
[watForth.git] / forth.wat
1 (; This program is free software: you can redistribute it and/or modify
2 it under the terms of the GNU General Public License as published by
3 the Free Software Foundation, either version 3 of the License, or
4 (at your option) any later version.
5
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10
11 You should have received a copy of the GNU General Public License
12 along with this program. If not, see <http://www.gnu.org/licenses/>. ;)
13 (module
14 (type $FUNCSIGi (func (result i32)))
15 (type $FUNCSIGii (func (param i32)))
16 (type $FUNCSIGiii (func))
17 (type $FUNCSIGiv (func (param i32 i32) (result i32)))
18 (type $FUNCSIGv (func (param i32) (result i32)))
19 (type $FUNCSIGvi (func (param i32 i32 i32) (result i32)))
20 (type $FUNCSIGvii (func (param i32 i32)))
21 (type $FUNCSIGviii (func (param i32 i32 i32)))
22 (import "env" "pop" (func $pop (result i32)))
23 (import "env" "push" (func $push (param i32)))
24 (import "env" "rinit" (func $rinit))
25 (import "env" "rpop" (func $rpop (result i32)))
26 (import "env" "rpush" (func $rpush (param i32)))
27 (import "env" "sys_read" (func $sys_read (param i32 i32 i32) (result i32)))
28 (import "env" "sys_fetch" (func $sys_fetch (param i32 i32) (result i32)))
29 (import "env" "sys_listen" (func $sys_listen (param i32) (result i32)))
30 (import "env" "sys_write" (func $sys_write (param i32 i32 i32) (result i32)))
31 (import "env" "sys_echo" (func $sys_echo (param i32 i32)))
32 (import "env" "sys_echochar" (func $sys_echochar (param i32)))
33 (import "env" "sys_reflect" (func $sys_reflect (param i32)))
34 (import "env" "vocab_get" (func $vocab_get (param i32 i32) (result i32)))
35 (import "env" "vocab_set" (func $vocab_set (param i32 i32 i32)))
36 (import "env" "does_get" (func $does_get (param i32 i32) (result i32)))
37 (import "env" "does_set" (func $does_set (param i32 i32 i32)))
38 (import "env" "is_whitespace" (func $is_whitespace (param i32) (result i32)))
39 (import "env" "sys_parsenum" (func $sys_parsenum (param i32 i32 i32) (result i32)))
40 (import "env" "sys_stack" (func $sys_stack))
41 (import "env" "sys_words" (func $sys_words))
42 (table (;0;) 0 anyfunc)
43 (memory $0 1)
44 (; String Belt ;) ;; 0x0000 Size: 8192
45 (global $wordbelt i32 (i32.const 8192)) ;; 0x2000 Size: 4096
46 (global $inbuf i32 (i32.const 12288)) ;; 0x3000 Size: 2048
47 (global $inbuf_size i32 (i32.const 12292))
48 (global $inbuf_data i32 (i32.const 12296))
49 (global $kvars i32 (i32.const 14336)) ;; 0x3800 Size: 2048
50 (data (i32.const 12288) "\f8\07\00\00") ;; 2040 len
51 (data (i32.const 14336) "\28\41\00\00") ;; MODE
52 (data (i32.const 14340) "\04\42\00\00") ;; HERE
53 (data (i32.const 14344) "\00\40\00\00") ;; START (16384) (Quit)
54 (data (i32.const 14348) "\0a\00\00\00") ;; BASE
55 (data (i32.const 14352) "\00\00\00\00") ;; STRINGBELT_TAIL
56 (data (i32.const 14356) "\00\00\00\00") ;; STRINGBELT_HEAD
57 (data (i32.const 14360) "\00\20\00\00") ;; WORDBELT_TAIL
58 (data (i32.const 14364) "\00\20\00\00") ;; WORDBELT_HEAD
59 (data (i32.const 14368) "\00\00\00\00") ;; CHANNEL
60 (; Quit ;)
61 (data (i32.const 16384) "\03\00\00\00") ;; RINIT xt
62 (data (i32.const 16388) "\10\40\00\00") ;; INTERPRET xt
63 (data (i32.const 16392) "\12\00\00\00") ;; JMP xt
64 (data (i32.const 16396) "\00\40\00\00") ;; quit location (16384)
65 (; Interpret ;)
66 (data (i32.const 16400) "\74\40\00\00") ;; WORD xt (16500)
67 (data (i32.const 16404) "\06\00\00\00") ;; DUP
68 (data (i32.const 16408) "\0e\00\00\00") ;; JZ:
69 (data (i32.const 16412) "\38\40\00\00") ;; INTERP-END addr (16444)
70 (data (i32.const 16416) "\02\00\00\00") ;; LIT xt
71 (data (i32.const 16420) "\00\38\00\00") ;; MODE addr (14336)
72 (data (i32.const 16424) "\0a\00\00\00") ;; @ (fetch) xt
73 (data (i32.const 16428) "\0c\00\00\00") ;; EXECUTE xt
74 (data (i32.const 16432) "\0d\00\00\00") ;; NOOP xt
75 (data (i32.const 16436) "\01\00\00\00") ;; RET
76 (data (i32.const 16440) "\10\00\00\00") ;; DROP <-- INTERP-END
77 (data (i32.const 16444) "\10\00\00\00") ;; DROP
78 (data (i32.const 16448) "\19\00\00\00") ;; BYE
79 (; Word ;)
80 (data (i32.const 16500) "\14\00\00\00") ;; WORDSTART
81 (data (i32.const 16504) "\05\00\00\00") ;; KEY <-- KEYLOOP
82 (data (i32.const 16508) "\06\00\00\00") ;; DUP
83 (data (i32.const 16512) "\18\00\00\00") ;; J-1: 18
84 (data (i32.const 16516) "\f0\40\00\00") ;; addr of WORDEND
85 (data (i32.const 16520) "\11\00\00\00") ;; WS?
86 (data (i32.const 16524) "\0f\00\00\00") ;; JNZ:
87 (data (i32.const 16528) "\bc\40\00\00") ;; addr of KEYDROP
88 (data (i32.const 16532) "\02\00\00\00") ;; LIT
89 (data (i32.const 16536) "\5c\00\00\00") ;; 92 (\ character)
90 (data (i32.const 16540) "\25\00\00\00") ;; =?
91 (data (i32.const 16544) "\0e\00\00\00") ;; JZ:
92 (data (i32.const 16548) "\e4\40\00\00") ;; addr of DOCHAR
93 (data (i32.const 16552) "\10\00\00\00") ;; DROP
94 (data (i32.const 16556) "\94\41\00\00") ;; DO-BACKSLASH (continue using this wbuf we started)
95 (data (i32.const 16560) "\0d\00\00\00") ;; NOOP
96 (data (i32.const 16564) "\12\00\00\00") ;; JMP:
97 (data (i32.const 16568) "\74\40\00\00") ;; addr of KEYLOOP-1 (get a new wbuf, call to wbuf+1 ate ours)
98 (data (i32.const 16572) "\10\00\00\00") ;; DROP <-- KEYDROP
99 (data (i32.const 16576) "\12\00\00\00") ;; JMP:
100 (data (i32.const 16580) "\78\40\00\00") ;; addr of KEYLOOP
101 (data (i32.const 16584) "\05\00\00\00") ;; KEY <-- WORDLOOP
102 (data (i32.const 16588) "\11\00\00\00") ;; WS?
103 (data (i32.const 16592) "\0f\00\00\00") ;; JNZ:
104 (data (i32.const 16596) "\f0\40\00\00") ;; addr of WORDEND
105 (data (i32.const 16600) "\06\00\00\00") ;; DUP
106 (data (i32.const 16604) "\18\00\00\00") ;; J-1:
107 (data (i32.const 16608) "\f0\40\00\00") ;; addr of WORDEND
108 (data (i32.const 16612) "\13\00\00\00") ;; WORDPUTC <-- DOCHAR
109 (data (i32.const 16616) "\12\00\00\00") ;; JMP:
110 (data (i32.const 16620) "\c8\40\00\00") ;; addr of WORDLOOP
111 (data (i32.const 16624) "\10\00\00\00") ;; DROP <-- WORDEND
112 (data (i32.const 16628) "\17\00\00\00") ;; WORDFINISH
113 (data (i32.const 16632) "\01\00\00\00") ;; RET
114 (; Exec Mode ;)
115 (data (i32.const 16680) "\1e\00\00\00") ;; 2DUP
116 (data (i32.const 16684) "\15\00\00\00") ;; DICT_GET
117 (data (i32.const 16688) "\06\00\00\00") ;; DUP
118 (data (i32.const 16692) "\0e\00\00\00") ;; JZ:
119 (data (i32.const 16696) "\4c\41\00\00") ;; donum -1 (16716)
120 (data (i32.const 16700) "\1f\00\00\00") ;; ROT
121 (data (i32.const 16704) "\20\00\00\00") ;; 2DROP
122 (data (i32.const 16708) "\0c\00\00\00") ;; EXECUTE
123 (data (i32.const 16712) "\01\00\00\00") ;; RET
124 (data (i32.const 16716) "\10\00\00\00") ;; DROP (xt from dictionary)
125 (data (i32.const 16720) "\16\00\00\00") ;; NUMBER <-- donum, pushes NUM, UNPARSED
126 (data (i32.const 16724) "\06\00\00\00") ;; DUP
127 (data (i32.const 16728) "\0f\00\00\00") ;; JNZ:
128 (data (i32.const 16732) "\68\41\00\00") ;; donum_err (16744)
129 (data (i32.const 16736) "\10\00\00\00") ;; DROP
130 (data (i32.const 16740) "\01\00\00\00") ;; RET
131 (data (i32.const 16744) "\20\00\00\00") ;; 2DROP <-- donum_err
132 (data (i32.const 16748) "\02\00\00\00") ;; LIT
133 (data (i32.const 16752) "\04\30\00\00") ;; INBUFSIZE LOCATION
134 (data (i32.const 16756) "\02\00\00\00") ;; LIT
135 (data (i32.const 16760) "\00\00\00\00") ;; 0
136 (data (i32.const 16764) "\0b\00\00\00") ;; !
137 (data (i32.const 16768) "\19\00\00\00") ;; BYE
138 (data (i32.const 16772) "\00\00\00\00") ;;
139 (data (i32.const 16776) "\00\00\00\00") ;;
140 (data (i32.const 16780) "\00\00\00\00") ;;
141 (data (i32.const 16784) "\00\00\00\00") ;;
142 (; Do Backslash ;)
143 (data (i32.const 16788) "\05\00\00\00") ;; KEY
144 (data (i32.const 16792) "\11\00\00\00") ;; WS?
145 (data (i32.const 16796) "\0f\00\00\00") ;; JNZ:
146 (data (i32.const 16800) "\c8\41\00\00") ;; addr of keypump + 3
147 (data (i32.const 16804) "\cc\40\00\00") ;; WORDLOOP + 1
148 (data (i32.const 16808) "\28\41\00\00") ;; EXECUTE-MODE
149 (data (i32.const 16812) "\01\00\00\00") ;; RET
150 (; Do Comment ;)
151 (data (i32.const 16828) "\18\00\00\00") ;; j-1: <-- keypump
152 (data (i32.const 16832) "\e0\41\00\00") ;; addr of end
153 (data (i32.const 16836) "\05\00\00\00") ;; KEY
154 (data (i32.const 16840) "\02\00\00\00") ;; LIT
155 (data (i32.const 16844) "\0a\00\00\00") ;; 10 (line feed)
156 (data (i32.const 16848) "\25\00\00\00") ;; =?
157 (data (i32.const 16852) "\0e\00\00\00") ;; JZ:
158 (data (i32.const 16856) "\bc\41\00\00") ;; addr of keypump
159 (data (i32.const 16860) "\10\00\00\00") ;; DROP
160 (data (i32.const 16864) "\01\00\00\00") ;; RET
161
162 (export "memory" (memory $0))
163 (export "main" (func $main))
164 (func $main (result i32)
165 call $interpret
166 )
167 (func $interpret (result i32)
168 (local $here i32)
169 (local $eax i32)
170 (local $esi i32)
171 (local $inbuf_head i32)
172 (local $stringbelt_tail i32)
173 (local $stringbelt_head i32)
174 (local $wordbelt_tail i32)
175 (local $wordbelt_head i32)
176 (local $channel i32)
177 i32.const 14340
178 i32.load
179 set_local $here
180 (; Load "start" into esi, then restore "start" to "quit" ;)
181 i32.const 14344
182 i32.load
183 set_local $esi
184 i32.const 14344
185 i32.const 16384
186 i32.store
187 (; "start" will be a normal quit, unless cirumvented in this run ;)
188 get_global $inbuf_data
189 set_local $inbuf_head
190 i32.const 14352
191 i32.load
192 set_local $stringbelt_tail
193 i32.const 14356
194 i32.load
195 set_local $stringbelt_head
196 i32.const 14360
197 i32.load
198 set_local $wordbelt_tail
199 i32.const 14364
200 i32.load
201 set_local $wordbelt_head
202 i32.const 14368
203 i32.load
204 set_local $channel
205 block $bye
206 loop $next
207 get_local $esi
208 get_local $esi
209 i32.const 4
210 i32.add
211 set_local $esi
212 i32.load
213 set_local $eax
214 loop $execloop
215 block $default block $op0 block $ret block $lit block $rinit
216 block $word block $key block $dup block $plus block $noop2 block $emit
217 block $fetch block $set block $execute block $noop block $jz block $jnz
218 block $drop block $wsbool block $jmp block $wordputc block $wordstart
219 block $dictget block $parsenum block $wordfinish block $jneg1 block $swap
220 block $words block $here block $dictset block $dup2 block $rot block $drop2
221 block $comma block $subtract block $keychan block $sethere block $eqbool
222 block $echostring block $strstart block $strput block $strend block $fetchinc
223 block $setinc block $finddoes block $definedoes block $stacktrace
224 get_local $eax
225 br_table $op0 $ret (;2;)$lit $rinit (;4;)$word $key (;6;)$dup $plus
226 (;8;)$jmp $emit (;10;)$fetch $set (;12;)$execute $noop (;14;)$jz $jnz
227 (;16;)$drop $wsbool (;18;)$jmp $wordputc (;20;)$wordstart $dictget
228 (;22;)$parsenum $wordfinish (;24;)$jneg1 $bye (;26;)$swap $words
229 (;28;)$here $dictset (;30;)$dup2 $rot (;32;)$drop2 $comma
230 (;34;)$subtract $keychan (;36;)$sethere $eqbool (;38;)$echostring $strstart
231 (;40;)$strput $strend (;42;)$fetchinc $setinc (;44;)$finddoes $definedoes
232 (;46;)$stacktrace $default
233 end ;; stacktrace
234 call $sys_stack
235 get_local $esi
236 call $sys_reflect
237 br $next
238 end ;; definedoes
239 call $pop
240 call $rpush
241 call $pop
242 set_local $eax
243 call $pop
244 get_local $eax
245 call $rpop
246 call $does_set
247 br $next
248 end ;; finddoes
249 call $pop
250 set_local $eax
251 call $pop
252 get_local $eax
253 call $does_get
254 call $push
255 br $next
256 end ;; setinc
257 call $pop
258 call $rpush
259 call $pop
260 tee_local $eax
261 call $rpop
262 i32.store
263 get_local $eax
264 i32.const 4
265 i32.add
266 call $push
267 br $next
268 end ;; fetchinc
269 call $pop
270 tee_local $eax
271 i32.const 4
272 i32.add
273 call $push
274 get_local $eax
275 i32.load
276 call $push
277 br $next
278 end ;; strend
279 get_local $stringbelt_tail
280 get_local $stringbelt_head
281 get_local $stringbelt_tail
282 i32.const 4
283 i32.add
284 i32.sub
285 tee_local $eax (; n bytes ;)
286 i32.store
287 (; align to 32-bit ;)
288 get_local $stringbelt_head
289 i32.const 3
290 i32.add
291 i32.const 8188
292 i32.and
293 set_local $stringbelt_head
294 (; /align ;)
295 get_local $stringbelt_tail
296 i32.const 4
297 i32.add
298 call $push
299 get_local $eax
300 call $push
301 br $next
302 end ;; strput
303 block $sbhasspace2
304 get_local $stringbelt_head
305 get_global $wordbelt
306 i32.lt_u
307 br_if $sbhasspace2
308 i32.const 0
309 tee_local $stringbelt_head
310 get_local $stringbelt_tail
311 i32.load
312 i32.store
313 get_local $stringbelt_head
314 i32.const 4
315 i32.add
316 set_local $stringbelt_head
317 get_local $stringbelt_tail
318 i32.const 4
319 i32.add
320 set_local $stringbelt_tail
321 loop $copystringtostart
322 get_local $stringbelt_head
323 get_local $stringbelt_tail
324 i32.load16_u
325 i32.store16
326 get_local $stringbelt_head
327 i32.const 2
328 i32.add
329 set_local $stringbelt_head
330 get_local $stringbelt_tail
331 i32.const 2
332 i32.add
333 tee_local $stringbelt_tail
334 get_global $wordbelt
335 i32.le_u
336 br_if $copystringtostart
337 end
338 i32.const 0
339 set_local $stringbelt_tail
340 end
341 get_local $stringbelt_head
342 call $pop
343 i32.store16
344 get_local $stringbelt_head
345 i32.const 2
346 i32.add
347 set_local $stringbelt_head
348 br $next
349 end ;; strstart
350 block $sbhasspace
351 get_local $stringbelt_head
352 get_global $wordbelt
353 i32.const 8
354 i32.sub
355 i32.le_u
356 br_if $sbhasspace
357 i32.const 0
358 set_local $stringbelt_head
359 end
360 get_local $stringbelt_head
361 get_local $stringbelt_head
362 tee_local $stringbelt_tail
363 i32.const 0
364 i32.store
365 i32.const 4
366 i32.add
367 set_local $stringbelt_head
368 br $next
369 end ;; echostring
370 get_local $channel
371 call $pop
372 set_local $eax
373 call $pop
374 get_local $eax
375 call $sys_write
376 br $next
377 end ;; eqbool
378 block $equiv
379 call $pop
380 call $pop
381 tee_local $eax
382 i32.eq
383 get_local $eax
384 call $push
385 br_if $equiv
386 i32.const 0
387 call $push
388 br $next
389 end
390 i32.const 1
391 call $push
392 br $next
393 end ;; sethere
394 call $pop
395 set_local $here
396 br $next
397 end ;; keychan
398 call $pop
399 set_local $channel
400 br $next
401 end ;; subtract
402 call $pop
403 set_local $eax
404 call $pop
405 get_local $eax
406 i32.sub
407 call $push
408 br $next
409 end ;; comma
410 get_local $here
411 call $pop
412 i32.store
413 get_local $here
414 i32.const 4
415 i32.add
416 set_local $here
417 br $next
418 end ;; drop2
419 call $pop
420 call $pop
421 drop
422 drop
423 br $next
424 end ;; rot
425 call $pop
426 call $pop
427 set_local $eax
428 call $pop
429 call $rpush
430 call $push
431 call $rpop
432 call $push
433 get_local $eax
434 call $push
435 br $next
436 end ;; dup2
437 get_local $esi
438 call $rpush
439 call $pop
440 set_local $eax
441 call $pop
442 tee_local $esi
443 call $push
444 get_local $eax
445 call $push
446 get_local $esi
447 call $push
448 get_local $eax
449 call $push
450 call $rpop
451 set_local $esi
452 br $next
453 end ;; dictset
454 call $pop
455 call $rpush
456 call $pop
457 set_local $eax
458 call $pop
459 get_local $eax
460 call $rpop
461 call $vocab_set
462 br $next
463 end ;; here
464 get_local $here
465 call $push
466 br $next
467 end ;; words
468 call $sys_words
469 br $next
470 end ;; swap
471 call $pop
472 call $pop
473 set_local $eax
474 call $push
475 get_local $eax
476 call $push
477 br $next
478 end ;; jneg1
479 block $jneg1if
480 call $pop
481 i32.const -1
482 i32.eq
483 br_if $jneg1if
484 get_local $esi
485 i32.const 4
486 i32.add
487 set_local $esi
488 br $next
489 end
490 get_local $esi
491 i32.load
492 set_local $esi
493 br $next
494 end ;; wordfinish
495 get_local $wordbelt_tail
496 get_local $wordbelt_head
497 get_local $wordbelt_tail
498 i32.const 4
499 i32.add
500 i32.sub
501 tee_local $eax (; n bytes ;)
502 i32.store
503 (; align to 32-bit ;)
504 get_local $wordbelt_head
505 i32.const 3
506 i32.add
507 i32.const 12284
508 i32.and
509 set_local $wordbelt_head
510 (; /align ;)
511 get_local $wordbelt_tail
512 i32.const 4
513 i32.add
514 call $push
515 get_local $eax
516 call $push
517 br $next
518 end ;; parsenum
519 call $pop
520 call $rpush
521 call $pop
522 tee_local $eax
523 call $rpop
524 i32.const 14348 (; load BASE ;)
525 i32.load
526 call $sys_parsenum
527 get_local $eax
528 i32.load
529 call $push
530 call $push
531 br $next
532 end ;; dictget
533 call $pop
534 set_local $eax
535 call $pop
536 get_local $eax
537 call $vocab_get
538 call $push
539 br $next
540 end ;; wordstart
541 block $wbhasspace
542 get_local $wordbelt_head
543 get_global $inbuf
544 i32.const 8
545 i32.sub
546 i32.le_u
547 br_if $wbhasspace
548 get_global $wordbelt
549 set_local $wordbelt_head
550 end
551 get_local $wordbelt_head
552 get_local $wordbelt_head
553 tee_local $wordbelt_tail
554 i32.const 0
555 i32.store
556 i32.const 4
557 i32.add
558 set_local $wordbelt_head
559 br $next
560 end ;; wordputc
561 block $wbhasspace2
562 get_local $wordbelt_head
563 get_global $inbuf
564 i32.lt_u
565 br_if $wbhasspace2
566 get_global $wordbelt
567 tee_local $wordbelt_head
568 get_local $wordbelt_tail
569 i32.load
570 i32.store
571 get_local $wordbelt_head
572 i32.const 4
573 i32.add
574 set_local $wordbelt_head
575 get_local $wordbelt_tail
576 i32.const 4
577 i32.add
578 set_local $wordbelt_tail
579 loop $copywordtostart
580 get_local $wordbelt_head
581 get_local $wordbelt_tail
582 i32.load16_u
583 i32.store16
584 get_local $wordbelt_head
585 i32.const 2
586 i32.add
587 set_local $wordbelt_head
588 get_local $wordbelt_tail
589 i32.const 2
590 i32.add
591 tee_local $wordbelt_tail
592 get_global $inbuf
593 i32.le_u
594 br_if $copywordtostart
595 end
596 get_global $wordbelt
597 set_local $wordbelt_tail
598 end
599 get_local $wordbelt_head
600 call $pop
601 i32.store16
602 get_local $wordbelt_head
603 i32.const 2
604 i32.add
605 set_local $wordbelt_head
606 br $next
607 end ;; jmp
608 get_local $esi
609 i32.load
610 set_local $esi
611 br $next
612 end ;; wsbool
613 call $pop
614 tee_local $eax
615 call $is_whitespace
616 get_local $eax
617 call $push
618 call $push
619 br $next
620 end ;; drop
621 call $pop
622 drop
623 br $next
624 end ;; jnz
625 block $jnzif
626 call $pop
627 i32.eqz
628 br_if $jnzif
629 get_local $esi
630 i32.load
631 set_local $esi
632 br $next
633 end
634 get_local $esi
635 i32.const 4
636 i32.add
637 set_local $esi
638 br $next
639 end ;; jz
640 block $jzif
641 call $pop
642 i32.eqz
643 br_if $jzif
644 get_local $esi
645 i32.const 4
646 i32.add
647 set_local $esi
648 br $next
649 end
650 get_local $esi
651 i32.load
652 set_local $esi
653 br $next
654 end ;; noop
655 br $next
656 end ;; execute
657 call $pop
658 tee_local $eax
659 i32.const 256
660 i32.lt_u
661 br_if $execloop
662 get_local $esi
663 call $rpush
664 get_local $eax
665 set_local $esi
666 br $next
667 end ;; set
668 call $pop
669 set_local $eax
670 call $pop
671 get_local $eax
672 i32.store
673 br $next
674 end ;; fetch
675 call $pop
676 i32.load
677 call $push
678 br $next
679 end ;; emit (.)
680 call $pop
681 i32.const 14348
682 i32.load
683 call $sys_echo
684 br $next
685 end ;; noop2
686 br $next
687 end ;; plus
688 call $pop
689 call $pop
690 i32.add
691 call $push
692 br $next
693 end ;; dup
694 call $pop
695 tee_local $eax
696 get_local $eax
697 call $push
698 call $push
699 br $next
700 end ;; key
701 loop $key_loop
702 block $key_read
703 get_global $inbuf_size
704 i32.load
705 get_local $inbuf_head
706 get_global $inbuf_data
707 i32.sub
708 i32.le_u
709 br_if $key_read
710 get_local $inbuf_head
711 i32.load16_u
712 call $push
713 get_local $inbuf_head
714 i32.const 2
715 i32.add
716 set_local $inbuf_head
717 br $next
718 end ;; key_read
719 get_global $inbuf_size
720 get_local $channel
721 get_global $inbuf_data
722 get_global $inbuf
723 i32.load
724 call $sys_read
725 i32.store
726 block $nullread
727 get_global $inbuf_size
728 i32.load
729 i32.eqz
730 br_if $nullread
731 get_global $inbuf_data
732 set_local $inbuf_head
733 br $key_loop
734 end ;; nullread
735 i32.const -1 ;; <- keyval sent if sz == 0
736 call $push
737 br $next
738 end ;; key_loop
739 end ;; word
740 br $next
741 end ;; rinit
742 call $rinit
743 br $next
744 end ;; lit
745 get_local $esi
746 get_local $esi
747 i32.const 4
748 i32.add
749 set_local $esi
750 i32.load
751 call $push
752 br $next
753 end ;; ret
754 call $rpop
755 set_local $esi
756 br $next
757 end ;; op0
758 get_local $esi
759 call $rpush
760 br $bye
761 end ;; default
762 get_local $esi
763 call $rpush
764 get_local $eax
765 set_local $esi
766 br $next
767 end ;; execloop
768 end ;; next loop
769 end ;; bye
770 i32.const 14340
771 get_local $here
772 i32.store
773 i32.const 14352
774 get_local $stringbelt_tail
775 i32.store
776 i32.const 14356
777 get_local $stringbelt_head
778 i32.store
779 i32.const 14360
780 get_local $wordbelt_tail
781 i32.store
782 i32.const 14364
783 get_local $wordbelt_head
784 i32.store
785 i32.const 14368
786 get_local $channel
787 i32.store
788 i32.const 0
789 return
790 )
791 )