Is there a better way to access the User-Mode Stack pointer (R13_usr) from within an exception than this
STM SP,{SP}^
NOP
LDM SP,{SP}
note: the nop is for back/forward compatibility reason, according to ARMv5 ARM
Is there a better way to access the User-Mode Stack pointer (R13_usr) from within an exception than this
STM SP,{SP}^
NOP
LDM SP,{SP}
note: the nop is for back/forward compatibility reason, according to ARMv5 ARM
ARMv4 and later have System mode, the whole purpose of which is to be a privileged mode with a full view of user registers, so unless you want to be compatible with truly ancient hardware (Acorn Archimedes, anyone?) you have the option of just switching modes and doing stuff directly in user context. For simply retrieving SP it's a little busy, but it is an option to avoid touching memory:
mrs r0, cpsr
orr r1, r0, #0xf
msr r1, cpsr
mov r2, sp
msr r0, cpsr ; back to whatever the previous mode was with user SP in r2
mov sp, r2
On ARMv7 with the virtualisation extensions (Cortex-A7/A15/A17) there are new banked register access instructions, so things become trivial:
.arch_extension virt
mrs sp, r13_usr