For the Cosmic compiler, you need to place an underscore ( _) in front of each identifier, but for this compiler you can use the same name both for C and inline assembly. In addition, to use the address of a variable, place a @ in front of variables for better type-safety with this compiler. Use a conditional block like the one below in the following listing, to compensate for the differences in compilers.
#ifdef __MWERKS__ ldx @myVariable,x jsr MyFunction #else ldx _myVariable,x jsr _MyFunction #endif
You can also use macros to cope with the compiler differences. The following listing shows the preferred method.
#ifdef __MWERKS__ #define USCR(ident) ident #define USCRA(ident) @ ident #else /* for COSMIC, add a _ (underscore) to each ident */ #define USCR(ident) _##ident #define USCRA(ident) _##ident #endif
The source can use the macros:
ldx USCRA(myVariable),x
jsr USCR(MyFunction)