HLI Assembly

Do not mix High-Level Inline (HLI) Assembly with C declarations and statements (see the following listing). Using HLI assembly may affect the register trace of the compiler. The Compiler cannot touch HLI Assembly, and thus it is out of range for any optimizations except branch optimization.

Listing: Mixing HLI Assembly with C Statements (Not Recommended)
void myfun(void) {
  /* some local variable declarations */

  /* some C/C++ statements */

  __asm {

    /* some HLI statements */

  }

  /* maybe other C/C++ statements */

}

When encountering this code, the Compiler assumes that everything has changed. It cannot hold variables used by C statements in registers while processing HLI statements. Normally it is better to place special HLI code sequences into separate functions, although additional calls or returns may occur. Placing HLI instructions into separate functions (and modules) simplifies porting the software to another target (refer the following listing).

Listing: HLI Statements are Not Mixed with C Statements (Recommended)
/* hardware.c */
void special_hli(void) {

  __asm {

    /* some HLI statements */

  }

}

/* myfun.c */

void myfun(void) {

  /* some local variable declarations */

  /* some C/C++ statements */

  special_hli();

  /* maybe other C/C++ statements */

}