We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi I am trying to reinitialize the sp and pc registers in my bootloader code (cortex m3) and I am getting a warning and a error from the code below. I have tried r13 and r15 as well and get the same errors.
I don't understand the warning at all. But the stack pointer should be a valid name.
Could someone please tell me what I am missing here?
Thanks
SoftBoot.cpp(108): warning: #1267-D: Implicit physical register R1 should be defined as a variable
SoftBoot.cpp(108): error: #20: identifier "sp" is undefined
void startboot(void) { __asm volatile ( "movs r1, #0x00 \n" "ldr sp, [r1,#0x00] ; Load new stack pointer address \n" "ldr pc, [r1,#0x04] ; Load new program counter address \n" ); }
Most people consider it more maintainable by separating assembler and C. Especially since the optimizer in the compiler will not leave inlined assembler as "don't touch" blocks but will mix and match and potentially rewrite the inlined assembler before producing the final code output.