Keil™, An ARM® Company

RealView Compiler User's Guide

Differences between inline and embedded assembly code

6.4. Differences between inline and embedded assembly code

There are differences between the way inline and embedded assembly is compiled:

  • Inline assembly code uses a high‑level of processor abstraction, and is integrated with the C and C++ code during code generation. Therefore, the compiler optimizes the C and C++ code, and the assembly code together.

  • Unlike inline assembly code, embedded assembly code is assembled separately from the C and C++ code to produce a compiled object that is then combined with the object from the compilation of the C or C++ source.

  • Inline assembly code can be inlined by the compiler, but embedded assembly code cannot be inlined, either implicitly or explicitly.

Table 6.1 summarizes the main differences between inline assembler and embedded assembler.

Table 6.1. Differences between inline and embedded assembler

FeatureEmbedded assemblerInline assembler
Instruction setARM and Thumb.ARM only.
ARM assembler directivesAll supported.None supported.
ARMv6 instructionsAll supported.

Supports only the media instructions.

C/C++ expressionsConstant expressions only.Full C/C++ expressions.
Optimization of assembly codeNo optimization.Full optimization.
InliningNever.Possible.
Register accessSpecified physical registers are used. You can also use PC, LR and SP.

Uses virtual registers (see Virtual registers). Using sp (r13), lr (r14), and pc (r15) gives an error. See Legacy inline assembler that accesses sp, lr, or pc.

Return instructionsYou must add them in your code.Generated automatically. (The BX , BXJ, and BLX instructions are not supported.)
BKPT instructionSupported directly.Not supported.

See also Differences between expressions in embedded assembly and C or C++.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0375A