This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

asm to load the pc and sp

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"
    );
}

0