I tried below code, but failed to read the correct value from r11 following below reference of http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472f/Cihfhjhg.html
volatile int top_fp;
__asm
{
mov top_fp, r11
}
r11's value is 0x20009DCC top_fp's value is 0x00000004
[update] Solution, we have to use embedded assembler:
__asm int getRegisterR11()
{
mov r0,r11
BX LR //return, must not omitted!!!
}
The link you posted refers only to lr(R13), sp(R14), pc(R5) for legacy code support of code for old versions of ARM ADS and does not apply to general-purpose registers.
In ARM's compiler (also used in Keil's MDK-ARM):
(Ref: Inline assembler and register access)
Inline assembler in ARM's compiler is subject to optimisation like the C or C++ code it is in-lined within, as such the compiler may generate code that differs from that you have written in any case. If you want assembler code to be generated exactly as you have written you must use embedded assembler rather the inline assembler