(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))) (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) (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) (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) (result i32))) (import "env" "vocab_set" (func $vocab_set (param i32) (param i32) (result i32))) (import "env" "is_whitespace" (func $is_whitespace (param i32) (result i32))) (import "env" "sys_parsenum" (func $sys_parsenum (param i32) (result i32))) (import "env" "sys_stack" (func $sys_stack)) (import "env" "sys_words" (func $sys_words)) (table (;0;) 0 anyfunc) (memory $0 1) (global $inbuf i32 (i32.const 8)) (global $inbuf_size i32 (i32.const 12)) (global $inbuf_data i32 (i32.const 16)) (global $wbuf i32 (i32.const 256)) (global $wbuf_data i32 (i32.const 260)) (data (i32.const 8) "\f4\00\00\00") ;; STDIN buf, 244 len (data (i32.const 256) "\7c\00\00\00") ;; WBUF, 124 len (data (i32.const 384) "\20\03\00\00") ;; MODE (data (i32.const 388) "\18\04\00\00") ;; HERE (data (i32.const 392) "\58\02\00\00") ;; START (data (i32.const 396) "\0a\00\00\00") ;; BASE (; Interpret ;) (data (i32.const 512) "\b8\02\00\00") ;; WORD xt (696) (data (i32.const 516) "\06\00\00\00") ;; DUP (data (i32.const 520) "\0a\00\00\00") ;; @ (data (i32.const 524) "\0e\00\00\00") ;; JZ: (data (i32.const 528) "\2c\02\00\00") ;; INTERP-END addr (556) (data (i32.const 532) "\02\00\00\00") ;; LIT xt (data (i32.const 536) "\80\01\00\00") ;; MODE addr (384) (data (i32.const 540) "\0a\00\00\00") ;; @ (fetch) xt (data (i32.const 544) "\0c\00\00\00") ;; EXECUTE xt (data (i32.const 548) "\0d\00\00\00") ;; NOOP xt (data (i32.const 552) "\01\00\00\00") ;; RET (data (i32.const 556) "\10\00\00\00") ;; DROP <-- INTERP-END (data (i32.const 560) "\19\00\00\00") ;; BYE (; Quit ;) (data (i32.const 600) "\03\00\00\00") ;; RINIT xt (data (i32.const 604) "\00\02\00\00") ;; INTERPRET xt (512) (data (i32.const 608) "\12\00\00\00") ;; JMP xt (data (i32.const 612) "\58\02\00\00") ;; quit location (600) (; Test instructions ;) (data (i32.const 640) "\02\00\00\00") ;; LIT (data (i32.const 644) "\02\00\00\00") ;; 2 (data (i32.const 648) "\06\00\00\00") ;; DUP (data (i32.const 652) "\07\00\00\00") ;; + (data (i32.const 656) "\09\00\00\00") ;; . (data (i32.const 660) "\12\00\00\00") ;; JMP (data (i32.const 664) "\58\02\00\00") ;; quit addr (; Word ;) (data (i32.const 696) "\14\00\00\00") ;; WB0 (data (i32.const 700) "\05\00\00\00") ;; KEY <-- KEYLOOP (data (i32.const 704) "\06\00\00\00") ;; DUP (data (i32.const 708) "\18\00\00\00") ;; J-1: 18 (data (i32.const 712) "\0c\03\00\00") ;; addr of WORDEND (data (i32.const 716) "\11\00\00\00") ;; WS? (data (i32.const 720) "\0e\00\00\00") ;; JZ: (data (i32.const 724) "\00\03\00\00") ;; addr of DOCHAR (data (i32.const 728) "\10\00\00\00") ;; DROP (data (i32.const 732) "\12\00\00\00") ;; JMP: (data (i32.const 736) "\bc\02\00\00") ;; addr of KEYLOOP (data (i32.const 740) "\05\00\00\00") ;; KEY <-- WORDLOOP (data (i32.const 744) "\11\00\00\00") ;; WS? (data (i32.const 748) "\0f\00\00\00") ;; JNZ: (data (i32.const 752) "\0c\03\00\00") ;; addr of WORDEND (data (i32.const 756) "\06\00\00\00") ;; DUP (data (i32.const 760) "\18\00\00\00") ;; J-1: (data (i32.const 764) "\0c\03\00\00") ;; addr of WORDEND (data (i32.const 768) "\13\00\00\00") ;; WPUTC <-- DOCHAR (data (i32.const 772) "\12\00\00\00") ;; JMP: (data (i32.const 776) "\e4\02\00\00") ;; addr of WORDLOOP (data (i32.const 780) "\10\00\00\00") ;; DROP <-- WORDEND (data (i32.const 784) "\02\00\00\00") ;; LIT (push addr of wbuf, 256) (data (i32.const 788) "\00\01\00\00") ;; wbuf addr (utf16 string) (data (i32.const 792) "\17\00\00\00") ;; WB!LEN (data (i32.const 796) "\01\00\00\00") ;; RET (; Exec Mode ;) (data (i32.const 800) "\06\00\00\00") ;; DUP (data (i32.const 804) "\15\00\00\00") ;; DICT_GET (data (i32.const 808) "\06\00\00\00") ;; DUP (data (i32.const 812) "\0e\00\00\00") ;; JZ: (data (i32.const 816) "\44\03\00\00") ;; donum (832) (data (i32.const 820) "\1a\00\00\00") ;; SWAP (data (i32.const 824) "\10\00\00\00") ;; DROP (data (i32.const 828) "\0c\00\00\00") ;; EXECUTE (data (i32.const 832) "\01\00\00\00") ;; RET (data (i32.const 836) "\10\00\00\00") ;; DROP (xt from dictionary) (data (i32.const 840) "\16\00\00\00") ;; NUMBER <-- donum, pushes NUM, UNPARSED (data (i32.const 844) "\06\00\00\00") ;; DUP (data (i32.const 848) "\0f\00\00\00") ;; JNZ: (data (i32.const 852) "\60\03\00\00") ;; donum_err (864) (data (i32.const 856) "\10\00\00\00") ;; DROP (data (i32.const 860) "\01\00\00\00") ;; RET (data (i32.const 864) "\10\00\00\00") ;; PARSE_ERR <-- donum_err (data (i32.const 868) "\10\00\00\00") ;; ( DROP DROP ) (data (i32.const 872) "\19\00\00\00") ;; BYE (; : definition ;) (data (i32.const 900) "\b8\02\00\00") ;; WORD (data (i32.const 904) "\1c\00\00\00") ;; HERE (data (i32.const 908) "\1d\00\00\00") ;; VOCAB_SET (data (i32.const 912) "\01\00\00\00") ;; RET (data (i32.const 1000) "\08\00\00\00") ;; "word" size (data (i32.const 1004) "w\00o\00r\00d\00") ;; utf16 (data (i32.const 1012) "\12\00\00\00") ;; "interpret" size (data (i32.const 1016) "i\00n\00t\00e\00r\00p\00r\00e\00t\00") ;; utf16 (data (i32.const 1034) "\00\00") ;; align 32-bit (data (i32.const 1036) "\08\00\00\00") ;; "quit" size (data (i32.const 1040) "q\00u\00i\00t\00") ;; utf16 (;HERE ---> 1048;) (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 $wbuf_head i32) i32.const 388 i32.load set_local $here i32.const 392 i32.load set_local $esi i32.const 16 set_local $inbuf_head i32.const 260 set_local $wbuf_head block $bye loop $next call $sys_stack get_local $esi call $sys_reflect 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 $wputc block $wbzero block $dictget block $parsenum block $wbsetlen block $jneg1 block $swap block $words block $here block $dictset 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 $wputc (;20;)$wbzero $dictget (;22;)$parsenum $wbsetlen (;24;)$jneg1 $bye (;26;)$swap $words (;28;)$here $dictset $default end ;; dictset call $pop set_local $eax call $pop get_local $eax 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 ;; wbsetlen get_global $wbuf get_local $wbuf_head get_global $wbuf_data i32.sub i32.store get_global $wbuf call $sys_reflect br $next end ;; parsenum i32.const 396 (; load BASE ;) i32.load call $pop tee_local $eax call $sys_parsenum call $push get_local $eax i32.load call $push br $next end ;; dictget call $pop call $vocab_get call $push br $next end ;; wbzero get_global $wbuf_data set_local $wbuf_head get_global $wbuf i32.const 0 i32.store br $next end ;; wputc get_local $wbuf_head call $pop i32.store16 get_local $wbuf_head i32.const 2 i32.add set_local $wbuf_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 call $sys_stack 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 i32.const 0 get_global $inbuf call $sys_read block $nullread get_global $inbuf_size i32.load i32.eqz br_if $nullread 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 $next end ;; default get_local $esi call $rpush get_local $eax set_local $esi br $next end ;; execloop end ;; nextl end ;; bye get_local $here ) )