From f314234078db58ba07d1c80f62a79f6ec27430e4 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 28 Feb 2026 17:36:16 +0000 Subject: [PATCH] Define [ and ] --- wipforth.wat | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wipforth.wat b/wipforth.wat index 35f6d31..4d36be3 100644 --- a/wipforth.wat +++ b/wipforth.wat @@ -1764,6 +1764,36 @@ "\04HALT\00\00\00" "\3e\00\00\00") + ;; And now to make myself obsolete as the compiler (finally) + + ;; : [ 0 STATE ! ; IMMEDIATE + + (data (i32.const 0x0c10) + "\00\0c\00\00" + "\81[\00\00" + "\00\00\00\00" + "\18\04\00\00" ;; LIT + "\00\00\00\00" ;; 0 + "\5c\05\00\00" ;; STATE + "\c0\03\00\00" ;; ! + "\0c\04\00\00") ;; EXIT + + ;; => 0x20 bytes + + ;; : ] 1 STATE ! ; + + (data (i32.const 0x0c30) + "\10\0c\00\00" + "\01]\00\00" + "\00\00\00\00" + "\18\04\00\00" ;; LIT + "\01\00\00\00" ;; 1 + "\5c\05\00\00" ;; STATE + "\c0\03\00\00" ;; ! + "\0c\04\00\00") ;; EXIT + + ;; => 0x20 bytes + ;; The trampoline is a workaround for WebAssembly's lack of indirect ;; jumps and code addresses. Instead of jumping into the next ;; codeword, NEXT sets the $fn global to the function index of the