5 ms·
I have recently built a simple 8085 computer on a breadboard and finding a working and open-source C compiler was a huge challenge. Finally I found this one: ht
by 0xmarcin 6y ago
I have recently built a simple 8085 computer on a breadboard and finding a working and open-source C compiler was a huge challenge. Finally I found this one: https://github.com/ncb85/SmallC-85 https://github.com/ncb85/SmallC-85 but it supports ancient K&R C syntax, without such goodies like subscript operator or character literals. Still I prefer ancient C than ancient assembly language.
On the other hand there is Small Device C Compiler (SDCC) project that provides a decent compiler for Z80 CPU. There is also cc65 for 6502 CPUs.
The strangest thing is that Free Pascal seems to support 68k out of the box (https://www.freepascal.org/ https://www.freepascal.org/) and also AVR and bunch of other archs.
- korethr 6y ago> but it supports ancient K&R C syntax, without such goodies like subscript operator or character literals. Still I prefer ancient C than ancient assembly language A thought occurs to me: would it be possible to use that compiler to bootstrap your way to a modern C dialect? At one point, there were no C89 compilers. So, one would have to write a C89 compiler in K&R. Or am I failing to appreciate just how much work it would be?
- duskwuff 6y ago> A thought occurs to me: would it be possible to use that compiler to bootstrap your way to a modern C dialect? You don't need to. SmallC is a cross-compiler, not a self-hosting compiler; it runs on a modern computer, not an 8085. If you wanted to modify SmallC to accept modern C syntax, you can do that without "bootstrapping" anything.
- arcticbull 6y agoYou could probably write some macros or some other kind of text processing job to convert modern C constructs into K&R and feed it into SmallC.
- kmeisthax 6y agoYou need to write a bridge compiler in C89 that can compile newer variants of C, and then feed another compiler's source code into it. These are implicitly written whenever new C features are added to compilers (can't depend on features that don't exist yet) but will be destroyed fairly quickly (why not dogfood our own features?). Furthermore, the compilers most people are going to want are either GCC or LLVM/clang, both of which have non-standard extensions which you'll likely also need to support. However, a much more efficient approach would be to add support for older architectures to a modern compiler. Then you can build binaries via cross-compilation, or cross-compile the compiler itself to get a modern self-compiler on an old system.
- pabs3 6y agoThese folks are working on bootstrapping from a small amount of machine code for multiple arches all the way to the Linux kernel. https://bootstrappable.org/ https://bootstrappable.org/
- yjftsjthsd-h 6y agoFree Pascal has shockingly broad platform support:) One of the things I always found cool about it.
- deleted 6y ago[deleted]
- marktangotango 6y agoI vaguely recall trying to write fixed point math functions using sdcc for a gameboy homebrew project a long time ago. I’d compile and run via an emulator. Good times!