You copied the Doc URL to your clipboard.

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 assembly code using the following formats:

  • On a single line, for example:


    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:


    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.