| |||
| Home > Using the Inline and Embedded Assemblers of the ARM Compiler > Inline assembly language syntax with the __asm keyword in C and C++ | |||
The inline assembler is invoked with the assembler specifier, and is followed by a list of assembler instructions inside braces or parentheses. You can specify inline assembler code using the following formats:
On a single line, for example:
__asm("instruction[;instruction]");
__asm{instruction[;instruction]}
You cannot include comments.
Using multiple adjacent strings, for example:
__asm("ADD x, x, #1\n"
"MOV y, x\n");
This enables you to use macros to generate inline assembly, for example:
#define ADDLSL(x, y, shift) __asm ("ADD " #x ", " #y ", LSL " #shift)
On multiple lines, for example:
__asm
{
...
instruction
...
}
You can use C or C++ comments anywhere in an inline assembly language block.
You can use an __asm statement wherever
a statement is expected.