mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 05:08:05 +11:00
Make DO .. LOOP binary code more compact
Only a few bytes saved in forth1.bin, but the DO .. LOOP construct isn't used much yet. It's still significant savings per LOOP call.
This commit is contained in:
parent
b8dd86bd18
commit
add3b6629b
@ -94,12 +94,20 @@
|
|||||||
H@
|
H@
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
|
||||||
|
( Increase loop counter and returns whether we should loop. )
|
||||||
|
: _
|
||||||
|
R> ( IP, keep for later )
|
||||||
|
R> 1 + ( ip i+1 )
|
||||||
|
DUP >R ( ip i )
|
||||||
|
I' = ( ip f )
|
||||||
|
SWAP >R ( f )
|
||||||
|
;
|
||||||
|
|
||||||
( One could think that we should have a sub word to avoid all
|
( One could think that we should have a sub word to avoid all
|
||||||
these COMPILE, but we can't because otherwise it messes with
|
these COMPILE, but we can't because otherwise it messes with
|
||||||
the RS )
|
the RS )
|
||||||
: LOOP
|
: LOOP
|
||||||
COMPILE R> 1 LITN COMPILE + COMPILE DUP COMPILE >R
|
COMPILE _ COMPILE (?br)
|
||||||
COMPILE I' COMPILE = COMPILE (?br)
|
|
||||||
H@ - ,
|
H@ - ,
|
||||||
COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP
|
COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
Loading…
Reference in New Issue
Block a user