Hello,
I am currently working on a very ambitious project, namely rebuilding FlashForth for ARDUINO, but going through meta-compilation.
For that, I go through gForth.
I'm adapting a PHENIX meta-compiler that I used almost 30 years ago under MS-DOS (Turbo-FORTH).
My project is visible here: https://github.com/MPETREMANN11/gFORTH/tree/master/meta
Currently I manage to manage the creation of FORTH primitives. Example, assembly code:
INVERT_L:
.db NFA|INLINE|6, "invert",0
INVERT:
com tosl
com tosh
ret
I don't need to manage the NFA fields. Links are created upon creation of a word by code <name>
The interest of meta-compilation:
- use FORTH as a compiler generator
- reduce assembly code to only primitives that cannot be coded in FORTH language
- reusability of ":" type words (colon) with all processors</name>
GOAL:
once the meta-compilation is successful for the AVR processor, it is enough to create an Xassembler (cross assembler) adapted to another processor and to rewrite the only assembler primitives in core.txt to generate a new FlashForth for this other processor.
Good luck with that.
But please change the name of your Forth to something else than FlashForth.
I am quite sure it will be a different system in the end.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
At the moment, my project is in its early stages.
As I explained, I am starting from PHENIX, a meta-compiler created by myself and Michel ZUPAN for an F83 version under MS-DOS. PHENIX itself is an adaptation of the meta-compiler created by Laxen and Perry.
I had always felt the enormous potential of PHENIX, but I never had the opportunity to put into practice the ideas, one in particular: the meta-generation of code for a processor other than that of the PC.
I analyzed the source code in FlashForth assembler. And I thought to myself that there was an opportunity to recreate FlashForth, but to use the metacompilation instead of going through a classic assembler.
To get there, I need to do two essential things:
1) adapt PHENIX to gForth. gForth has a 32-bit stack and 64-bit CELLs. This forces you to debug many pieces of code like , or ! which cannot be used directly for an AVR target
2) rewrite the FlashForth code to be compatible with PHENIX.
This second part is not the most difficult.
I am rewriting FlashForth, not that I am re-creating a FlashForth version.
I know what I'm starting with, I know where I am, but I still have an uncertain idea of the end result.
PHENIX has a so-called "slave compilation" mechanism allowing to generate a very compact target. The principle was already operational on version 8086 under MS-DOS. It consists in pointing out all the words used by the final application, then generating in the target only the executable code of the words useful for this application.
The end goal, if I get there with the PHENIX <--> FlashForth adaptation, is to allow a Forth application for FlashForth to be meta-generated in compact mode:
- the developer creates his application with FlashForth
- once tested and operational, this same code is integrated into the project to be meta-compiled
- PHENIX generates a compact executable code ready to install on an ARDUINO card, without a bootloader.
But before we get there, I will already be satisfied to produce a "FlashForth" for ARDUINO 100% compatible and similar to FF 5.0
At this point, the content of the core.txt file would be easily adaptable for another target processor. Certainly easier than the current assembly code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am currently working on a very ambitious project, namely rebuilding FlashForth for ARDUINO, but going through meta-compilation.
For that, I go through gForth.
I'm adapting a PHENIX meta-compiler that I used almost 30 years ago under MS-DOS (Turbo-FORTH).
My project is visible here:
https://github.com/MPETREMANN11/gFORTH/tree/master/meta
Currently I manage to manage the creation of FORTH primitives. Example, assembly code:
which becomes in my "core.txt";
I don't need to manage the NFA fields. Links are created upon creation of a word by code <name>
The interest of meta-compilation:
- use FORTH as a compiler generator
- reduce assembly code to only primitives that cannot be coded in FORTH language
- reusability of ":" type words (colon) with all processors</name>
GOAL:
once the meta-compilation is successful for the AVR processor, it is enough to create an Xassembler (cross assembler) adapted to another processor and to rewrite the only assembler primitives in core.txt to generate a new FlashForth for this other processor.
For now, the adaptation is still in its early stages. But if you are interested in this work, there is a series of articles visible here:
https://arduino-forth.com/article/FORTH_metacompilation_intro
BR
Last edit: PETREMANN 2021-04-30
Good luck with that.
But please change the name of your Forth to something else than FlashForth.
I am quite sure it will be a different system in the end.
Hello,
At the moment, my project is in its early stages.
As I explained, I am starting from PHENIX, a meta-compiler created by myself and Michel ZUPAN for an F83 version under MS-DOS. PHENIX itself is an adaptation of the meta-compiler created by Laxen and Perry.
I had always felt the enormous potential of PHENIX, but I never had the opportunity to put into practice the ideas, one in particular: the meta-generation of code for a processor other than that of the PC.
I analyzed the source code in FlashForth assembler. And I thought to myself that there was an opportunity to recreate FlashForth, but to use the metacompilation instead of going through a classic assembler.
To get there, I need to do two essential things:
1) adapt PHENIX to gForth. gForth has a 32-bit stack and 64-bit CELLs. This forces you to debug many pieces of code like , or ! which cannot be used directly for an AVR target
2) rewrite the FlashForth code to be compatible with PHENIX.
This second part is not the most difficult.
I am rewriting FlashForth, not that I am re-creating a FlashForth version.
I know what I'm starting with, I know where I am, but I still have an uncertain idea of the end result.
PHENIX has a so-called "slave compilation" mechanism allowing to generate a very compact target. The principle was already operational on version 8086 under MS-DOS. It consists in pointing out all the words used by the final application, then generating in the target only the executable code of the words useful for this application.
The end goal, if I get there with the PHENIX <--> FlashForth adaptation, is to allow a Forth application for FlashForth to be meta-generated in compact mode:
- the developer creates his application with FlashForth
- once tested and operational, this same code is integrated into the project to be meta-compiled
- PHENIX generates a compact executable code ready to install on an ARDUINO card, without a bootloader.
But before we get there, I will already be satisfied to produce a "FlashForth" for ARDUINO 100% compatible and similar to FF 5.0
At this point, the content of the core.txt file would be easily adaptable for another target processor. Certainly easier than the current assembly code.