11 ms·
It would be cool if 68k support landed in LLVM. I've been wanting to do a 68k-based retrocomputer project for a while. If I ever get started on such a project,
by korethr 6y ago
It would be cool if 68k support landed in LLVM. I've been wanting to do a 68k-based retrocomputer project for a while. If I ever get started on such a project, being able to use a modern compiler would be nice.
- 0xmarcin 6y agoI 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!
- phire 6y agoOne annoying thing is that nobody makes new 68k CPUs anymore. The only real source appears to be scavenged chips from China. If you want to limit your retrocomputer design to only parts that are still manufactured, like I do: The only cpu choices appear to be: Z80, 68c02 and 68c816
- korethr 6y agoWhich is a shame. Just from high level descriptions of the 68k architecture, compared to my own (albeit very limited) experience with x86 assembly, the 68k seems a much more elegant and easier to program architecture.
- phire 6y agoSomeone else in this thread has pointed out you can still buy the 68SEC000 from digikey. But it's not recommended for new designs.
- korethr 6y agoYou are correct. I also seem to recall recently reading news that someone had started fabbing 68020s again, but can't find the source at the moment.
- enticeing 6y agoWikipedia says Rochester Electronics, and I did find it here on their site: https://www.rocelec.com/part/REIMC68020EH33E https://www.rocelec.com/part/REIMC68020EH33E
- zokier 6y agoAt $100 for '020 and $300 for '040 I don't see many hobbyists rushing for those. You can get pretty damn nice FPGA for that sort of money, even if I understand it's not quite the same. https://www.rocelec.com/part/REIMC68040RC25A https://www.rocelec.com/part/REIMC68040RC25A
- not2b 6y agoSo, use gcc, which is what the BSD ports supporting m86k use. See also https://www.phoronix.com/scan.php?page=news_item&px=GCC-11-m68k-Is-Safe https://www.phoronix.com/scan.php?page=news_item&px=GCC-11-m...
- AnIdiotOnTheNet 6y agoThere are languages that LLVM supports that GCC doesn't.
- vmchale 6y agoFair enough.
- cbmuser 6y agoI know about GCC. In fact, I'm the one who created the Bountysource campaign to convert the m68k backend in GCC to MODE_CC.
- Zardoz84 6y agoyou know that GCC had support for 68k and it's a modern compiler, not ?
- cbmuser 6y agoYes, but GCC cannot be used as a backend for other languages like Rust. My primary goal is to get Rust support for m68k.
- seg_lol 6y agoYou probably don't want to hear this but you could go the LLVM->Wasm->Wasm2C->GCC route. The Julia folks had resurrected the C backend to LLVM at least once, it is also a possibility.