Implement BRANCH and 0BRANCH
This commit is contained in:
35
wipforth.wat
35
wipforth.wat
@@ -625,6 +625,29 @@
|
||||
|
||||
call $next)
|
||||
|
||||
;; Branching
|
||||
|
||||
(func $branch
|
||||
global.get $ip
|
||||
i32.load
|
||||
global.get $ip
|
||||
i32.add
|
||||
global.set $ip
|
||||
call $next)
|
||||
|
||||
(func $zbranch
|
||||
call $pop
|
||||
if (result i32)
|
||||
global.get $ip
|
||||
i32.load
|
||||
else
|
||||
i32.const 4
|
||||
end
|
||||
global.get $ip
|
||||
i32.add
|
||||
global.set $ip
|
||||
call $next)
|
||||
|
||||
;; 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
|
||||
;; with call_indirect in the $trampoline loop. Fantastically, there
|
||||
@@ -955,6 +978,18 @@
|
||||
"\04EMIT\00\00\00"
|
||||
"\35\00\00\00")
|
||||
|
||||
(elem (i32.const 0x36) $branch)
|
||||
(data (i32.const 0x0498)
|
||||
"\88\04\00\00"
|
||||
"\06BRANCH\00"
|
||||
"\36\00\00\00")
|
||||
|
||||
(elem (i32.const 0x37) $branch)
|
||||
(data (i32.const 0x04a8)
|
||||
"\98\04\00\00"
|
||||
"\070BRANCH"
|
||||
"\37\00\00\00")
|
||||
|
||||
;; Built-in constants and variables
|
||||
|
||||
;; (data (i32.const 0x????)
|
||||
|
||||
Reference in New Issue
Block a user