Chapter 4 Using Assembly and Intrinsics in C or C++ Code

All code for a single application can be written in the same source language. This is usually a high-level language such as C or C++ that is compiled to instructions for ARM® architectures. However, in some situations you might need lower-level control than what C and C++ provide.

For example:

  • To access features which are not available from C or C++, such as interfacing directly with device hardware.
  • To generate highly optimized code by manually writing sections using intrinsics or inline assembly.

There are a number of different ways to have low-level control over the generated code:

  • Intrinsics are functions provided by the compiler. An intrinsic function has the appearance of a function call in C or C++, but is replaced during compilation by a specific sequence of low-level instructions.
  • Inline assembly lets you write assembly instructions directly in your C/C++ code, without the overhead of a function call.
  • Calling assembly functions from C/C++ lets you write standalone assembly code in a separate source file. This code is assembled separately to the C/C++ code, and then integrated at link time.
It contains the following sections:
Non-ConfidentialPDF file icon PDF versionARM 100748_0607_00_en
Copyright © 2016, 2017 ARM Limited or its affiliates. All rights reserved.