I am upgrading AN4379 MSD bootloader from K60 to FRDM-KL25Z. Here is the code snippet.
volatile uint_32 temp = 1; /* default the button is not pressed */
/* Get PC and SP of application region */
New_sp = ((uint_32_ptr)IMAGE_ADDR);
New_pc = ((uint_32_ptr)IMAGE_ADDR);
if((New_sp != 0xffffffff)&&(New_pc != 0xffffffff))
/* Run the application */
#if (!defined __MK_xxx_H__)
ldr sp, [r4]
ldr r5, [r4]
#if defined (MCU_MKL25Z4)
asm("msr msp, New_sp");
asm("msr psp, New_sp");
asm("mov r5, New_pc");
asm("mov pc, r5");
asm("ldr r5, [r4]");
#endif /* end (!defined __MK_xxx_H__) */
} /* EndIf */
But IAR reports my assembly is wrong.
Does anyone can recommend some assembly language covering Cortex-M0? Although we are working on high level language. Sometimes assembly programming is still very useful in highly optimized code and libraries.