Remove Linker
Now that the boot binary is fully cross-compiled, there's no use for the linker anymore. Theoretically, it could still be useful, but I can't think of a real use case. Let's take it out of the picture. If it's ever needed again, I'll know where to find it.
This commit is contained in:
parent
ed2b91411a
commit
4c1cacd8d0
2
blk/001
2
blk/001
@ -2,7 +2,7 @@ MASTER INDEX
|
||||
|
||||
3 Usage 30 Dictionary
|
||||
70 Implementation notes 100 Block editor
|
||||
120 Linker 150 Extra words
|
||||
150 Extra words
|
||||
200 Z80 assembler 260 Cross compilation
|
||||
280 Z80 boot code 350 Core words
|
||||
410 PS/2 keyboard subsystem 420 Bootstrap guide
|
||||
|
16
blk/120
16
blk/120
@ -1,16 +0,0 @@
|
||||
Linker
|
||||
|
||||
Relink a dictionary by applying offsets to all word references
|
||||
in words of the "compiled" type.
|
||||
|
||||
A typical usage of this unit would be to, right after a
|
||||
bootstrap-from-icore-from-source operation, identify the root
|
||||
word of the source part, probably "H@", and run " ' thatword
|
||||
RLDICT ". Then, take the resulting relinked binary, concatenate
|
||||
it to the boot binary, and write to boot media.
|
||||
|
||||
LIMITATIONS
|
||||
|
||||
This unit can't automatically detect all offsets needing
|
||||
relinking. This is a list of situations that aren't handled:
|
||||
(cont.)
|
8
blk/121
8
blk/121
@ -1,8 +0,0 @@
|
||||
Cells: It's not possible to know for sure whether a cellWord
|
||||
contains an address or a number. They are therefore not
|
||||
automatically relinked. You have to manually relink each of
|
||||
them with RLCELL. In the case of a DOES> word, PFA+2, which
|
||||
is always an offset, is automatically relinked, but not
|
||||
PFA+0.
|
||||
|
||||
Load with "122 LOAD"
|
15
blk/123
15
blk/123
@ -1,15 +0,0 @@
|
||||
( Skip atom, considering special atom types. )
|
||||
: ASKIP ( a -- a+n )
|
||||
DUP @ ( a n )
|
||||
( ?br or br or NUMBER )
|
||||
DUP 0x67 = OVER 0x53 = OR OVER 0x20 = OR OVER 0x24 = OR
|
||||
IF DROP 4 + EXIT THEN
|
||||
( regular word )
|
||||
0x22 = NOT IF 2+ EXIT THEN
|
||||
( it's a lit, skip to null char )
|
||||
( a )
|
||||
1+ ( we skip by 2, but the loop below is pre-inc... )
|
||||
BEGIN 1+ DUP C@ NOT UNTIL
|
||||
( skip null char )
|
||||
1+
|
||||
;
|
11
blk/124
11
blk/124
@ -1,11 +0,0 @@
|
||||
( RLATOM pre-comment
|
||||
|
||||
Relink atom at a, applying offset o with limit ol.
|
||||
Returns a, appropriately skipped.
|
||||
|
||||
0x24 = IF: 0x24 is an addrWord, which should be offsetted in
|
||||
the same way that a regular word would. To achieve this, we
|
||||
skip ASKIP and instead of skipping 4 bytes like a numberWord,
|
||||
we skip only 2, which means that our number will be treated
|
||||
like a regular wordref. )
|
||||
|
16
blk/125
16
blk/125
@ -1,16 +0,0 @@
|
||||
: RLATOM ( a o ol -- a+n )
|
||||
ROT ( o ol a )
|
||||
DUP @ ( o ol a n )
|
||||
DUP 0x24 = IF
|
||||
DROP 2+ ( o ol a+2 )
|
||||
ROT ROT 2DROP ( a ) EXIT
|
||||
THEN
|
||||
ROT ( o a n ol )
|
||||
< IF ( under limit, do nothing )
|
||||
NIP ( a )
|
||||
ELSE ( o a )
|
||||
TUCK @ ( a o n )
|
||||
-^ ( a n-o )
|
||||
OVER ! ( a )
|
||||
THEN
|
||||
ASKIP ;
|
15
blk/126
15
blk/126
@ -1,15 +0,0 @@
|
||||
( RLWORD pre-comment
|
||||
|
||||
Relink a word with specified offset. If it's not of the type
|
||||
"compiled word", ignore. If it is, advance in word until a2
|
||||
is met, and for each word that is above ol, reduce that
|
||||
reference by o.
|
||||
Arguments: a1: wordref a2: word end addr o: offset to apply
|
||||
ol: offset limit. don't apply on refs under it.
|
||||
|
||||
The 0x0e and 0x2b check at the beginning is to ensure we have
|
||||
either a compiledWord or a doesWord. If we don't, we do
|
||||
nothing. The further 0x2b check is because if we have a
|
||||
doesWord, we start 2 bytes later.
|
||||
)
|
||||
|
16
blk/127
16
blk/127
@ -1,16 +0,0 @@
|
||||
: RLWORD ( ol o a1 a2 -- )
|
||||
SWAP DUP C@ ( ol o a2 a1 n )
|
||||
DUP 0x0e = OVER 0x2b = OR NOT IF
|
||||
( unwind all args ) 2DROP 2DROP EXIT THEN
|
||||
0x2b = IF 2+ THEN ( ol o a2 a1 )
|
||||
1+ ( ol o a2 a1+1 )
|
||||
BEGIN ( ol o a2 a1 )
|
||||
2OVER SWAP ( ol o a2 a1 o ol )
|
||||
RLATOM ( ol o a2 a+n )
|
||||
2DUP < IF ABORT THEN ( Something is very wrong )
|
||||
2DUP = ( ol o a2 a+n f )
|
||||
IF ( unwind )
|
||||
2DROP 2DROP EXIT
|
||||
THEN
|
||||
AGAIN
|
||||
;
|
16
blk/128
16
blk/128
@ -1,16 +0,0 @@
|
||||
( RLDICT pre-comment: Copy dict from target wordref, including
|
||||
header, up to HERE. We're going relocate those words by
|
||||
specified offset. To do this, we're copying this whole memory
|
||||
area in HERE and then iterate through that copied area and call
|
||||
RLWORD on each word. That results in a dict that can be
|
||||
concatenated to target's prev entry in a more compact way.
|
||||
|
||||
This copy of data doesn't allocate anything, so H@ doesn't
|
||||
move. Moreover, we reserve 4 bytes at H@ to write our target
|
||||
and offset because otherwise, things get too complicated with
|
||||
the PSP.
|
||||
|
||||
The output of this word is 3 numbers: top copied address, top
|
||||
copied CURRENT, and then the beginning of the copied dict at
|
||||
the end to indicate that we're finished processing.
|
||||
cont. )
|
16
blk/129
16
blk/129
@ -1,16 +0,0 @@
|
||||
( 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. )
|
16
blk/130
16
blk/130
@ -1,16 +0,0 @@
|
||||
: RLDICT ( target offset -- )
|
||||
H@ 2+ ! H@ ! ( H@+2 == offset, H@ == target )
|
||||
H@ @ WORD( DUP H@ -^ ( src u )
|
||||
DUP ROT SWAP H@ 4 + ( u src u dst )
|
||||
SWAP MOVE ( u )
|
||||
4 + DUP CURRENT @ WORD( + ( u we )
|
||||
DUP .X NL
|
||||
SWAP CURRENT @ PREV + DUP .X NL ( 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 NL ;
|
Loading…
Reference in New Issue
Block a user