AnsweredAssumed Answered

Help on Assembly for Cortex-M0/M0+

Question asked by Kai Liu on Oct 19, 2013
Latest reply on Oct 30, 2013 by Kai Liu

I am upgrading AN4379 MSD bootloader from K60 to FRDM-KL25Z. Here is the code snippet.

 

void Switch_mode(void)

{

     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)[0];

    New_pc  = ((uint_32_ptr)IMAGE_ADDR)[1];

 

    if(temp)

    {

        if((New_sp != 0xffffffff)&&(New_pc != 0xffffffff))

        {

            /* Run the application */

#if (!defined __MK_xxx_H__)

     /* */

            asm

            {

                move.w   #0x2700,sr

                move.l   New_sp,a0

                move.l   New_pc,a1

                move.l   a0,a7

                jmp     (a1)

            }

#elif defined(__CWCC__)

            asm

            {

                ldr   r4,=New_sp

                ldr   sp, [r4]

                ldr   r4,=New_pc

                ldr   r5, [r4]

                blx   r5

            }

#elif defined(__IAR_SYSTEMS_ICC__)

#if defined (MCU_MKL25Z4)

            asm("msr    msp, New_sp");

            asm("msr    psp, New_sp");

            asm("mov    r5, New_pc");

            asm("mov    pc, r5");

#else           

            asm("mov32   r4,New_sp");

            asm("ldr     sp,[r4]");

            asm("mov32   r4,New_pc");

            asm("ldr     r5, [r4]");

            asm("blx     r5");

#endif           

#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.

Outcomes