C compiler
A backend has been added to Clang to support the MOS instruction set. This backend may be targeted by adding the flag --target=mos
to clang.
Different CPUs may be selected using the -mcpu
flag, for example -mcpu=mosw65816
.
Defines[edit | edit source]
The compiler defines the __mos__
macro for the mos
target. In addition, defines are added for every CPU which is compatible with the code; for instance -mcpu=mos65c02
additionally defines __mos6502__
and __mos65c02__
.
Known issues[edit | edit source]
The Clang is broadly compatible with the freestanding portion of the C99 standard. 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.