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 foo(void) {

  /* some local variable declarations */

  /* some C/C++ statements */

  __asm {

    /* some HLI statements */

  }

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

}

The Compiler in the worst case has to assume that everything has changed. It cannot hold variables into registers over HLI statements. Normally it is better to place special HLI code sequences into separate functions. However, there is the drawback of an additional call or return. Placing HLI instructions into separate functions (and module) simplifies porting the software to another target.

Listing: HLI Statements are not mixed with C Statements (recommended).


/* hardware.c */

void special_hli(void) {

  __asm {

    /* some HLI statements */

  }

}

/* foo.c */

void foo(void) {

  /* some local variable declarations */

  /* some C/C++ statements */

  special_hli();

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

}