C Macros

C macros expand inside inline assembler code just like they expand in C. One special point to note is the syntax of the __asm directive (generated by macros). As macros always expand to one single line, you can only use __asm NOP; the first form of the __asm keyword, in macros.

for example,

  #define SPACE_OK { __asm NOP; __asm NOP; }

  

Using the second form is illegal:

  #define NOT_OK { __asm { \

  
                       NOP; \

  
                        NOP; \

  
                 }

  

Here the preprocessor expands the NOT_OK macro to one single line, which is mistranslated because every assembly instruction must be explicitly terminated by a new line.

To use # inside macros to build immediates, use the #pragma NO_STRING_CONSTR: No String Concatenation during Preprocessing.