Inline Assembly Identifiers

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, for better type-safety with this compiler you need to place a `@' in front of variables if you want to use the address of a variable. Using a conditional block like the one below in the following listing may be difficult. Using macros which deal with the cases below is a better way to deal with this.

Listing: Using a conditional block to account for different compilers


#ifdef __MWERKS__

  ldx @myVariable,x

  jsr MyFunction

#else

  ldx _myVariable,x

  jsr _MyFunction

#endif
Listing: Using a macro to account for different compilers


#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)