Make linker more compact

There was a weird empty block in the middle of the program.
This commit is contained in:
Virgil Dupras 2020-05-03 20:33:36 -04:00
parent a96b5f1dec
commit 8ef197d248
5 changed files with 42 additions and 42 deletions

View File

@ -1 +1 @@
123 132 LOADR 123 131 LOADR

16
blk/129 Normal file
View File

@ -0,0 +1,16 @@
( Note that the last word is always skipped because it's not
possible to reliably detect its end. If you need that last
word, define a dummy word before calling RLDICT.
We first start by copying the affected area to H@+4. This is
where the relinking will take place.
Then we iterate the new dict from the top, keeping track of
wr, the current wordref and we, wr's end offset.
Initially, we get our wr and we, withH@ and CURRENT, which we
offset by u+4. +4 before, remember, we're using 4 bytes
as variable space.
At each iteration, we becomes wr-header and wr is fetched from
PREV field. )

32
blk/130
View File

@ -1,16 +1,16 @@
( Note that the last word is always skipped because it's not : RLDICT ( target offset -- )
possible to reliably detect its end. If you need that last H@ 2+ ! H@ ! ( H@+2 == offset, H@ == target )
word, define a dummy word before calling RLDICT. H@ @ WORD( DUP H@ -^ ( src u )
DUP ROT SWAP H@ 4 + ( u src u dst )
We first start by copying the affected area to H@+4. This is SWAP MOVE ( u )
where the relinking will take place. 4 + DUP CURRENT @ WORD( + ( u we )
DUP .X CRLF
Then we iterate the new dict from the top, keeping track of SWAP CURRENT @ PREV + DUP .X CRLF ( we wr )
wr, the current wordref and we, wr's end offset. BEGIN ( we wr )
DUP ROT ( wr wr we )
Initially, we get our wr and we, withH@ and CURRENT, which we H@ @ H@ 2+ @ ( wr wr we ol o )
offset by u+4. +4 before, remember, we're using 4 bytes 2SWAP RLWORD ( wr )
as variable space. DUP PREV SWAP ( wr oldwr )
WORD( SWAP ( we wr )
At each iteration, we becomes wr-header and wr is fetched from DUP 4 - H@ <= ( are we finished? )
PREV field. ) UNTIL H@ 4 + .X CRLF ;

25
blk/131
View File

@ -1,16 +1,9 @@
: RLDICT ( target offset -- ) ( Relink a regular Forth full interpreter. )
H@ 2+ ! H@ ! ( H@+2 == offset, H@ == target ) : RLCORE
H@ @ WORD( DUP H@ -^ ( src u ) LIT< H@ (find) DROP ( target )
DUP ROT SWAP H@ 4 + ( u src u dst ) DUP 3 - @ ( t prevoff )
SWAP MOVE ( u ) ( subtract H@ name length )
4 + DUP CURRENT @ WORD( + ( u we ) 2- ( t o )
DUP .X CRLF RLDICT
SWAP CURRENT @ PREV + DUP .X CRLF ( we wr ) ;
BEGIN ( we wr )
DUP ROT ( wr wr we )
H@ @ H@ 2+ @ ( wr wr we ol o )
2SWAP RLWORD ( wr )
DUP PREV SWAP ( wr oldwr )
WORD( SWAP ( we wr )
DUP 4 - H@ <= ( are we finished? )
UNTIL H@ 4 + .X CRLF ;

View File

@ -1,9 +0,0 @@
( Relink a regular Forth full interpreter. )
: RLCORE
LIT< H@ (find) DROP ( target )
DUP 3 - @ ( t prevoff )
( subtract H@ name length )
2- ( t o )
RLDICT
;