Closed brtchip-paul-jiao closed 1 year ago
This project derived from one of my other projects, https://github.com/howerj/forth-cpu, for that project I wrote a toolchain in C that compiled a Forth like language for that Forth CPU. I then branched off an made the embed project, which then eventually became self hosting, and no longer required the cross-compiler. The embed project was then reintegrated in the Forth CPU project and the toolchain written in C was removed.
When porting to a new CPU/VM now I instead make a cross compiler written for GForth, which is easier to get things self hosting (which I did for the https://github.com/howerj/subleq and https://github.com/howerj/bit-serial Forth projects). The way this system became self-hosting was a lot more convoluted than normal.
The compiler and toolchain is in https://github.com/howerj/forth-cpu/tree/bd6d9daca39b5cac4b779ec37eb6e5939d3dc979 (in the h2.c file, the Forth interpreter in the h2.fth file).
Does this make sense?
@howerj Your explanation is good enough. Thanks you very much! Good to close the ticket.
@howerj Thanks for your great work! It is amazing!
I can see the image of VM is stored in the C array
embed_default_block
of image.c as below:when I checked the makefile, I can see this C array is derived from
embed.fth
byembed.exe -o embed-1.blk embed.fth
.However, the
embed.exe
above has been loaded into the image. It goes into chick&egg problem. I am wondering how we get the first VM image which can interpret embed.fth?I am stuck there, can help answer?