I was once in a meeting where the facilitator asked us to introduce ourselves with the usual information, but also wanted us to share our favorite hobby. I spent a second trying to think of which hobby I could say to not sound like a total nerd. Then I realized it didn’t matter. All my hobbies are nerdy, including designing CPUs and their instruction sets.
I language, but modern C is far from simple, and compilers are huge projects. I have looked before at porting GCC to a different architecture, and it looks daunting. There’s LLVM, which is a bit more modern, but also non-trivial to port. There are a few older compilers that ought to be easier, but they often aren’t quite modern enough. Plus, if your CPU were big enough, which BLUE isn’t, GCC or a similar modern compiler would be attractive because you could use it to get Linux going.
Keep in mind, though, I’m not talking about a C compiler that runs on BLUE. Just a cross-compiler. My OneDer CPU is 32-bit and could host a C compiler, though. That’s another reason to bite the bullet and do a “big” compiler port. Because even if BLUE isn’t that big, other CPUs are, and I’d love to have a GCC port under my belt.
Decisions
So… what do I do? I have a few ideas for you to consider, and of course I’m open to other suggestions. One of the biggest problems with BLUE is that it is a word-oriented machine. Address 0, for example, is a 16-bit word. Address 1 is another 16-bit word that does not overlap.
This is great until you get into strings: that is, character arrays. Should a character pointer be special? Or should you waste space by putting one character per word? The address space isn’t very large, so you could make character pointers that get converted at runtime, but there is a penalty for that, of course. Or, you could make everything a byte pointer and pay an even bigger penalty.
Path 1: Port a Big Compiler
Obviously, the best result would be to port GCC or a similar compiler. It turns out, GCC has a PDP/11 port, and BLUE is not very dissimilar from a stripped-down low-end PDP/11. It seems like one idea would be to get the PDP/11 GCC
Of course, some compilers are made to be easier to port. SDCC handles CPUs with few registers, for example. Clang/LLVM and LCC are also compilers made to be easier to port.
There is obvious appeal here. If I get GCC or LLVM producing good BLUE code, I’ve learned how to target one of the major compiler infrastructures. That knowledge might transfer to later CPUs and, in the case of a sufficiently capable future processor, could lead to things like Linux ports.
The downside is obvious too: this may be solving a much larger problem than BLUE actually requires.
Path 2: Port a Little Compiler
There are a few little compilers like


