6.29 Restrictions on embedded assembly language functions in C and C++ code

A number of restrictions apply to embedded assembly language functions.

Specifically:
  • After preprocessing, __asm functions can only contain assembly code, with the exception of the following embedded assembler built-ins:
    __cpp(expr)
    __offsetof_base(D, B)
    __mcall_is_virtual(D, f)
    __mcall_is_in_vbase(D, f)
    __mcall_offsetof_base(D, f)
    __mcall_this_offset(D, f)
    __vcall_offsetof_vfunc(D, f)
    
  • No return instructions are generated by the compiler for an __asm function. If you want to return from an __asm function, you must include the return instructions, in assembly code, in the body of the function.

    Note

    This makes it possible to fall through to the next function, because the embedded assembler guarantees to emit the __asm functions in the order you define them. However, inlined and template functions behave differently. Do not assume that code execution falls out of an inline or template function into another embedded assembly function.
  • __asm functions do not change the ARM Architecture Procedure Call Standard (AAPCS) rules that apply. This means that all calls between an __asm function and a normal C or C++ function must adhere to the AAPCS, even though there are no restrictions on the assembly code that an __asm function can use (for example, change state).
Related concepts
6.26 Embedded assembler support in the compiler
6.34 __offsetof_base keyword for related base classes in embedded assembler
6.35 Compiler-supported keywords for calling class member functions in embedded assembler
6.30 Compiler generation of embedded assembly language functions
6.31 Access to C and C++ compile-time constant expressions from embedded assembler
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.