[rb-general] Stage0 Release 0.4.0, M2-Planet Release 1.5.0 and mescc-tools-seed Release 1.2

Orians, Jeremiah (DTMB) OriansJ at michigan.gov
Tue Feb 4 13:42:41 UTC 2020


> WOW! That is an impressive list. And in 4 hours.
Really ends the debate about how to bootstrap C compilers in my book

> Is there something I can play with on my 32-bit ppc machine to add to the list?

Well if you are willing to do some testing it is really trivial to get a new architecture into mescc-tools and M2-Planet (I can handle the conversion to cc_* rather quickly)

First you'll want to figure out how the architecture expresses immediates and offsets; hex2 is the place where those architecture specific details are leveraged (https://github.com/oriansj/mescc-tools/blob/master/hex2_linker.c) 
(rasm2 and gdb are extremely handy here)

This will give you the answers to hex2 --architecture powerpc32 (or what ever name you want really) --{Big/Little}Endian -f elf-header.hex2 -f test.hex2 -- exec_enable -o binary
Which will generate working binaries for that architecture from hex2 sources

Next you'll want to figure out how the bits of the instructions are actually laid out and M1 definitions are a quick way to get to that quickly (https://github.com/oriansj/mescc-tools/blob/master/M1-macro.c)

This will give you the answers to M1 --architecture powerpc32 (or what ever name you want really) --{Big/Little}Endian -f defs.M1 -f test.M1 -o test.hex2
Which can be passed to hex2 (with the previously created elf-header) and generate a working binary for that architecture.

After that one needs to figure out what M1 defs would be required (This should give you a simple example of what would be required https://github.com/oriansj/stage0/blob/master/stage2/High_level_prototypes/cc_x86/cc_core.c ) 

Which will convert C code into M1 output which you at this point know what to do with it to get a working binary.

After all of that, one simply takes the M1 strings that are in M2-Planet which we know generate working C code and taking a copy of cc_x86.s, replace the strings, fix the local and argument offsets (change a few type sizes for 64bit targets) and you are done. With a working C compiler for powerpc32 written in assembly.

One trick is after you get the architecture into M2-Planet Is have it build itself for your target instruction set and put that into a file (I used foo1)
Then cat all of the inputs used into another file (I used foo.c)

Here is the instruction I used with knight-native:
M1 --architecture knight-native --BigEndian -f High_level_prototypes/defs -f stage2/cc_knight-native.s -o scratch/cc_knight-native.hex2 && hex2 --architecture knight-native --BigEndian -f scratch/cc_knight-native.hex2 -o scratch/cc_knight-native && ./bin/vm --rom scratch/cc_knight-native --tape_01 foo.c --memory 10M && meld foo1 tape_02

If you need further clarification, I am more than happy to help
Plus there are some wonderful people on #bootstrappable who are able to help you work through ugly details

-Jeremiah



More information about the rb-general mailing list