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

Parents
  • Thank you for your response but not the rude Please read the manual.

    I did research using Google and forums including this one all morning before posting the question here. The link you Googled for me does not apply to my scenario since I am not passing a parameter. The warning about R0 needing a variable declared before reading (I am writing first) does not apply either.

    I have been able to use a table of assembly language instructions to implement/execute what I posted and was able to use LDR to set pc register without error. I wanted to get away from doing it that way and use the code I posted as it is easier to maintain.

    If anyone else has an idea as to why the uVision compiler does not know what the sp register is in this context, I would appreciate your practical comments without being rude/insulting.

Reply
  • Thank you for your response but not the rude Please read the manual.

    I did research using Google and forums including this one all morning before posting the question here. The link you Googled for me does not apply to my scenario since I am not passing a parameter. The warning about R0 needing a variable declared before reading (I am writing first) does not apply either.

    I have been able to use a table of assembly language instructions to implement/execute what I posted and was able to use LDR to set pc register without error. I wanted to get away from doing it that way and use the code I posted as it is easier to maintain.

    If anyone else has an idea as to why the uVision compiler does not know what the sp register is in this context, I would appreciate your practical comments without being rude/insulting.

Children