Instruction intrinsics, inline and embedded assembler

Instruction intrinsics, inline and embedded assembler are built into the compiler to enable the use of target processor features that cannot normally be accessed directly from C or C++. For example:

Instruction intrinsics

Instruction intrinsics provide a way of easily incorporating target processor features in C and C++ source code without resorting to complex implementations in assembly language. They have the appearance of a function call in C or C++, but are replaced during compilation by assembly language instructions.

Note

Instruction intrinsics are specific to the ARM instruction set and are therefore not portable to other architecture.

Inline assembler

The inline assembler supports interworking with C and C++. Any register operand can be an arbitrary C or C++ expression. The inline assembler also expands complex instructions and optimizes the assembly language code.

Note

The output object code might not correspond exactly to your input because of compiler optimization.

Embedded assembler

The embedded assembler enables you to use the full ARM assembler instruction set, including assembler directives. Embedded assembly code is assembled separately from the C and C++ code. A compiled object is produced that is then combined with the object from the compilation of the C and C++ source.

The following table summarizes the main differences between instruction intrinsics, inline and embedded assembler.

Table 12. Differences

FeatureInstruction IntrinsicsInline assemblerEmbedded assembler
Instruction setARM and Thumb.ARM only.ARM and Thumb.
ARM assembler directivesNone supported.None supported.All supported.
C/C++ expressionsFull C/C++ expressions.Full C/C++ expressions.Constant expressions only.
Optimization of assembly codeFull optimization.Full optimization.No optimization.
InliningAutomatically inlined.Automatically inlined.Can be inlined by linker if it is the right size and linker inlining is enabled.
Register accessPhysical registers, including PC, LR and SP.

Virtual registers except PC, LR and SP.

Physical registers, including PC, LR and SP.
Return instructionsGenerated automatically.Generated automatically. BX , BXJ, and BLX instructions are not supported.You must add them in your code.
BKPT instructionSupported.Not supported.Supported.

Show/hideSee also

Tasks
Concepts

Using the Compiler:

Using the Assembler:

Reference

Compiler Reference:

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0471G
Non-ConfidentialID021412