Home > Root > Log book > More compilers

More compilers

Sunday 29 January 2023, by Mathieu Brèthes

All the versions of this article: [Deutsch] [English] [français]

In my previous article I checked SDCC as a possible candidate for extending C compiler to the TLCS900H, the NeoGeo Pocket CPU. This compiler already has a backend for the TLCS90, and on the Toshiba documentation it was writtent that both instruction sets look alike.

However there are three problems:

  • The two CPUS are really very different: the 900 is a 16bit processor with 32 bit registers, and it has a 24bit bus. The 90 is a 8-bit CPU. The instructions of both look alike but the code to be generated will be very different.
  • The backend for the TLCS90 is not an independent implementation but an extension of the Z80 backend, meaning adapting it to the TLCS900 is not going to be easy.
  • Finally SDCC lacks documentation for backend development.

On its forums some people indicate this CPU would be a better candidate for other compilers that allow to target more powerful CPUs. I checked:

  • GCC, the GNU Compiler Collection. I am very familiar with it as a user, it has many advantages, among which a very stable code base. But it lacks a good tutorial for backend writing.
  • LLVM is a compiler on BSD license. It has a very thorough and up to date tutorial for writing a backend for a fictional CPU called cpu0. However, the compiler is known to regularly undergo architectural changes, which mean a lot of reworks possible for backend.

But there are more C compilers listed Wikipedia.

  • I had a deeper look into SmallC. It dates from the 1980s but it his very well documented, including for the backend. And it has been used for school teaching purposes. But it is also designed for Z80 like CPUs.

So right now I do not have an ideal candidate. But there are other compilers I have yet to discover...