61cbb2238a83b51ed204844b6302a1d782a55e92
[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)))
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) (result i32)))
37 (import "env" "does_set" (func $does_set (param 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 i32.const 14344
181 i32.load
182 set_local $esi
183 get_global $inbuf_data
184 set_local $inbuf_head
185 i32.const 14352
186 i32.load
187 set_local $stringbelt_tail
188 i32.const 14356
189 i32.load
190 set_local $stringbelt_head
191 i32.const 14360
192 i32.load
193 set_local $wordbelt_tail
194 i32.const 14364
195 i32.load
196 set_local $wordbelt_head
197 i32.const 14368
198 i32.load
199 set_local $channel
200 block $bye
201 loop $next
202 get_local $esi
203 get_local $esi
204 i32.const 4
205 i32.add
206 set_local $esi
207 i32.load
208 set_local $eax
209 loop $execloop
210 block $default block $op0 block $ret block $lit block $rinit
211 block $word block $key block $dup block $plus block $noop2 block $emit
212 block $fetch block $set block $execute block $noop block $jz block $jnz
213 block $drop block $wsbool block $jmp block $wordputc block $wordstart
214 block $dictget block $parsenum block $wordfinish block $jneg1 block $swap
215 block $words block $here block $dictset block $dup2 block $rot block $drop2
216 block $comma block $subtract block $keychan block $sethere block $eqbool
217 block $echostring block $strstart block $strput block $strend block $fetchinc
218 block $setinc block $finddoes block $definedoes
219 get_local $eax
220 br_table $op0 $ret (;2;)$lit $rinit (;4;)$word $key (;6;)$dup $plus
221 (;8;)$jmp $emit (;10;)$fetch $set (;12;)$execute $noop (;14;)$jz $jnz
222 (;16;)$drop $wsbool (;18;)$jmp $wordputc (;20;)$wordstart $dictget
223 (;22;)$parsenum $wordfinish (;24;)$jneg1 $bye (;26;)$swap $words
224 (;28;)$here $dictset (;30;)$dup2 $rot (;32;)$drop2 $comma
225 (;34;)$subtract $keychan (;36;)$sethere $eqbool (;38;)$echostring $strstart
226 (;40;)$strput $strend (;42;)$fetchinc $setinc (;44;)$finddoes $definedoes
227 (;46;)$default
228 end ;; definedoes
229 call $pop
230 set_local $eax
231 call $pop
232 get_local $eax
233 call $does_set
234 br $next
235 end ;; finddoes
236 call $pop
237 call $does_get
238 call $push
239 br $next
240 end ;; setinc
241 call $pop
242 call $rpush
243 call $pop
244 tee_local $eax
245 call $rpop
246 i32.store
247 get_local $eax
248 i32.const 4
249 i32.add
250 call $push
251 br $next
252 end ;; fetchinc
253 call $pop
254 tee_local $eax
255 i32.const 4
256 i32.add
257 call $push
258 get_local $eax
259 i32.load
260 call $push
261 br $next
262 end ;; strend
263 get_local $stringbelt_tail
264 get_local $stringbelt_head
265 get_local $stringbelt_tail
266 i32.const 4
267 i32.add
268 i32.sub
269 tee_local $eax (; n bytes ;)
270 i32.store
271 (; align to 32-bit ;)
272 get_local $stringbelt_head
273 i32.const 3
274 i32.add
275 i32.const 8188
276 i32.and
277 set_local $stringbelt_head
278 (; /align ;)
279 get_local $stringbelt_tail
280 i32.const 4
281 i32.add
282 call $push
283 get_local $eax
284 call $push
285 br $next
286 end ;; strput
287 block $sbhasspace2
288 get_local $stringbelt_head
289 get_global $wordbelt
290 i32.lt_u
291 br_if $sbhasspace2
292 i32.const 0
293 tee_local $stringbelt_head
294 get_local $stringbelt_tail
295 i32.load
296 i32.store
297 get_local $stringbelt_head
298 i32.const 4
299 i32.add
300 set_local $stringbelt_head
301 get_local $stringbelt_tail
302 i32.const 4
303 i32.add
304 set_local $stringbelt_tail
305 loop $copystringtostart
306 get_local $stringbelt_head
307 get_local $stringbelt_tail
308 i32.load16_u
309 i32.store16
310 get_local $stringbelt_head
311 i32.const 2
312 i32.add
313 set_local $stringbelt_head
314 get_local $stringbelt_tail
315 i32.const 2
316 i32.add
317 tee_local $stringbelt_tail
318 get_global $wordbelt
319 i32.le_u
320 br_if $copystringtostart
321 end
322 i32.const 0
323 set_local $stringbelt_tail
324 end
325 get_local $stringbelt_head
326 call $pop
327 i32.store16
328 get_local $stringbelt_head
329 i32.const 2
330 i32.add
331 set_local $stringbelt_head
332 br $next
333 end ;; strstart
334 block $sbhasspace
335 get_local $stringbelt_head
336 get_global $wordbelt
337 i32.const 8
338 i32.sub
339 i32.le_u
340 br_if $sbhasspace
341 i32.const 0
342 set_local $stringbelt_head
343 end
344 get_local $stringbelt_head
345 get_local $stringbelt_head
346 tee_local $stringbelt_tail
347 i32.const 0
348 i32.store
349 i32.const 4
350 i32.add
351 set_local $stringbelt_head
352 br $next
353 end ;; echostring
354 get_local $channel
355 call $pop
356 set_local $eax
357 call $pop
358 get_local $eax
359 call $sys_write
360 br $next
361 end ;; eqbool
362 block $equiv
363 call $pop
364 call $pop
365 tee_local $eax
366 i32.eq
367 get_local $eax
368 call $push
369 br_if $equiv
370 i32.const 0
371 call $push
372 br $next
373 end
374 i32.const 1
375 call $push
376 br $next
377 end ;; sethere
378 call $pop
379 set_local $here
380 br $next
381 end ;; keychan
382 call $pop
383 set_local $channel
384 br $next
385 end ;; subtract
386 call $pop
387 set_local $eax
388 call $pop
389 get_local $eax
390 i32.sub
391 call $push
392 br $next
393 end ;; comma
394 get_local $here
395 call $pop
396 i32.store
397 get_local $here
398 i32.const 4
399 i32.add
400 set_local $here
401 br $next
402 end ;; drop2
403 call $pop
404 call $pop
405 drop
406 drop
407 br $next
408 end ;; rot
409 call $pop
410 call $pop
411 set_local $eax
412 call $pop
413 call $rpush
414 call $push
415 call $rpop
416 call $push
417 get_local $eax
418 call $push
419 br $next
420 end ;; dup2
421 get_local $esi
422 call $rpush
423 call $pop
424 set_local $eax
425 call $pop
426 tee_local $esi
427 call $push
428 get_local $eax
429 call $push
430 get_local $esi
431 call $push
432 get_local $eax
433 call $push
434 call $rpop
435 set_local $esi
436 br $next
437 end ;; dictset
438 call $pop
439 call $rpush
440 call $pop
441 set_local $eax
442 call $pop
443 get_local $eax
444 call $rpop
445 call $vocab_set
446 br $next
447 end ;; here
448 get_local $here
449 call $push
450 br $next
451 end ;; words
452 call $sys_words
453 br $next
454 end ;; swap
455 call $pop
456 call $pop
457 set_local $eax
458 call $push
459 get_local $eax
460 call $push
461 br $next
462 end ;; jneg1
463 block $jneg1if
464 call $pop
465 i32.const -1
466 i32.eq
467 br_if $jneg1if
468 get_local $esi
469 i32.const 4
470 i32.add
471 set_local $esi
472 br $next
473 end
474 get_local $esi
475 i32.load
476 set_local $esi
477 br $next
478 end ;; wordfinish
479 get_local $wordbelt_tail
480 get_local $wordbelt_head
481 get_local $wordbelt_tail
482 i32.const 4
483 i32.add
484 i32.sub
485 tee_local $eax (; n bytes ;)
486 i32.store
487 (; align to 32-bit ;)
488 get_local $wordbelt_head
489 i32.const 3
490 i32.add
491 i32.const 12284
492 i32.and
493 set_local $wordbelt_head
494 (; /align ;)
495 get_local $wordbelt_tail
496 i32.const 4
497 i32.add
498 call $push
499 get_local $eax
500 call $push
501 br $next
502 end ;; parsenum
503 call $pop
504 call $rpush
505 call $pop
506 tee_local $eax
507 call $rpop
508 i32.const 14348 (; load BASE ;)
509 i32.load
510 call $sys_parsenum
511 get_local $eax
512 i32.load
513 call $push
514 call $push
515 br $next
516 end ;; dictget
517 call $pop
518 set_local $eax
519 call $pop
520 get_local $eax
521 call $vocab_get
522 call $push
523 br $next
524 end ;; wordstart
525 block $wbhasspace
526 get_local $wordbelt_head
527 get_global $inbuf
528 i32.const 8
529 i32.sub
530 i32.le_u
531 br_if $wbhasspace
532 get_global $wordbelt
533 set_local $wordbelt_head
534 end
535 get_local $wordbelt_head
536 get_local $wordbelt_head
537 tee_local $wordbelt_tail
538 i32.const 0
539 i32.store
540 i32.const 4
541 i32.add
542 set_local $wordbelt_head
543 br $next
544 end ;; wordputc
545 block $wbhasspace2
546 get_local $wordbelt_head
547 get_global $inbuf
548 i32.lt_u
549 br_if $wbhasspace2
550 get_global $wordbelt
551 tee_local $wordbelt_head
552 get_local $wordbelt_tail
553 i32.load
554 i32.store
555 get_local $wordbelt_head
556 i32.const 4
557 i32.add
558 set_local $wordbelt_head
559 get_local $wordbelt_tail
560 i32.const 4
561 i32.add
562 set_local $wordbelt_tail
563 loop $copywordtostart
564 get_local $wordbelt_head
565 get_local $wordbelt_tail
566 i32.load16_u
567 i32.store16
568 get_local $wordbelt_head
569 i32.const 2
570 i32.add
571 set_local $wordbelt_head
572 get_local $wordbelt_tail
573 i32.const 2
574 i32.add
575 tee_local $wordbelt_tail
576 get_global $inbuf
577 i32.le_u
578 br_if $copywordtostart
579 end
580 get_global $wordbelt
581 set_local $wordbelt_tail
582 end
583 get_local $wordbelt_head
584 call $pop
585 i32.store16
586 get_local $wordbelt_head
587 i32.const 2
588 i32.add
589 set_local $wordbelt_head
590 br $next
591 end ;; jmp
592 get_local $esi
593 i32.load
594 set_local $esi
595 br $next
596 end ;; wsbool
597 call $pop
598 tee_local $eax
599 call $is_whitespace
600 get_local $eax
601 call $push
602 call $push
603 br $next
604 end ;; drop
605 call $pop
606 drop
607 br $next
608 end ;; jnz
609 block $jnzif
610 call $pop
611 i32.eqz
612 br_if $jnzif
613 get_local $esi
614 i32.load
615 set_local $esi
616 br $next
617 end
618 get_local $esi
619 i32.const 4
620 i32.add
621 set_local $esi
622 br $next
623 end ;; jz
624 block $jzif
625 call $pop
626 i32.eqz
627 br_if $jzif
628 get_local $esi
629 i32.const 4
630 i32.add
631 set_local $esi
632 br $next
633 end
634 get_local $esi
635 i32.load
636 set_local $esi
637 br $next
638 end ;; noop
639 br $next
640 end ;; execute
641 call $pop
642 tee_local $eax
643 i32.const 256
644 i32.lt_u
645 br_if $execloop
646 get_local $esi
647 call $rpush
648 get_local $eax
649 set_local $esi
650 br $next
651 end ;; set
652 call $pop
653 set_local $eax
654 call $pop
655 get_local $eax
656 i32.store
657 br $next
658 end ;; fetch
659 call $pop
660 i32.load
661 call $push
662 br $next
663 end ;; emit (.)
664 call $pop
665 call $sys_echo
666 br $next
667 end ;; noop2
668 br $next
669 end ;; plus
670 call $pop
671 call $pop
672 i32.add
673 call $push
674 br $next
675 end ;; dup
676 call $pop
677 tee_local $eax
678 get_local $eax
679 call $push
680 call $push
681 br $next
682 end ;; key
683 loop $key_loop
684 block $key_read
685 get_global $inbuf_size
686 i32.load
687 get_local $inbuf_head
688 get_global $inbuf_data
689 i32.sub
690 i32.le_u
691 br_if $key_read
692 get_local $inbuf_head
693 i32.load16_u
694 call $push
695 get_local $inbuf_head
696 i32.const 2
697 i32.add
698 set_local $inbuf_head
699 br $next
700 end ;; key_read
701 get_global $inbuf_size
702 get_local $channel
703 get_global $inbuf_data
704 get_global $inbuf
705 i32.load
706 call $sys_read
707 i32.store
708 block $nullread
709 get_global $inbuf_size
710 i32.load
711 i32.eqz
712 br_if $nullread
713 get_global $inbuf_data
714 set_local $inbuf_head
715 br $key_loop
716 end ;; nullread
717 i32.const -1 ;; <- keyval sent if sz == 0
718 call $push
719 br $next
720 end ;; key_loop
721 end ;; word
722 br $next
723 end ;; rinit
724 call $rinit
725 br $next
726 end ;; lit
727 get_local $esi
728 get_local $esi
729 i32.const 4
730 i32.add
731 set_local $esi
732 i32.load
733 call $push
734 br $next
735 end ;; ret
736 call $rpop
737 set_local $esi
738 br $next
739 end ;; op0
740 get_local $esi
741 call $rpush
742 br $bye
743 end ;; default
744 get_local $esi
745 call $rpush
746 get_local $eax
747 set_local $esi
748 br $next
749 end ;; execloop
750 end ;; next loop
751 end ;; bye
752 i32.const 14340
753 get_local $here
754 i32.store
755 i32.const 14352
756 get_local $stringbelt_tail
757 i32.store
758 i32.const 14356
759 get_local $stringbelt_head
760 i32.store
761 i32.const 14360
762 get_local $wordbelt_tail
763 i32.store
764 i32.const 14364
765 get_local $wordbelt_head
766 i32.store
767 i32.const 14368
768 get_local $channel
769 i32.store
770 i32.const 0
771 return
772 )
773 )