Using Assembly and Intrinsics in C or C++ Code
All code for a single application can be written in the same source language. This source language 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 that which C or C++ provides.
- To access features which are not available from C or C++, such as interfacing directly with device hardware.
- To generate highly optimized code by using intrinsics or inline assembly to write sections of your code.
There are several ways to have low-level control over the generated code:
Intrinsics are functions that the compiler provides. 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.
NoteArm intrinsics are recognized by Arm compilers, but not guaranteed to work with any third-party compiler toolchains.
- 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: