Add EXECUTE

This commit is contained in:
2026-02-28 02:06:51 +00:00
parent 093e4188bd
commit fa5a6dbb1d

View File

@@ -660,6 +660,15 @@
global.set $ip global.set $ip
call $next) call $next)
;; Execution
(func $execute
call $pop
global.set $cfa
global.get $cfa
i32.load
global.set $fn)
;; The codewords function table must contain every codeword we want ;; The codewords function table must contain every codeword we want
;; to be able to run, as it's indices into this table that can be ran ;; to be able to run, as it's indices into this table that can be ran
;; with call_indirect in the $trampoline loop. Fantastically, there ;; with call_indirect in the $trampoline loop. Fantastically, there
@@ -1068,13 +1077,13 @@
"\64\05\00\00" "\64\05\00\00"
"\04HERE\00\00\00" "\04HERE\00\00\00"
"\02\00\00\00" "\02\00\00\00"
"\b0\0b\00\00") "\c0\0b\00\00")
(data (i32.const 0x058c) (data (i32.const 0x058c)
"\78\05\00\00" "\78\05\00\00"
"\06LATEST\00" "\06LATEST\00"
"\02\00\00\00" "\02\00\00\00"
"\84\0b\00\00") "\b0\0b\00\00")
(data (i32.const 0x05a0) (data (i32.const 0x05a0)
"\8c\05\00\00" "\8c\05\00\00"
@@ -1572,7 +1581,7 @@
;; INVERT 0BRANCH [32] \ Jump straight to executing if so ;; INVERT 0BRANCH [32] \ Jump straight to executing if so
;; STATE @ 0BRANCH [16] \ Check state ;; STATE @ 0BRANCH [16] \ Check state
;; >CFA , EXIT \ Compile word ;; >CFA , EXIT \ Compile word
;; >CFA >R EXIT \ Execute word ;; >CFA EXECUTE EXIT \ Execute word
;; ;;
;; \ Handle number ;; \ Handle number
;; DROP \ Discard nil entry ;; DROP \ Discard nil entry
@@ -1614,7 +1623,7 @@
"\5c\0a\00\00" ;; , "\5c\0a\00\00" ;; ,
"\0c\04\00\00" ;; EXIT "\0c\04\00\00" ;; EXIT
"\28\08\00\00" ;; >CFA "\28\08\00\00" ;; >CFA
"\24\04\00\00" ;; >R "\bc\0b\00\00" ;; EXECUTE
"\0c\04\00\00" ;; EXIT "\0c\04\00\00" ;; EXIT
"\18\02\00\00" ;; DROP "\18\02\00\00" ;; DROP
"\08\02\00\00" ;; DUP "\08\02\00\00" ;; DUP
@@ -1659,6 +1668,14 @@
(data (i32.const 0x0bac) "\90\0b\00\00") ;; QUIT (data (i32.const 0x0bac) "\90\0b\00\00") ;; QUIT
;; Bro thought she didn't need EXECUTE
(elem (i32.const 0x38) $execute)
(data (i32.const 0x0bb0)
"\84\0b\00\00"
"\07EXECUTE"
"\38\00\00\00")
;; The trampoline is a workaround for WebAssembly's lack of indirect ;; The trampoline is a workaround for WebAssembly's lack of indirect
;; jumps and code addresses. Instead of jumping into the next ;; jumps and code addresses. Instead of jumping into the next
;; codeword, NEXT sets the $fn global to the function index of the ;; codeword, NEXT sets the $fn global to the function index of the