rrthomas / pforth

A portable Forth compiler
GNU General Public License v3.0
11 stars 1 forks source link

Separate compilation on bee-asm branch #46

Open rrthomas opened 4 years ago

rrthomas commented 4 years ago

Currently pForth is compiled to a single assembly file. If that file is split into two parts, primitives.s and highlevel.s, and those two parts are assembled separately, then the resulting object files can be linked to give an image with the following caveats:

  1. _does labels need to be public (this is only needed for _28_CREATE_29__does).
  2. --warn-unresolved-symbols must be passed to ld so that it does not give an error for all the undefined _compilation symbols.
  3. The files must be linked in the right order (bee-ld --warn-unresolved-symbols primitives.o highlevel.o) so that the word list links work. This could presumably be fixed by making those links symbolic (and global).
  4. The initial branch must be in the first file linked; maybe this could be fixed by calling it _start? Or does that not in itself cause the linker to put it first?
  5. POSTPONEd addresses would also need to be symbolic.
  6. Relatedly, it would be nice to use a suitable alignment directive instead of emitting 0x20 bytes for spaces in the header fields.
rrthomas commented 4 years ago

Also try separate compilation of applications, e.g. life.fs. Current problems:

  1. Multiple definitions (assembly and linking works with -z muldefs, but don't know yet if it does the right thing).
  2. Linking life.o with primitives.o and highlevel.o does not change the initial branch or dictionary list, so although the Life words are compiled into the image, they are not visible on start-up.