~vdupras/duskos

64208509a28101653791de438b1870b4a809a443 — Virgil Dupras 13 days ago 00206d2
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.
1 files changed, 5 insertions(+), 3 deletions(-)

M fs/xcomp/bootlo.fs
M fs/xcomp/bootlo.fs => fs/xcomp/bootlo.fs +5 -3
@@ 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