LDR R0, [R6] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDM R0, {R4-R11} ; restore r4-11 from new process stack ADD R0, R0, #0x20 MSR PSP, R0 ; load PSP with new process SP ORR LR, LR, #0x04 ; ensure exception return uses process stack BX LR ; exception return will restore remaining context NOP }
/*SVC中断入口*/ __asm void SVC_Handler() { LDR R6,=BenOSCurTCB LDR R0, [R6] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDR R0, [R0] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
LDM R0, {R4-R11} ; restore r4-11 from new process stack ADD R0, R0, #0x20 MSR PSP, R0 ; load PSP with new process SP ORR LR, LR, #0x04 ; ensure exception return uses process stack BX LR ; exception return will restore remaining context }