+ (;34;)$subtract $inchan (;36;)$sethere $eqbool (;38;)$echostring $strstart
+ (;40;)$strput $strend (;42;)$fetchinc $setinc (;44;)$finddoes $definedoes
+ (;46;)$stacktrace $webfetch (;48;)$outchan $read (;50;)$awaiting $openchannel
+ (;52;)$rpush_op $fetch8_u (;54;)$negrot $default
+ end ;; negrot
+ call $pop
+ call $pop
+ set_local $eax
+ call $pop
+ get_local $eax
+ call $push
+ set_local $eax
+ call $push
+ get_local $eax
+ call $push
+ br $next
+ end ;; fetch8_u
+ call $pop
+ i32.load8_u
+ call $push
+ br $next
+ end ;; rpush_op
+ call $pop
+ call $rpush
+ br $next
+ end ;; openchannel
+ (; Get addr of channel block ;)
+ get_global $channel_table_p
+ get_global $channel_entry_size
+ call $sys_open
+ tee_local $eax
+ call $rpush ;;save to rstack
+ get_local $eax
+ i32.mul
+ i32.add
+ (; Set Out-Channel to 1 by default ;)
+ tee_local $eax
+ i32.const 3
+ i32.add ;; out channel
+ i32.const 1
+ i32.store8
+ (; leave a copy of channel_p on stack ;)
+ get_local $eax
+ (; Get addr of ch-start and ch-default-start ;)
+ get_local $eax
+ i32.const 4
+ i32.add ;; addr of channel start
+ tee_local $eax
+ get_local $eax
+ i32.const 4
+ i32.add ;; addr of channel default start
+ (; Store the user-provided address in both ;)
+ call $pop
+ tee_local $eax
+ i32.store
+ get_local $eax
+ i32.store
+ (; go bo buf-base (channel_p + 12), put HERE in it ;)
+ tee_local $eax
+ i32.const 12
+ i32.add
+ get_local $here
+ i32.store
+ (; set buf-tail ;)
+ get_local $eax
+ i32.const 16
+ i32.add
+ get_local $here
+ i32.store
+ (; set buf-head ;)
+ get_local $eax
+ i32.const 20
+ i32.add
+ get_local $here
+ i32.store
+ (; set buf-bound ;)
+ get_local $eax
+ i32.const 24
+ i32.add
+ (; set buf-bound = here += 512 ;)
+ get_local $here
+ i32.const 512
+ i32.add
+ tee_local $here
+ i32.store
+ (; return channel number ;)
+ call $rpop
+ call $push
+ br $next
+ end ;; read
+ get_local $channel_in
+ call $pop ;; location to write
+ set_local $eax
+ call $pop
+ get_local $eax
+ call $sys_read
+ br $next
+ end ;; outchan
+ call $pop
+ set_local $channel_out
+ br $next
+ end ;; webfetch
+ call $pop ;; u
+ call $rpush
+ call $pop ;; addr
+ set_local $eax
+ call $pop ;; callback
+ get_local $eax
+ call $rpop
+ call $sys_fetch
+ i32.const -1
+ i32.eq
+ br_if $bye
+ br $next
+ end ;; stacktrace
+ get_local $esi
+ call $rpush
+ call $sys_stack
+ call $rpop
+ drop
+ br $next
+ end ;; definedoes
+ call $pop
+ call $rpush
+ call $pop
+ set_local $eax
+ call $pop
+ get_local $eax
+ call $rpop
+ call $does_set
+ br $next
+ end ;; finddoes
+ call $pop
+ set_local $eax
+ call $pop
+ get_local $eax
+ call $does_get
+ call $push
+ br $next
+ end ;; setinc
+ call $pop
+ tee_local $eax
+ call $pop
+ i32.store
+ get_local $eax
+ i32.const 4
+ i32.add
+ call $push
+ br $next
+ end ;; fetchinc
+ call $pop
+ tee_local $eax
+ i32.const 4
+ i32.add
+ call $push
+ get_local $eax
+ i32.load
+ call $push
+ br $next
+ 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_base
+ 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_base
+ 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_base
+ 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