Hi all,
I would like to share an old university years project of mine,
a Small C compiler written in Forth, running on C64 or Plus4 and
targeting the 6502. It had hibernated for ~25 years in almost
working form. Recently I have picked it up again and open-sourced it.
It lives here: https://github.com/pzembrod/cc64
I won't advertise this yet as a full tool for C programming, since
a real library is still on the todo list, as well as ANSI style
function definitions (so far it's K&R only).
But apart from that, for coding
locally on the Commodore machines, as an alternative to
cross-development, cc64 should already be a practical option.
I would love to hear some feedback if anyone wants to try it out.
Cheers
/Philip
C64/C16/Plus4-hosted Small C compiler cc64
Re: C64/C16/Plus4-hosted Small C compiler cc64
Welcome! Can I suggest we use this thread, in Programming, to discuss the usage of this compiler? We can use the other thread, in Forth, to discuss the implementation.
Re: C64/C16/Plus4-hosted Small C compiler cc64
An update on this: I've recently gotten cc64 to run on the Commander X16:
https://www.commanderx16.com/forum/inde ... -cc64-x16/
https://www.commanderx16.com/forum/inde ... -cc64-x16/
Re: C64/C16/Plus4-hosted Small C compiler cc64
Now I’m much more incentivized to get my Plus4 working properly again!
Re: C64/C16/Plus4-hosted Small C compiler cc64
Gurft wrote:
Now I’m much more incentivized to get my Plus4 working properly again!
The latest release brought a decent compile speed increase (https://github.com/pzembrod/cc64/releases/tag/v0.9), and I'm currently working on enabling ANSI-style function definitions.
Re: C64/C16/Plus4-hosted Small C compiler cc64
Just before Christmas I released v0.10 (https://github.com/pzembrod/cc64/releases/tag/v0.10) which brings the mentioned ANSI syntax for function definitions (no type check between formal and actual params, though), better support for fastcall functions, and a basic libc, partially written in C, ported from https://pdclib.rootdirectory.de/, and partially rewritten in 6502 assembly. Of course, only a subset of functions was feasible and made sense due to limitations of both the compiler and the target platforms (C64, C16, X16).
A piece of code that I was initially most scared off was printf(). I thought it would need to turn into a monster in size and complexity. But surprisingly it was rather enjoyable, both to decide on a limit for features, and to squeeze those features into as compact and efficient code as I could. I even had fun sacrificing readability for efficiency in a few places, something I usually avoid, and instead tried to mollify my future self with extensive code comments where it seemed useful.
The code lives at https://github.com/pzembrod/cc64/blob/m ... e/printf.a if anyone wants to take a look.
A piece of code that I was initially most scared off was printf(). I thought it would need to turn into a monster in size and complexity. But surprisingly it was rather enjoyable, both to decide on a limit for features, and to squeeze those features into as compact and efficient code as I could. I even had fun sacrificing readability for efficiency in a few places, something I usually avoid, and instead tried to mollify my future self with extensive code comments where it seemed useful.
The code lives at https://github.com/pzembrod/cc64/blob/m ... e/printf.a if anyone wants to take a look.
Re: C64/C16/Plus4-hosted Small C compiler cc64
This is great. Thank you!