Inline Assembly and Conditional Blocks

In most cases, the ( -Ccx: Cosmic Compatibility Mode for Space Modifiers and Interrupt Handlers) will handle the #asm blocks used in Cosmic inline assembly code Cosmic compatibility switch. However, if #asm is used with conditional blocks like #ifdef or #if, then the C parser may not accept it.

Listing: Use of Conditional Blocks without asm { and } Block Markers


void foo(void) {

  #asm

    nop

#if 1

  #endasm

  foo();

  #asm

    #endif

    nop

  #endasm

}

In such case, the #asm and #endasm must be ported to asm { and } block markers.

Listing: Use of Conditional Blocks with asm { and } Block Markers


void foo(void) {

  asm { // asm #1

    nop

#if 1

  } // end of asm #1

  foo();

  asm { // asm #2

#endif

    nop

  } // end of asm #2

}