C Inline Assembly

Clang supports most of the standard GCC inline assembly syntax. There are a few notable exceptions:
 * Unsupported Constraints:,  ,  ,  , and
 * Goto Labels are unsupported.

"General purpose registers" for the purposes of inline assembly are taken to be 8-bit or 16-bit imaginary registers, depending on the size of the operand.

The compiler also supports a few MOS-specific constraints:
 * : The  register.
 * : The  register.
 * : The  register.
 * : One of,  , or.
 * : Either  or.
 * : The  flag.
 * : The  flag.

The unique opcode syntax of the 6502 allows using these operands in unorthodox ways. For example, to issue a copy from a  constrained operand to , you can use the following: asm volatile ("t%0a" :: "d"(c));

This will issue either  or , depending on where the compiler places.

Using GCC-style inline assembly has a lot of sharp edges and footguns, so beware. For a detailed guide on how to use this feature well, see: Frequently asked questions

[[Category:C]]