Statement-Level Inline Assembly

The compiler accepts functions that mix regular C/C++ statements with inline assembly. Statement-level assembly language acts as a block of assembly language that may appear anywhere that the compiler allows a regular C or C++ statement. It has this syntax:

__asm { one or more instructions }

Listing: Example Statement Level Inline Assembly Statements

void func(void)
{

asm{    add r0, r1;

sub r0,r2,r3;}

}

__asm{ add r0, r1;

       sub r0,r2,r3;}

__asm("nop\n nop");

__asm("nop; nop");

__asm(nop

      nop);


Note: Each instructions should be separated by a ';' or new line.