I am using I.mx6q Sabre-sd board. I am trying to write my own custom OS. During the context switching process, the context switch happens accurately but the control doesn't return to the exact position. ie. when the context has to be switched, i call a function that is written in assembly. After the assembly has been executed the context gets switched but the control doesn't reach where the assembly function was actually called. But the next task is being executed accurately. What might be the problem. The assembly code i am using is,
//save required registers
LDR sp ,[r12]
// sub lr, lr, #4;
// bx lr
Is this correct? Am i missing some steps ? I am not good with assembly. Please help.