diff options
| -rw-r--r-- | execution-support.e | 4 | ||||
| -rw-r--r-- | execution.e | 24 | ||||
| -rw-r--r-- | transform.e | 9 |
3 files changed, 31 insertions, 6 deletions
diff --git a/execution-support.e b/execution-support.e index 05dfe6d..a3d0ca5 100644 --- a/execution-support.e +++ b/execution-support.e @@ -36,6 +36,7 @@ ~ ~ (output point -- output point) : pack-next + ~ : "next" macro ~ Copy the next word's address from *rsi into rax. Increment rsi (as per ~ the DF flag). lods64 @@ -66,6 +67,7 @@ ~ ~ (output point, target address -- output point) : pack-beforenext + ~ : "beforenext" macro ~ Do a permanent transfer of control by setting rax and invoking the ~ codeword. Of course, we could jump to docol ourselves but this will work ~ regardless of what the receiving codeword is. @@ -97,11 +99,13 @@ ~ ~ (output point, source register -- output point) : pack-pushcontrol + ~ : "pushcontrol" macro swap :rbp -8 :rbp lea-reg64-disp8-reg64 swap :rbp 0 mov-disp8-reg64-reg64 ; ~ (output point, target register -- output point) : pack-popcontrol + ~ : "popcontrol" macro :rbp 0 3roll mov-reg64-disp8-reg64 :rbp 8 :rbp lea-reg64-disp8-reg64 ; diff --git a/execution.e b/execution.e index 649784c..3800e16 100644 --- a/execution.e +++ b/execution.e @@ -248,7 +248,6 @@ ~ : the Forth execution environment, then invoking the warm-start routine, ~ : which is defined below. ~ : blank-line - ~ : blank-line ~ : indent current-offset L' cold-start set-label @@ -446,7 +445,6 @@ ~ : occurs after the warm-start routine in the executable, which means these ~ : are forward references to words defined far below. ~ : blank-line - ~ : blank-line ~ : indent ~ While it's not actually a requirement that codeword pointers be @@ -510,29 +508,44 @@ ~ within itself. L@' log-load-log offset-to-target-address-space pack64 + ~ : -8 log-load-log (codeword pointer) L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" log" packstring 8 packalign L@' log-load-variable offset-to-target-address-space pack64 + ~ : -8 log-load-variable (codeword pointer) L@' log-load-s0 offset-to-target-address-space pack64 + ~ : -8 log-load-s0 (codeword pointer) L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" s0" packstring 8 packalign L@' log-load-variable offset-to-target-address-space pack64 + ~ : -8 log-load-variable (codeword pointer) L@' log-load-r0 offset-to-target-address-space pack64 + ~ : -8 log-load-r0 (codeword pointer) L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" r0" packstring 8 packalign L@' log-load-variable offset-to-target-address-space pack64 + ~ : -8 log-load-variable (codeword pointer) L@' log-load-latest offset-to-target-address-space pack64 + ~ : -8 log-load-latest (codeword pointer) L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" latest" packstring 8 packalign L@' log-load-variable offset-to-target-address-space pack64 + ~ : -8 log-load-variable (codeword pointer) L@' log-load-here offset-to-target-address-space pack64 + ~ : -8 log-load-here (codeword pointer) L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" here" packstring 8 packalign L@' log-load-variable offset-to-target-address-space pack64 + ~ : -8 log-load-variable (codeword pointer) ~ Having done that, nothing else needs to be defined in an unusual way, so ~ we can go ahead and dispatch to the log-load transform, and do the rest of @@ -555,12 +568,17 @@ ~ The next layer is built now, so let's move on to it. L@' litstring offset-to-target-address-space pack64 + ~ : -8 litstring (codeword pointer) s" quit" packstring 8 packalign L@' log-load-find-execution-token offset-to-target-address-space pack64 + ~ : -8 log-load-find-execution-token (codeword pointer) L@' swap offset-to-target-address-space pack64 - ~ Get rid of that heap pointer on the stack, we're finally done with it! + ~ : -8 swap (codewored pointer) + ~ : Get rid of that heap pointer on the stack, we're finally done with it! L@' drop offset-to-target-address-space pack64 + ~ : -8 drop (codeword pointer) L@' execute offset-to-target-address-space pack64 + ~ : -8 execute (codeword pointer) ~ : deindent ; diff --git a/transform.e b/transform.e index c9b06af..ee4f113 100644 --- a/transform.e +++ b/transform.e @@ -1541,7 +1541,6 @@ allocate-transformation-state s" transformation-state" variable ~ : The warm-start routine relies on words defined by the label transform, ~ : as does the log-load routine. ~ : blank-line - ~ : blank-line main-input-buffer dup push-input-buffer 3roll attach-string-to-input-buffer @@ -2295,7 +2294,7 @@ allocate-transformation-state s" transformation-state" variable swap-transform-variables offset-to-target-address-space , - ~ : -8 log-load-comma (codeword pointer) + ~ : -8 log-load-find (codeword pointer) ~ We leave an execution token on the log-load-time stack, so no delta ~ needed. @@ -2620,7 +2619,9 @@ allocate-transformation-state s" transformation-state" variable ~ This is an immediate effect, so once we've done it, we update the user ~ stack depth. An integer literal is a stack-depth delta of 1. swap-transform-variables L@' lit swap-transform-variables - offset-to-target-address-space , , + offset-to-target-address-space , ~ : -8 lit (codeword pointer) + ~ : provide-hex + , ~ : -8 # (integer literal) 1 transform-apply-stack-delta 0 exit } if @@ -2674,6 +2675,7 @@ allocate-transformation-state s" transformation-state" variable { ~ Again just like in label-transform, we declare our use of the label ~ and get a value for it. + ~ : provide-string-copy swap-transform-variables intern-label use-label swap-transform-variables @@ -2687,6 +2689,7 @@ allocate-transformation-state s" transformation-state" variable ~ This is an immediate effect, so once we've done that, we update the ~ user stack depth. offset-to-target-address-space , + ~ : -8 # (codeword pointer) transform-apply-stack-delta dropstring 0 exit } if |