My Registerallocatorless, deeply commented custom C Crosscompiler for retro-CPUs.
That's my puppy. A complicated beast of a C program, deeply commented, longest-kept-up project of mine. From Preprocessor to Semanticparser and Codegen, a lot of code was written.
Firstly it's actually not even K&R C, specifically it doesn't like typedefs - where a {declaration or statement} is excepted using typedefs requires forcing statement to declaration using 'auto' and 'static' keywords, elseways compiler will try to access the type as a variable. Otherwise typedefs should be fine Lexicalpreparser allows using typedefs to their full power!
Current release package from the 1st to Publicrelease 9 Interim 4 (0.9.4) is on Catbox (note that it's legacy and not maintained, may not even be available. use Github, it starts from 0.9.8 and only marches onwards.), and latest version is listed on Github. Compile via ./configure && make build && sudo make install && make stdlib && sudo make install
(why sudo? cuz configfiles are sourced from /etc/xcc
and you need write permissions to write there. if you have write permissions to /etc
and /usr/local/bin
(compiler binaries go there) you may omit the sudo.)
Number one feature is retargetability - you can (or at least should be able to) retarget the compiler to new platform by creating new configuration files - arch.irc for IR Compiler, arch.asm for Assembler, arch.lds for Linker, configs/arch/crt0.obj for crt0 which provides excecutable file's header as well, configs/arch/libc.obj for all of the standard library and configs/arch/libc.h for it's bindings to C code.