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

Assembly not supporting in keil 5.06

void JumpToUserApplication(LWord userSP, LWord userStartup)
{

volatile LWord avoid_optimization; avoid_optimization = userSP; //In order to avoid optimization issue when -Os avoid_optimization = userStartup; //In order to avoid optimization issue when -Os

// set up stack pointer __asm("msr msp,r0"); __asm("msr psp,r0");

// Jump to PC (r1) __asm("mov pc,r1");

}

Build target 'KL26bootloader'
compiling bootloader.c...
..\Sources\bootloader.c(110): warning: #1267-D: Implicit physical register R0 should be defined as a variable __asm("msr msp,r0");
..\Sources\bootloader.c(110): error: #549: variable "R0" is used before its value is set __asm("msr msp,r0");
..\Sources\bootloader.c(114): error: #20: identifier "pc" is undefined __asm("mov pc,r1");
..\Sources\bootloader.c: 1 warning, 2 errors
".\Objects\KL26bootloader.axf" - 2 Error(s), 1 Warning(s).
Target not created.

  • Can't you just jump using a standard C function pointer, and then have the target set up the actual stack in the application startup code? I would guess that is what most people do when they write their own boot loaders - the application can then decide if it needs a large stack, or a large heap or if it instead wants most of the RAM for variables.

  • Try like this:

    __asm void JumpToUserApplication(uint32_t userSP, uint32_t userStartup)
    {
      MSR MSP, R0
      BX r1
    }
    

    It compiles on 5.16