From ca6ac0f9bfb321bf961adb230444cc4ee55d64a1 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Fri, 27 Feb 2026 16:20:11 +0000 Subject: [PATCH] Implement cold start --- wipforth.wat | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wipforth.wat b/wipforth.wat index c657a89..b38c21f 100644 --- a/wipforth.wat +++ b/wipforth.wat @@ -1651,6 +1651,10 @@ ;; => 0x28 bytes + ;; Cold start + + (data (i32.const 0x0ba0) "\78\0b\00\00") ;; QUIT + ;; 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 @@ -1668,8 +1672,7 @@ end) (func (export "reset") - i32.const 0xf000 global.set $sp ;; Set the stack pointer - ;; i32.const 0x???? global.set $ip ;; Set the IP to point at QUIT - ;; call $next - ;; call $trampoline - )) + i32.const 0xf000 global.set $sp ;; Set the stack pointer + i32.const 0x0ba0 global.set $ip ;; Set the IP to the cold start + call $next + call $trampoline))