RealView heroes - this is your moment!

Hello all,

void select_next_task(void)
{
        if (l_task == 0)
        {
                l_task = 1 ;
        }
        else
        {
                l_task = 0 ;
        }
}

__asm void context_switch(void)
{
        STMDB R13!, {R0-R12, LR} ; save context

        BL        __cpp(select_next_task) ; select the next task to run

        LDR   R0,=__cpp(g_task_stacks)
        LDR   R1,=__cpp(&l_task)
        ADD       R0, R0, R1 ; calculate the offset of the next task stack
        LDR    R13, [R0] ; set the stack pointer to the new stack
        LDMIA R13!, {R0-R12, LR}
        BX                       LR        ; embedded assembly requires an explicit return instruction
}

I am trying change the context of my STR9. For that, I am working on a small prototype that I will extend later. The problem is that the marked like generates the following linker error:

scheduler.axf: Error: L6238E: context_switch.o(.emb_text) contains invalid call from '~PRES8' function to 'REQ8' function select_next_task.

If I comment the marked instruction, the program links corectly. I know what this is all about: assembler code (that does not preserve 8-byte stack alignment) calls compiled C/C++ code (that requires 8-byte stack alignment). But why is this caused only when I try to load SP with another address? Is this the proper way to do it? Are there any restictions on the address contained in SP?

Parents Reply Children
No data
More questions in this forum