| |||
| Home > Inline and Embedded Assemblers > 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 4.1 summarizes the main differences between inline assembler and embedded assembler.
Table 4.1. Differences between inline and embedded assembler
| Feature | Embedded assembler | Inline assembler |
|---|---|---|
| Instruction set | ARM and Thumb | ARM only |
| ARM assembler directives | All supported | None supported |
| C/C++ expressions | Constant expressions only | Full C/C++ expressions |
| Optimization of assembly code | No optimization | Full optimization |
| Inlining | Never | Possible |
| Register access | Specified physical registers are used. You can also use PC, LR and SP. | Uses virtual registers (see Virtual registers) |
| Return instructions | You must add them in your code. | Generated automatically |
A list of differences between embedded assembler and C or C++ is provided in Differences between expressions in embedded assembler and C or C++.