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.
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.
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/>. ;)
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 $FUNCSIG$v (func (param i32) (result i32)))
19 (type $FUNCSIG$vi (func (param i32 i32 i32) (result i32)))
20 (import "env" "pop" (func $pop (result i32)))
21 (import "env" "push" (func $push (param i32)))
22 (import "env" "rinit" (func $rinit))
23 (import "env" "rpop" (func $rpop (result i32)))
24 (import "env" "rpush" (func $rpush (param i32)))
25 (import "env" "sys_read" (func $sys_read (param i32 i32 i32) (result i32)))
26 (import "env" "sys_fetch" (func $sys_fetch (param i32 i32) (result i32)))
27 (import "env" "sys_listen" (func $sys_listen (param i32) (result i32)))
28 (import "env" "sys_write" (func $sys_write (param i32 i32 i32) (result i32)))
29 (import "env" "sys_echo" (func $sys_echo (param i32)))
30 (import "env" "sys_echochar" (func $sys_echochar (param i32)))
31 (import "env" "sys_reflect" (func $sys_reflect (param i32)))
32 (import "env" "vocab_get" (func $vocab_get (param i32 i32) (result i32)))
33 (import "env" "vocab_set" (func $vocab_set (param i32 i32 i32) (result i32)))
34 (import "env" "is_whitespace" (func $is_whitespace (param i32) (result i32)))
35 (import "env" "sys_parsenum" (func $sys_parsenum (param i32 i32 i32) (result i32)))
36 (import "env" "sys_stack" (func $sys_stack))
37 (import "env" "sys_words" (func $sys_words))
38 (table (;0;) 0 anyfunc)
40 (; String Belt ;) ;; 0x0000 Size: 8192
41 (global $wordbelt i32 (i32.const 8192)) ;; 0x2000 Size: 4096
42 (global $inbuf i32 (i32.const 12288)) ;; 0x3000 Size: 2048
43 (global $inbuf_size i32 (i32.const 12292))
44 (global $inbuf_data i32 (i32.const 12296))
45 (global $kvars i32 (i32.const 14336)) ;; 0x3800 Size: 2048
46 (data (i32.const 12288) "\f8\07\00\00") ;; 2040 len
47 (data (i32.const 14336) "\28\41\00\00") ;; MODE
48 (data (i32.const 14340) "\04\42\00\00") ;; HERE
49 (data (i32.const 14344) "\00\40\00\00") ;; START
50 (data (i32.const 14348) "\0a\00\00\00") ;; BASE
51 (data (i32.const 14352) "\00\00\00\00") ;; STRINGBELT_TAIL
52 (data (i32.const 14356) "\00\00\00\00") ;; STRINGBELT_HEAD
53 (data (i32.const 14360) "\00\20\00\00") ;; WORDBELT_TAIL
54 (data (i32.const 14364) "\00\20\00\00") ;; WORDBELT_HEAD
55 (data (i32.const 14368) "\00\00\00\00") ;; CHANNEL
57 (data (i32.const 16384) "\03\00\00\00") ;; RINIT xt
58 (data (i32.const 16388) "\10\40\00\00") ;; INTERPRET xt
59 (data (i32.const 16392) "\12\00\00\00") ;; JMP xt
60 (data (i32.const 16396) "\00\40\00\00") ;; quit location (16384)
62 (data (i32.const 16400) "\74\40\00\00") ;; WORD xt (16500)
63 (data (i32.const 16404) "\06\00\00\00") ;; DUP
64 (data (i32.const 16408) "\0e\00\00\00") ;; JZ:
65 (data (i32.const 16412) "\38\40\00\00") ;; INTERP-END addr (16444)
66 (data (i32.const 16416) "\02\00\00\00") ;; LIT xt
67 (data (i32.const 16420) "\00\38\00\00") ;; MODE addr (14336)
68 (data (i32.const 16424) "\0a\00\00\00") ;; @ (fetch) xt
69 (data (i32.const 16428) "\0c\00\00\00") ;; EXECUTE xt
70 (data (i32.const 16432) "\0d\00\00\00") ;; NOOP xt
71 (data (i32.const 16436) "\01\00\00\00") ;; RET
72 (data (i32.const 16440) "\10\00\00\00") ;; DROP <-- INTERP-END
73 (data (i32.const 16444) "\10\00\00\00") ;; DROP
74 (data (i32.const 16448) "\19\00\00\00") ;; BYE
76 (data (i32.const 16500) "\14\00\00\00") ;; WORDSTART
77 (data (i32.const 16504) "\05\00\00\00") ;; KEY <-- KEYLOOP
78 (data (i32.const 16508) "\06\00\00\00") ;; DUP
79 (data (i32.const 16512) "\18\00\00\00") ;; J-1: 18
80 (data (i32.const 16516) "\f0\40\00\00") ;; addr of WORDEND
81 (data (i32.const 16520) "\11\00\00\00") ;; WS?
82 (data (i32.const 16524) "\0f\00\00\00") ;; JNZ:
83 (data (i32.const 16528) "\bc\40\00\00") ;; addr of KEYDROP
84 (data (i32.const 16532) "\02\00\00\00") ;; LIT
85 (data (i32.const 16536) "\5c\00\00\00") ;; 92 (\ character)
86 (data (i32.const 16540) "\25\00\00\00") ;; =?
87 (data (i32.const 16544) "\0e\00\00\00") ;; JZ:
88 (data (i32.const 16548) "\e4\40\00\00") ;; addr of DOCHAR
89 (data (i32.const 16552) "\10\00\00\00") ;; DROP
90 (data (i32.const 16556) "\94\41\00\00") ;; DO-BACKSLASH (continue using this wbuf we started)
91 (data (i32.const 16560) "\0d\00\00\00") ;; NOOP
92 (data (i32.const 16564) "\12\00\00\00") ;; JMP:
93 (data (i32.const 16568) "\74\40\00\00") ;; addr of KEYLOOP-1 (get a new wbuf, call to wbuf+1 ate ours)
94 (data (i32.const 16572) "\10\00\00\00") ;; DROP <-- KEYDROP
95 (data (i32.const 16576) "\12\00\00\00") ;; JMP:
96 (data (i32.const 16580) "\78\40\00\00") ;; addr of KEYLOOP
97 (data (i32.const 16584) "\05\00\00\00") ;; KEY <-- WORDLOOP
98 (data (i32.const 16588) "\11\00\00\00") ;; WS?
99 (data (i32.const 16592) "\0f\00\00\00") ;; JNZ:
100 (data (i32.const 16596) "\f0\40\00\00") ;; addr of WORDEND
101 (data (i32.const 16600) "\06\00\00\00") ;; DUP
102 (data (i32.const 16604) "\18\00\00\00") ;; J-1:
103 (data (i32.const 16608) "\f0\40\00\00") ;; addr of WORDEND
104 (data (i32.const 16612) "\13\00\00\00") ;; WORDPUTC <-- DOCHAR
105 (data (i32.const 16616) "\12\00\00\00") ;; JMP:
106 (data (i32.const 16620) "\c8\40\00\00") ;; addr of WORDLOOP
107 (data (i32.const 16624) "\10\00\00\00") ;; DROP <-- WORDEND
108 (data (i32.const 16628) "\17\00\00\00") ;; WORDFINISH
109 (data (i32.const 16632) "\01\00\00\00") ;; RET
111 (data (i32.const 16680) "\1e\00\00\00") ;; DUP2
112 (data (i32.const 16684) "\15\00\00\00") ;; DICT_GET
113 (data (i32.const 16688) "\06\00\00\00") ;; DUP
114 (data (i32.const 16692) "\0e\00\00\00") ;; JZ:
115 (data (i32.const 16696) "\4c\41\00\00") ;; donum -1 (16716)
116 (data (i32.const 16700) "\1f\00\00\00") ;; ROT
117 (data (i32.const 16704) "\20\00\00\00") ;; DROP2
118 (data (i32.const 16708) "\0c\00\00\00") ;; EXECUTE
119 (data (i32.const 16712) "\01\00\00\00") ;; RET
120 (data (i32.const 16716) "\10\00\00\00") ;; DROP (xt from dictionary)
121 (data (i32.const 16720) "\16\00\00\00") ;; NUMBER <-- donum, pushes NUM, UNPARSED
122 (data (i32.const 16724) "\06\00\00\00") ;; DUP
123 (data (i32.const 16728) "\0f\00\00\00") ;; JNZ:
124 (data (i32.const 16732) "\68\41\00\00") ;; donum_err (16744)
125 (data (i32.const 16736) "\10\00\00\00") ;; DROP
126 (data (i32.const 16740) "\01\00\00\00") ;; RET
127 (data (i32.const 16744) "\10\00\00\00") ;; PARSE_ERR <-- donum_err
128 (data (i32.const 16748) "\10\00\00\00") ;; ( DROP DROP )
129 (data (i32.const 16752) "\19\00\00\00") ;; BYE
131 (data (i32.const 16788) "\05\00\00\00") ;; KEY
132 (data (i32.const 16792) "\11\00\00\00") ;; WS?
133 (data (i32.const 16796) "\0f\00\00\00") ;; JNZ:
134 (data (i32.const 16800) "\c8\41\00\00") ;; addr of keypump + 3
135 (data (i32.const 16804) "\cc\40\00\00") ;; WORDLOOP + 1
136 (data (i32.const 16808) "\28\41\00\00") ;; EXECUTE-MODE
137 (data (i32.const 16812) "\01\00\00\00") ;; RET
139 (data (i32.const 16828) "\18\00\00\00") ;; j-1: <-- keypump
140 (data (i32.const 16832) "\e0\41\00\00") ;; addr of end
141 (data (i32.const 16836) "\05\00\00\00") ;; KEY
142 (data (i32.const 16840) "\02\00\00\00") ;; LIT
143 (data (i32.const 16844) "\0a\00\00\00") ;; 10 (line feed)
144 (data (i32.const 16848) "\25\00\00\00") ;; =?
145 (data (i32.const 16852) "\0e\00\00\00") ;; JZ:
146 (data (i32.const 16856) "\bc\41\00\00") ;; addr of keypump
147 (data (i32.const 16860) "\10\00\00\00") ;; DROP
148 (data (i32.const 16864) "\01\00\00\00") ;; RET
150 (export "memory" (memory $0))
151 (export "main" (func $main))
152 (func $main (result i32)
155 (func $interpret (result i32)
159 (local $inbuf_head i32)
160 (local $stringbelt_tail i32)
161 (local $stringbelt_head i32)
162 (local $wordbelt_tail i32)
163 (local $wordbelt_head i32)
171 get_global $inbuf_data
172 set_local $inbuf_head
175 set_local $stringbelt_tail
178 set_local $stringbelt_head
181 set_local $wordbelt_tail
184 set_local $wordbelt_head
198 block $default block $op0 block $ret block $lit block $rinit
199 block $word block $key block $dup block $plus block $noop2 block $emit
200 block $fetch block $set block $execute block $noop block $jz block $jnz
201 block $drop block $wsbool block $jmp block $wordputc block $wordstart
202 block $dictget block $parsenum block $wordfinish block $jneg1 block $swap
203 block $words block $here block $dictset block $dup2 block $rot block $drop2
204 block $comma block $subtract block $keychan block $sethere block $eqbool
205 block $echostring block $strstart block $strput block $strend
207 br_table $op0 $ret (;2;)$lit $rinit (;4;)$word $key (;6;)$dup $plus
208 (;8;)$jmp $emit (;10;)$fetch $set (;12;)$execute $noop (;14;)$jz $jnz
209 (;16;)$drop $wsbool (;18;)$jmp $wordputc (;20;)$wordstart $dictget
210 (;22;)$parsenum $wordfinish (;24;)$jneg1 $bye (;26;)$swap $words
211 (;28;)$here $dictset (;30;)$dup2 $rot (;32;)$drop2 $comma
212 (;34;)$subtract $keychan (;36;)$sethere $eqbool (;38;)$echostring $strstart
213 (;40;)$strput $strend $default
215 get_local $stringbelt_tail
216 get_local $stringbelt_head
217 get_local $stringbelt_tail
221 tee_local $eax (; n bytes ;)
223 (; align to 32-bit ;)
224 get_local $stringbelt_head
229 set_local $stringbelt_head
231 get_local $stringbelt_tail
240 get_local $stringbelt_head
245 tee_local $stringbelt_head
246 get_local $stringbelt_tail
249 get_local $stringbelt_head
252 set_local $stringbelt_head
253 get_local $stringbelt_tail
256 set_local $stringbelt_tail
257 loop $copystringtostart
258 get_local $stringbelt_head
259 get_local $stringbelt_tail
262 get_local $stringbelt_head
265 set_local $stringbelt_head
266 get_local $stringbelt_tail
269 tee_local $stringbelt_tail
272 br_if $copystringtostart
275 set_local $stringbelt_tail
277 get_local $stringbelt_head
280 get_local $stringbelt_head
283 set_local $stringbelt_head
287 get_local $stringbelt_head
294 set_local $stringbelt_head
296 get_local $stringbelt_head
297 get_local $stringbelt_head
298 tee_local $stringbelt_tail
303 set_local $stringbelt_head
430 get_local $wordbelt_tail
431 get_local $wordbelt_head
432 get_local $wordbelt_tail
436 tee_local $eax (; n bytes ;)
438 (; align to 32-bit ;)
439 get_local $wordbelt_head
444 set_local $wordbelt_head
446 get_local $wordbelt_tail
459 i32.const 14348 (; load BASE ;)
477 get_local $wordbelt_head
484 set_local $wordbelt_head
486 get_local $wordbelt_head
487 get_local $wordbelt_head
488 tee_local $wordbelt_tail
493 set_local $wordbelt_head
497 get_local $wordbelt_head
502 tee_local $wordbelt_head
503 get_local $wordbelt_tail
506 get_local $wordbelt_head
509 set_local $wordbelt_head
510 get_local $wordbelt_tail
513 set_local $wordbelt_tail
514 loop $copywordtostart
515 get_local $wordbelt_head
516 get_local $wordbelt_tail
519 get_local $wordbelt_head
522 set_local $wordbelt_head
523 get_local $wordbelt_tail
526 tee_local $wordbelt_tail
529 br_if $copywordtostart
532 set_local $wordbelt_tail
534 get_local $wordbelt_head
537 get_local $wordbelt_head
540 set_local $wordbelt_head
636 get_global $inbuf_size
638 get_local $inbuf_head
639 get_global $inbuf_data
643 get_local $inbuf_head
646 get_local $inbuf_head
649 set_local $inbuf_head
652 get_global $inbuf_size
654 get_global $inbuf_data
660 get_global $inbuf_size
664 get_global $inbuf_data
665 set_local $inbuf_head
668 i32.const -1 ;; <- keyval sent if sz == 0
707 get_local $stringbelt_tail
710 get_local $stringbelt_head
713 get_local $wordbelt_tail
716 get_local $wordbelt_head