C compiler

A backend has been added to Clang to support the MOS instruction set. This backend may be targeted by adding the flag  to clang.

Different CPUs may be selected using the  flag, for example.

Defines
The compiler defines the  macro for the   target. In addition, defines are added for every CPU which is compatible with the code; for instance  additionally defines   and.

Known issues
The Clang is broadly compatible with the freestanding portion of the C99 standard, with one big caveat:


 * No float and no double. We'll eventually ship a working IEEE 754 soft float library with the compiler for completeness' sake, but we expect low demand for this, and it'll distract from the rest of the project.

Some of the GCC and Clang language extensions work, some don't. Similarly some of the C++ language features work, some don't. We haven't exhaustively catalogued this; there's a lot, and some are extremely obscure and nearly useless.

Still, some compiler extensions are de-facto standard, so we'll call out a few caveats for those:


 * The GCC/Clang alignment directives work only for global and static variables, not automatic (local) variables. Aligning the stack pointer is tricky, since it requires use of a frame pointer; but the rigors of 6502 indexing cause our frame pointer to be useless for this purpose. To get this to work, we may need *two* frame pointers. Expected call for this feature is low, so if you need it, let us know, and we'll reprioritize.

[[Category:C]]