| |||
| Home > Using the Inline and Embedded Assemblers of the ARM Compiler > Inline assembly language syntax with the asm keyword in C++ | |||
When compiling C++, the compiler supports the asm syntax proposed in the ISO C++ Standard. 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.