| |||
| Home > Using the Inline and Embedded Assemblers of the ARM Compiler > Legacy inline assembler that accesses sp, lr, or pc | |||
The compilers in ARM Developer Suite (ADS)
v1.2 and earlier enabled accesses to sp (r13), lr (r14),
and pc (r15) from inline assembly
code. Example 48 shows how
legacy inline assembly code might use lr.
Example 48. Legacy inline assembly code using lr
void func()
{
int var;
__asm
{
mov var, lr /* get the return address of func() */
}
}
There is no guarantee that lr contains
the return address of a function if your legacy code uses it in
inline assembly. For example, there are certain build options or
optimizations that might use lr for another purpose.
The compiler in RVCT v2.0 and later reports an error similar to
the following if lr, sp or pc is
used in this way:
If you have to access these registers from within a C or C++ source file, you can:
use embedded assembly
use the following intrinsics in inline assembly:
__current_pc()To access the pc register.
__current_sp()To access the sp register.
__return_address()To access the lr register.