6.5 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:
    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.
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.