3 ms·
Thanks, this is serendipitous timing. I definitely plan to watch the YouTube playlist. I'm designing a simple CPU at the moment[1] and one of the things that k
by jstanley 6y ago
Thanks, this is serendipitous timing. I definitely plan to watch the YouTube playlist.
I'm designing a simple CPU at the moment[1] and one of the things that keeps me awake at night is thinking about how to make a compiler for it.
It only supports 64K words of RAM (and I'm not planning to implement bank switching), and I definitely want the compiler to be self-hosting on my CPU, so retargeting LLVM or similar won't be applicable.
I've looked at Small-C[2], Cowgol[3], and PL/0[4] which all target related goals, from different directions.
[1] https://github.com/jes/scamp-cpu https://github.com/jes/scamp-cpu
[2] https://en.wikipedia.org/wiki/Small-C https://en.wikipedia.org/wiki/Small-C
[3] http://cowlark.com/cowgol/ http://cowlark.com/cowgol/
[4] https://en.wikipedia.org/wiki/PL/0 https://en.wikipedia.org/wiki/PL/0
- lenkite 6y agoHave you taken a look at Ferret ? https://ferret-lang.org/ https://ferret-lang.org/ ? Ferret is a free software lisp implementation designed to be used in real time embedded control systems. Ferret lisp compiles down to self contained C++11. Generated code is portable between any Operating System and/or Microcontroller that supports a C++11 compliant compiler. It has been verified to run on architectures ranging from embedded systems with as little as 2KB of RAM to general purpose computers running Linux/Mac OS X/Windows.
- jstanley 6y agoI hadn't seen it, and it looks cool, thanks. I'm really keen to be able to run the compiler end-to-end on the CPU itself, so I think getting C++11 working would be the stumbling block there.
- read_if_gay_ 6y agoMaybe this is interesting to you as well? https://github.com/cksystemsteaching/selfie https://github.com/cksystemsteaching/selfie
- yudlejoza 6y ago> ... real time ... embedded ... microcontroller ... > ... that supports ... C++11 ... Makes perfect sense.
- dexen 6y agoConsider the KenCC[1][2] - somewhat minimalistic, and the flavor of C it uses is very sane. -- [1] http://gsoc.cat-v.org/projects/kencc/ http://gsoc.cat-v.org/projects/kencc/ [2] yes, by that Ken
- retrac 6y agoConsider Forth. The simplicity of the language's syntax means that a compiler is basically just a table lookup, and they can fit into just a few kilobytes of code. Even if you don't port or implement an actual Forth, a Forth-like threaded code model fits tiny memory constraints very well, with very high code density and only moderate overhead. If you add a couple registers to the VM for easing pointer access, it becomes a suitable target for C-like languages, too.
- beefok 6y agoI'm looking at this one for a CPU design I've been working on. :) https://github.com/jserv/shecc https://github.com/jserv/shecc They just released it!