Inline Assembly and Conditional Blocks

In most cases, the ( -Ccx: Cosmic Compatibility Mode for Space Modifiers and Interrupt Handlers) handles the #asm blocks used in the Cosmic compiler's inline assembly code Cosmic compatibility switch. However, if you use #asm with conditional blocks like #ifdef or #if, then the C parser may not accept it (refer the following listing).

Listing: Using Conditional Blocks without asm Block Markers ({ and })


void myfun(void) {
  #asm

    nop

#if 1

  #endasm

  myfun();

  #asm

    #endif

    nop

  #endasm

}

In such cases, the #asm and #endasm must be ported to asm { and } block markers (refer the following listing).

Listing: Using Conditional Blocks with asm Block Markers ({ and })


void myfun(void) {
  asm { // asm #1

    nop

#if 1

  } // end of asm #1

  myfun();

  asm { // asm #2

#endif

    nop

  } // end of asm #2

}