commit 64208509a28101653791de438b1870b4a809a443
parent 00206d22e94bc8d380236c200f54dd13d1aaa30c
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 17 May 2023 12:11:24 -0400
bootlo: rewrite "for" in HAL
Being used very often, the general speedup should be appreciable, especially
since we piggy-back on [+n], setting the Z flag. I didn't rewrite "for2"
because the logic is more complex in Low HAL without all branching conditions.
Not worth it.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -225,11 +225,13 @@ alias execute | immediate
: unyield BRSZ RSP) [+n], ; immediate
: break 16 rs+, [compile] ahead to _breaklbl ; immediate
-:iterator for ( n -- )
- ?dup if to i begin yield to1- i i not until then unyield ;
+:iterator for ( n -- ) [
+ 1 W+n, RSP) 4 +) !, drop, ahead
+ begin yield swap then -1 RSP) 4 +) [+n], NZ) branchC, drop
+ unyield exit,
:iterator for2 ( lo hi -- )
- 2dup < if to j to i begin yield to1+ i i j >= until else 2drop then unyield ;
+ to j to i i j < if begin yield to1+ i i j >= until then unyield ;
code fill ( a u c -- )
W>A, PSP) 4 +) @, W<>A, 1 PSP) [+n], begin \ A=a W=c P+0=u+1