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