[bootstrappable] Re: Bootstrapping from a hex editor

  • From: Ondřej Čertík <ondrej@xxxxxxxxx>
  • To: bootstrappable@xxxxxxxxxxxxx
  • Date: Thu, 09 Nov 2017 10:00:16 -0700



On Thu, Nov 9, 2017, at 05:40 AM, Orians, Jeremiah (DTMB) wrote:

Is your idea with M2-Planet that you write a simple C compile, and then 
implement it in assembly? 
Simplest C compiler that can compile mes.c or a functional equivalent
Then depending on which group gets their implementation done first, that
will be the language used
(Slow_lisp, FORTH or Assembly)

How many lines of assembly do you estimate that would be to maintain?
Given the current level of complexity about ~3000 lines of assembly

Ok, 3000 is actually not much. That would be viable.


One thing is that we can use gcc to generate the assembly and take it as 
our "implementation" and maintain that.
But the assembly will be long, and not really maintainable for me. 
We are not even going to consider that an option.
If a human doesn't write it, it doesn't count

One idea that I got is that the Forth implementation in assembly is only 
about ~1000 lines, so that's maintainable.
One could then compile C code to Forth, here is a proof of concept:
https://github.com/dmedinag/C-to-Forth-compiler
That requires Bison and GCC (no go)


I don't know what version of Forth that is using, and how hard it would be 
to target your assembly Forth implementation. 
GFORTH and stage0 FORTH is approximately 84% there thanks to reepca

I also don't know if all the C constructs that are needed for a C compiler 
can actually be directly translated to Forth.
We don't need ALL C constructs, only the minimal subset needed to
bootstrap mes.c

Then one can maintain the C code as the implementation, and the Forth code 
will be generated from it.
Generated code will NOT be used by stage0, only well commented code
written by humans will be used

I have a different opinion on this: for me a hand written code is not a
guarantee that it will be more readable or maintainable than a generated
code. As an example, a hand written parser does not guarantee that it
will be more readable for me than a Bison generated one. It can be more
readable, but it might also be less readable. As another example, a
generated assembly by gcc is not very readable for me, and I much prefer
a well documented hand written asssembly.


For bootstrapping only the Forth code will be used of course, but if it's 
readable and not much longer than the C code,
then I think that would serve the purpose, wouldn't it?
If you wish to write FORTH code for bootstrapping, it will be
appreciated.
If you wish to simplify MES.c such that the floor for bootstrapping is
lower, we will also appreciate that

It's this file right?

https://gitlab.com/janneke/mes/blob/ef69b7a28ab11581950afebc1ba3ad1844f20316/src/mes.c

Essentially, the helpful work would be to remove some C constructs in
that file (at the expense of possibly making the file longer), so that
your C compiler does not have to implement them, correct?

Ondrej

Other related posts: