-
Notifications
You must be signed in to change notification settings - Fork 12
Description
As Sam described here, currently user-defined forth words are embedded as compact ascii text and compiled at startup:
... forth_words.fs and user_words.fs ... contain Forth code that is run at startup - the code is stored in the binary as strings and then EVALUATE is run on those strings at startup. ... There is a python program to strip the comments and replace all whitespace with a single space between words (to shrink the strings down as much as possible) ...
This is fine as long as your forth is not too big, since otherwise you waste the space of the ascii representation that's only used once.
I'm curious if this compilation could be done as part of the build process, i.e. compile a preliminary binary without the user words, and use that binary in a simulator to compile the user words in a way that could be appended to the native words.
It would presumably require temporarily moving the 'here' pointer to wherever you want the native words to end up in the final image, or that the generated code is all relocatable? Or making the compiler generate a relocation table 😅
I suppose it also gets fiddly if you're trying to target a native platform where addresses might be different than how they look in the simulator?