(; This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ;) (module (type $FUNCSIGi (func (result i32))) (type $FUNCSIGii (func (param i32))) (type $FUNCSIGiii (func)) (type $FUNCSIGiv (func (param i32 i32) (result i32))) (type $FUNCSIG$v (func (param i32) (result i32))) (type $FUNCSIG$vi (func (param i32 i32 i32) (result i32))) (import "env" "pop" (func $pop (result i32))) (import "env" "push" (func $push (param i32))) (import "env" "rinit" (func $rinit)) (import "env" "rpop" (func $rpop (result i32))) (import "env" "rpush" (func $rpush (param i32))) (import "env" "sys_read" (func $sys_read (param i32 i32 i32) (result i32))) (import "env" "sys_fetch" (func $sys_fetch (param i32 i32) (result i32))) (import "env" "sys_listen" (func $sys_listen (param i32) (result i32))) (import "env" "sys_write" (func $sys_write (param i32 i32 i32) (result i32))) (import "env" "sys_echo" (func $sys_echo (param i32))) (import "env" "sys_echochar" (func $sys_echochar (param i32))) (import "env" "sys_reflect" (func $sys_reflect (param i32))) (import "env" "vocab_get" (func $vocab_get (param i32 i32) (result i32))) (import "env" "vocab_set" (func $vocab_set (param i32 i32 i32) (result i32))) (import "env" "is_whitespace" (func $is_whitespace (param i32) (result i32))) (import "env" "sys_parsenum" (func $sys_parsenum (param i32 i32 i32) (result i32))) (import "env" "sys_stack" (func $sys_stack)) (import "env" "sys_words" (func $sys_words)) (table (;0;) 0 anyfunc) (memory $0 1) (; String Belt ;) ;; 0x0000 Size: 8192 (global $wordbelt i32 (i32.const 8192)) ;; 0x2000 Size: 4096 (global $inbuf i32 (i32.const 12288)) ;; 0x3000 Size: 2048 (global $inbuf_size i32 (i32.const 12292)) (global $inbuf_data i32 (i32.const 12296)) (global $kvars i32 (i32.const 14336)) ;; 0x3800 Size: 2048 (data (i32.const 12288) "\f8\07\00\00") ;; 2040 len (data (i32.const 14336) "\28\41\00\00") ;; MODE (data (i32.const 14340) "\04\42\00\00") ;; HERE (data (i32.const 14344) "\00\40\00\00") ;; START (data (i32.const 14348) "\0a\00\00\00") ;; BASE (data (i32.const 14352) "\00\00\00\00") ;; STRINGBELT_TAIL (data (i32.const 14356) "\00\00\00\00") ;; STRINGBELT_HEAD (data (i32.const 14360) "\00\20\00\00") ;; WORDBELT_TAIL (data (i32.const 14364) "\00\20\00\00") ;; WORDBELT_HEAD (data (i32.const 14368) "\00\00\00\00") ;; CHANNEL (; Quit ;) (data (i32.const 16384) "\03\00\00\00") ;; RINIT xt (data (i32.const 16388) "\10\40\00\00") ;; INTERPRET xt (data (i32.const 16392) "\12\00\00\00") ;; JMP xt (data (i32.const 16396) "\00\40\00\00") ;; quit location (16384) (; Interpret ;) (data (i32.const 16400) "\74\40\00\00") ;; WORD xt (16500) (data (i32.const 16404) "\06\00\00\00") ;; DUP (data (i32.const 16408) "\0e\00\00\00") ;; JZ: (data (i32.const 16412) "\38\40\00\00") ;; INTERP-END addr (16444) (data (i32.const 16416) "\02\00\00\00") ;; LIT xt (data (i32.const 16420) "\00\38\00\00") ;; MODE addr (14336) (data (i32.const 16424) "\0a\00\00\00") ;; @ (fetch) xt (data (i32.const 16428) "\0c\00\00\00") ;; EXECUTE xt (data (i32.const 16432) "\0d\00\00\00") ;; NOOP xt (data (i32.const 16436) "\01\00\00\00") ;; RET (data (i32.const 16440) "\10\00\00\00") ;; DROP <-- INTERP-END (data (i32.const 16444) "\10\00\00\00") ;; DROP (data (i32.const 16448) "\19\00\00\00") ;; BYE (; Word ;) (data (i32.const 16500) "\14\00\00\00") ;; WORDSTART (data (i32.const 16504) "\05\00\00\00") ;; KEY <-- KEYLOOP (data (i32.const 16508) "\06\00\00\00") ;; DUP (data (i32.const 16512) "\18\00\00\00") ;; J-1: 18 (data (i32.const 16516) "\f0\40\00\00") ;; addr of WORDEND (data (i32.const 16520) "\11\00\00\00") ;; WS? (data (i32.const 16524) "\0f\00\00\00") ;; JNZ: (data (i32.const 16528) "\bc\40\00\00") ;; addr of KEYDROP (data (i32.const 16532) "\02\00\00\00") ;; LIT (data (i32.const 16536) "\5c\00\00\00") ;; 92 (\ character) (data (i32.const 16540) "\25\00\00\00") ;; =? (data (i32.const 16544) "\0e\00\00\00") ;; JZ: (data (i32.const 16548) "\e4\40\00\00") ;; addr of DOCHAR (data (i32.const 16552) "\10\00\00\00") ;; DROP (data (i32.const 16556) "\94\41\00\00") ;; DO-BACKSLASH (continue using this wbuf we started) (data (i32.const 16560) "\0d\00\00\00") ;; NOOP (data (i32.const 16564) "\12\00\00\00") ;; JMP: (data (i32.const 16568) "\74\40\00\00") ;; addr of KEYLOOP-1 (get a new wbuf, call to wbuf+1 ate ours) (data (i32.const 16572) "\10\00\00\00") ;; DROP <-- KEYDROP (data (i32.const 16576) "\12\00\00\00") ;; JMP: (data (i32.const 16580) "\78\40\00\00") ;; addr of KEYLOOP (data (i32.const 16584) "\05\00\00\00") ;; KEY <-- WORDLOOP (data (i32.const 16588) "\11\00\00\00") ;; WS? (data (i32.const 16592) "\0f\00\00\00") ;; JNZ: (data (i32.const 16596) "\f0\40\00\00") ;; addr of WORDEND (data (i32.const 16600) "\06\00\00\00") ;; DUP (data (i32.const 16604) "\18\00\00\00") ;; J-1: (data (i32.const 16608) "\f0\40\00\00") ;; addr of WORDEND (data (i32.const 16612) "\13\00\00\00") ;; WORDPUTC <-- DOCHAR (data (i32.const 16616) "\12\00\00\00") ;; JMP: (data (i32.const 16620) "\c8\40\00\00") ;; addr of WORDLOOP (data (i32.const 16624) "\10\00\00\00") ;; DROP <-- WORDEND (data (i32.const 16628) "\17\00\00\00") ;; WORDFINISH (data (i32.const 16632) "\01\00\00\00") ;; RET (; Exec Mode ;) (data (i32.const 16680) "\1e\00\00\00") ;; DUP2 (data (i32.const 16684) "\15\00\00\00") ;; DICT_GET (data (i32.const 16688) "\06\00\00\00") ;; DUP (data (i32.const 16692) "\0e\00\00\00") ;; JZ: (data (i32.const 16696) "\4c\41\00\00") ;; donum -1 (16716) (data (i32.const 16700) "\1f\00\00\00") ;; ROT (data (i32.const 16704) "\20\00\00\00") ;; DROP2 (data (i32.const 16708) "\0c\00\00\00") ;; EXECUTE (data (i32.const 16712) "\01\00\00\00") ;; RET (data (i32.const 16716) "\10\00\00\00") ;; DROP (xt from dictionary) (data (i32.const 16720) "\16\00\00\00") ;; NUMBER <-- donum, pushes NUM, UNPARSED (data (i32.const 16724) "\06\00\00\00") ;; DUP (data (i32.const 16728) "\0f\00\00\00") ;; JNZ: (data (i32.const 16732) "\68\41\00\00") ;; donum_err (16744) (data (i32.const 16736) "\10\00\00\00") ;; DROP (data (i32.const 16740) "\01\00\00\00") ;; RET (data (i32.const 16744) "\10\00\00\00") ;; PARSE_ERR <-- donum_err (data (i32.const 16748) "\10\00\00\00") ;; ( DROP DROP ) (data (i32.const 16752) "\19\00\00\00") ;; BYE (; Do Backslash ;) (data (i32.const 16788) "\05\00\00\00") ;; KEY (data (i32.const 16792) "\11\00\00\00") ;; WS? (data (i32.const 16796) "\0f\00\00\00") ;; JNZ: (data (i32.const 16800) "\c8\41\00\00") ;; addr of keypump + 3 (data (i32.const 16804) "\cc\40\00\00") ;; WORDLOOP + 1 (data (i32.const 16808) "\28\41\00\00") ;; EXECUTE-MODE (data (i32.const 16812) "\01\00\00\00") ;; RET (; Do Comment ;) (data (i32.const 16828) "\18\00\00\00") ;; j-1: <-- keypump (data (i32.const 16832) "\e0\41\00\00") ;; addr of end (data (i32.const 16836) "\05\00\00\00") ;; KEY (data (i32.const 16840) "\02\00\00\00") ;; LIT (data (i32.const 16844) "\0a\00\00\00") ;; 10 (line feed) (data (i32.const 16848) "\25\00\00\00") ;; =? (data (i32.const 16852) "\0e\00\00\00") ;; JZ: (data (i32.const 16856) "\bc\41\00\00") ;; addr of keypump (data (i32.const 16860) "\10\00\00\00") ;; DROP (data (i32.const 16864) "\01\00\00\00") ;; RET (export "memory" (memory $0)) (export "main" (func $main)) (func $main (result i32) call $interpret ) (func $interpret (result i32) (local $here i32) (local $eax i32) (local $esi i32) (local $inbuf_head i32) (local $stringbelt_tail i32) (local $stringbelt_head i32) (local $wordbelt_tail i32) (local $wordbelt_head i32) (local $channel i32) i32.const 14340 i32.load set_local $here i32.const 14344 i32.load set_local $esi get_global $inbuf_data set_local $inbuf_head i32.const 14352 i32.load set_local $stringbelt_tail i32.const 14356 i32.load set_local $stringbelt_head i32.const 14360 i32.load set_local $wordbelt_tail i32.const 14364 i32.load set_local $wordbelt_head i32.const 14368 i32.load set_local $channel block $bye loop $next get_local $esi get_local $esi i32.const 4 i32.add set_local $esi i32.load set_local $eax loop $execloop block $default block $op0 block $ret block $lit block $rinit block $word block $key block $dup block $plus block $noop2 block $emit block $fetch block $set block $execute block $noop block $jz block $jnz block $drop block $wsbool block $jmp block $wordputc block $wordstart block $dictget block $parsenum block $wordfinish block $jneg1 block $swap block $words block $here block $dictset block $dup2 block $rot block $drop2 block $comma block $subtract block $keychan block $sethere block $eqbool block $echostring block $strstart block $strput block $strend get_local $eax br_table $op0 $ret (;2;)$lit $rinit (;4;)$word $key (;6;)$dup $plus (;8;)$jmp $emit (;10;)$fetch $set (;12;)$execute $noop (;14;)$jz $jnz (;16;)$drop $wsbool (;18;)$jmp $wordputc (;20;)$wordstart $dictget (;22;)$parsenum $wordfinish (;24;)$jneg1 $bye (;26;)$swap $words (;28;)$here $dictset (;30;)$dup2 $rot (;32;)$drop2 $comma (;34;)$subtract $keychan (;36;)$sethere $eqbool (;38;)$echostring $strstart (;40;)$strput $strend $default end ;; strend get_local $stringbelt_tail get_local $stringbelt_head get_local $stringbelt_tail i32.const 4 i32.add i32.sub tee_local $eax (; n bytes ;) i32.store (; align to 32-bit ;) get_local $stringbelt_head i32.const 3 i32.add i32.const 8188 i32.and set_local $stringbelt_head (; /align ;) get_local $stringbelt_tail i32.const 4 i32.add call $push get_local $eax call $push br $next end ;; strput block $sbhasspace2 get_local $stringbelt_head get_global $wordbelt i32.lt_u br_if $sbhasspace2 i32.const 0 tee_local $stringbelt_head get_local $stringbelt_tail i32.load i32.store get_local $stringbelt_head i32.const 4 i32.add set_local $stringbelt_head get_local $stringbelt_tail i32.const 4 i32.add set_local $stringbelt_tail loop $copystringtostart get_local $stringbelt_head get_local $stringbelt_tail i32.load16_u i32.store16 get_local $stringbelt_head i32.const 2 i32.add set_local $stringbelt_head get_local $stringbelt_tail i32.const 2 i32.add tee_local $stringbelt_tail get_global $wordbelt i32.le_u br_if $copystringtostart end i32.const 0 set_local $stringbelt_tail end get_local $stringbelt_head call $pop i32.store16 get_local $stringbelt_head i32.const 2 i32.add set_local $stringbelt_head br $next end ;; strstart block $sbhasspace get_local $stringbelt_head get_global $wordbelt i32.const 8 i32.sub i32.le_u br_if $sbhasspace i32.const 0 set_local $stringbelt_head end get_local $stringbelt_head get_local $stringbelt_head tee_local $stringbelt_tail i32.const 0 i32.store i32.const 4 i32.add set_local $stringbelt_head br $next end ;; echostring get_local $channel call $pop set_local $eax call $pop get_local $eax call $sys_write br $next end ;; eqbool block $equiv call $pop call $pop tee_local $eax i32.eq get_local $eax call $push br_if $equiv i32.const 0 call $push br $next end i32.const 1 call $push br $next end ;; sethere call $pop set_local $here br $next end ;; keychan call $pop set_local $channel br $next end ;; subtract call $pop set_local $eax call $pop get_local $eax i32.sub call $push br $next end ;; comma get_local $here call $pop i32.store get_local $here i32.const 4 i32.add set_local $here br $next end ;; drop2 call $pop call $pop drop drop br $next end ;; rot call $pop call $pop set_local $eax call $pop call $rpush call $push call $rpop call $push get_local $eax call $push br $next end ;; dup2 get_local $esi call $rpush call $pop set_local $eax call $pop tee_local $esi call $push get_local $eax call $push get_local $esi call $push get_local $eax call $push call $rpop set_local $esi br $next end ;; dictset call $pop call $rpush call $pop set_local $eax call $pop get_local $eax call $rpop call $vocab_set drop br $next end ;; here get_local $here call $push br $next end ;; words call $sys_words br $next end ;; swap call $pop call $pop set_local $eax call $push get_local $eax call $push br $next end ;; jneg1 block $jneg1if call $pop i32.const -1 i32.eq br_if $jneg1if get_local $esi i32.const 4 i32.add set_local $esi br $next end get_local $esi i32.load set_local $esi br $next end ;; wordfinish get_local $wordbelt_tail get_local $wordbelt_head get_local $wordbelt_tail i32.const 4 i32.add i32.sub tee_local $eax (; n bytes ;) i32.store (; align to 32-bit ;) get_local $wordbelt_head i32.const 3 i32.add i32.const 12284 i32.and set_local $wordbelt_head (; /align ;) get_local $wordbelt_tail i32.const 4 i32.add call $push get_local $eax call $push br $next end ;; parsenum call $pop call $rpush call $pop tee_local $eax call $rpop i32.const 14348 (; load BASE ;) i32.load call $sys_parsenum get_local $eax i32.load call $push call $push br $next end ;; dictget call $pop set_local $eax call $pop get_local $eax call $vocab_get call $push br $next end ;; wordstart block $wbhasspace get_local $wordbelt_head get_global $inbuf i32.const 8 i32.sub i32.le_u br_if $wbhasspace get_global $wordbelt set_local $wordbelt_head end get_local $wordbelt_head get_local $wordbelt_head tee_local $wordbelt_tail i32.const 0 i32.store i32.const 4 i32.add set_local $wordbelt_head br $next end ;; wordputc block $wbhasspace2 get_local $wordbelt_head get_global $inbuf i32.lt_u br_if $wbhasspace2 get_global $wordbelt tee_local $wordbelt_head get_local $wordbelt_tail i32.load i32.store get_local $wordbelt_head i32.const 4 i32.add set_local $wordbelt_head get_local $wordbelt_tail i32.const 4 i32.add set_local $wordbelt_tail loop $copywordtostart get_local $wordbelt_head get_local $wordbelt_tail i32.load16_u i32.store16 get_local $wordbelt_head i32.const 2 i32.add set_local $wordbelt_head get_local $wordbelt_tail i32.const 2 i32.add tee_local $wordbelt_tail get_global $inbuf i32.le_u br_if $copywordtostart end get_global $wordbelt set_local $wordbelt_tail end get_local $wordbelt_head call $pop i32.store16 get_local $wordbelt_head i32.const 2 i32.add set_local $wordbelt_head br $next end ;; jmp get_local $esi i32.load set_local $esi br $next end ;; wsbool call $pop tee_local $eax call $is_whitespace get_local $eax call $push call $push br $next end ;; drop call $pop drop br $next end ;; jnz block $jnzif call $pop i32.eqz br_if $jnzif get_local $esi i32.load set_local $esi br $next end get_local $esi i32.const 4 i32.add set_local $esi br $next end ;; jz block $jzif call $pop i32.eqz br_if $jzif get_local $esi i32.const 4 i32.add set_local $esi br $next end get_local $esi i32.load set_local $esi br $next end ;; noop br $next end ;; execute call $pop tee_local $eax i32.const 256 i32.lt_u br_if $execloop get_local $esi call $rpush get_local $eax set_local $esi br $next end ;; set call $pop set_local $eax call $pop get_local $eax i32.store br $next end ;; fetch call $pop i32.load call $push br $next end ;; emit (.) call $pop call $sys_echo br $next end ;; noop2 br $next end ;; plus call $pop call $pop i32.add call $push br $next end ;; dup call $pop tee_local $eax get_local $eax call $push call $push br $next end ;; key loop $key_loop block $key_read get_global $inbuf_size i32.load get_local $inbuf_head get_global $inbuf_data i32.sub i32.le_u br_if $key_read get_local $inbuf_head i32.load16_u call $push get_local $inbuf_head i32.const 2 i32.add set_local $inbuf_head br $next end ;; key_read get_global $inbuf_size get_local $channel get_global $inbuf_data get_global $inbuf i32.load call $sys_read i32.store block $nullread get_global $inbuf_size i32.load i32.eqz br_if $nullread get_global $inbuf_data set_local $inbuf_head br $key_loop end ;; nullread i32.const -1 ;; <- keyval sent if sz == 0 call $push br $next end ;; key_loop end ;; word br $next end ;; rinit call $rinit br $next end ;; lit get_local $esi get_local $esi i32.const 4 i32.add set_local $esi i32.load call $push br $next end ;; ret call $rpop set_local $esi br $next end ;; op0 get_local $esi call $sys_reflect br $bye end ;; default get_local $esi call $rpush get_local $eax set_local $esi br $next end ;; execloop end ;; nextl end ;; bye i32.const 14340 get_local $here i32.store i32.const 14352 get_local $stringbelt_tail i32.store i32.const 14356 get_local $stringbelt_head i32.store i32.const 14360 get_local $wordbelt_tail i32.store i32.const 14364 get_local $wordbelt_head i32.store i32.const 14368 get_local $channel i32.store i32.const 0 ) )