Context Switch Routine
Write the context switch for a cooperative RTOS on Cortex-M: save the callee-saved registers of the outgoing task, swap stack pointers, and restore the incoming task.
Constraints
- Runs in PendSV so the hardware has already stacked r0 to r3, r12, LR, PC and xPSR.
- Save and restore r4 to r11 manually.
- The task stack pointer is PSP.
- The current TCB pointer is a global whose first member is the saved SP.
- Must return via EXC_RETURN, not BX LR to a normal address.
- Do not touch MSP.
1.global PendSV_Handler2PendSV_Handler:3 @ TODO4 bx lr