Re: Fleet Forth design considerations
Posted: Tue Jun 02, 2020 9:12 pm
From the first version of Fleet Forth onward I've implemented what I think is the best EMPTY. I say this because I've seen what is a really bad implementation of EMPTY ( ahem, Blazin' Forth ).
When Fleet Forth cold starts after being loaded from disk, some of the user variables, up to and including DP the dictionary pointer, are initialized with default values from what some would call the 'boot area'. The first three user variable locations are reserved for multitasking.
This initial value for DP is used by EMPTY. This value CAN change. FORGET will set it to the minimum of its current address and HERE so this 'empty point' is never greater than the top of the dictionary. Saving the system as a new Forth will change the address of this location to the current value of DP.
EMPTY fetches this address from the boot area and sets FENCE equal to it then branches into FORGET to let FORGET do the heavy lifting of trimming back the VOC-LINK and vocabularies. 'THERE is a metacompiler label holding the address of this location.
The above is from the source the metacompiler uses to build a new kernel.
The new kernel is built in virtual memory ( the C64's REU ) and LABELs are compiled in host memory ( that's how I can have labels in the middle of a definition ).
When Fleet Forth cold starts after being loaded from disk, some of the user variables, up to and including DP the dictionary pointer, are initialized with default values from what some would call the 'boot area'. The first three user variable locations are reserved for multitasking.
Code: Select all
// FORTH SOURCE - BOOT AREA
HEX
LABEL BOOT
// SET CURRENT COLORS FOR TARGET
HOST D020 C@ 0F AND TARGET C,
HOST D021 C@ 0F AND TARGET C,
HOST 286 C@ 0F AND TARGET C,
LABEL USER.DATA
// SYSTEM USER AREA BOOTUP VALUES
USER.AREA , // ENTRY
0 , // WAKE?
0 , // TOS
1FF , // RP0
7E , // SP0
1E , // SPLIM
// AUXILIARY STACK
AUX.BASE AUX.SIZE + , // AP0
AUX.BASE , // APLIM
HERE TIS 'THERE
0 , // DP
EMPTY fetches this address from the boot area and sets FENCE equal to it then branches into FORGET to let FORGET do the heavy lifting of trimming back the VOC-LINK and vocabularies. 'THERE is a metacompiler label holding the address of this location.
Code: Select all
: EMPTY ( -- )
FORTH DEFINITIONS
[ 'THERE ] LITERAL @
DUP FENCE !
// BRANCH INTO FORGET
BRANCH [ (FORGET) , ]
; -2 ALLOT
: FORGET ( -- )
SINGLE
NAME CURRENT @ DUP CONTEXT !
VFIND 0= ?HUH >LINK
LABEL (FORGET) \ EMPTY branches to this location
DUP>R FENCE @ U< R@
LIT
LABEL KERNEL-FENCE
[ 0 , ] // WILL BE PATCHED
// REST OF FORGET
The new kernel is built in virtual memory ( the C64's REU ) and LABELs are compiled in host memory ( that's how I can have labels in the middle of a definition ).