7.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).

Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.