sp_svc,lr_svc,spsr_svc

   You will get a error as follows when you're trying to use "mov  r2,sp_svc" in your asm file (GNU ARM-LINUX-GCC)
error:
   immediate expression requires a # prefix -- `mov r2,sp_svc' "
why ?:
   it doesn't understand sp_svc, so it thinks you're trying to do an immediate mov, which would look like:
   "mov r2, #0x14 "   So that's why it says "requires a # prefix".

Q
   what is the right methods to approach the sp_svc,lr_svc,spsr_svc ?

A:
   use mrs and msr to change modes by changing bits in the cpsr then use r13 normally.
From the arm arm
   MRS R0,CPSR
   BIC R0,R0,#0x1F
   ORR R0,R0,#0x13
   MSR CPSR_c,R0
then
   mov sp,#0x10000000
or if you need more bits in the immediate
   ldr sp,=0x12345600
or if you dont want the assembler placing your data, you can place it yourself.
   ldr sp,svc_stack
   b 1f
svc_stack: .word 0x12345600
   1:

You will see typical arm startup code, where the application is going to support interrupts, aborts and other exceptions,
to set all of your stack pointers that you are going to need, change mode, set sp, change mode, set sp, change mode ...

posted @ 2013-04-23 16:04  moon_cat  Views(546)  Comments(0Edit  收藏  举报