mirror of
https://github.com/remko/waforth
synced 2024-12-26 09:59:09 +01:00
Compile push & pop using global TOS.
This commit is contained in:
parent
7c2bd40293
commit
98dbf19a45
1 changed files with 19 additions and 4 deletions
|
@ -1667,12 +1667,22 @@ EOF
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(func $compilePushConst (param $n i32)
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitConst (get_local $n))
|
||||
(call $emitICall (i32.const 1) (i32.const !pushIndex)))
|
||||
(call $emitStore)
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitConst (i32.const 4))
|
||||
(call $emitAdd)
|
||||
(call $emitSetGlobal (i32.const !tosIndex)))
|
||||
|
||||
(func $compilePushLocal (param $n i32)
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitGetLocal (get_local $n))
|
||||
(call $emitICall (i32.const 1) (i32.const !pushIndex)))
|
||||
(call $emitStore)
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitConst (i32.const 4))
|
||||
(call $emitAdd)
|
||||
(call $emitSetGlobal (i32.const !tosIndex)))
|
||||
|
||||
(func $compileIf
|
||||
(call $compilePop)
|
||||
|
@ -1796,9 +1806,14 @@ EOF
|
|||
(set_global $cp (i32.add (get_global $cp) (i32.const 1)))
|
||||
(i32.store8 (get_global $cp) (i32.const 0x00))
|
||||
(set_global $cp (i32.add (get_global $cp) (i32.const 1))))
|
||||
|
||||
|
||||
(func $compilePop
|
||||
(call $emitICall (i32.const 2) (i32.const !popIndex)))
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitConst (i32.const 4))
|
||||
(call $emitSub)
|
||||
(call $emitSetGlobal (i32.const !tosIndex))
|
||||
(call $emitGetGlobal (i32.const !tosIndex))
|
||||
(call $emitLoad))
|
||||
|
||||
|
||||
(func $compileCall (param $findToken i32)
|
||||
|
|
Loading…
Reference in a new issue