6.4 Inline assembly language syntax with the __asm keyword in C and C++

The inline assembler is invoked with the assembler specifier, __asm, and is followed by a list of assembler instructions inside braces or parentheses.

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 DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.