赞
踩
[size=10.5000pt]LDR R0, =NVIC_INT_CTRL | [size=10.5000pt]R0 = [size=10.5000pt]0xE000ED04 |
[size=10.5000pt]LDR R1, =NVIC_PENDSVSET | [size=10.5000pt]R1 = [size=10.5000pt]0x10000000 |
[size=10.5000pt]STR R1, [R0] | [size=10.5000pt]*(U32*)R0 = R1 |
[size=10.5000pt]BX LR | [size=10.5000pt]return |
[size=10.5000pt]CPSID I | [size=10.5000pt]关中断 |
[size=10.5000pt]MRS R0, PSP | [size=10.5000pt]R0 = PSP(注意这里用的是PSP) |
[size=10.5000pt]CBZ [size=10.5000pt] [size=10.5000pt]R0, OS_CPU_PendSVHandler_nosave | [size=10.5000pt]If(R0 == 0) [size=10.5000pt]{ [size=10.5000pt] [size=10.5000pt]OS_CPU_PendSVHandler_nosave[size=10.5000pt](); [size=10.5000pt]} |
[size=10.5000pt]PUSH {R14} | [size=10.5000pt]简单的入栈,不过注意这里是用MSP因为在handle模式必须是MSP |
[size=10.5000pt]LDR R0, =OSTaskSwHook | [size=10.5000pt]OSTaskSwHook[size=10.5000pt]这里是一个函数名 [size=10.5000pt]即这里[size=10.5000pt]R0等于[size=10.5000pt]OSTaskSwHook[size=10.5000pt]的地址 [size=10.5000pt]OSTaskSwHook[size=10.5000pt]内其实是空的由用户改写,先不管它。 |
[size=10.5000pt]BLX R0 | [size=10.5000pt]OSTaskSwHook[size=10.5000pt]() |
[size=10.5000pt]POP {R14} | [size=10.5000pt]出栈。这个R14是LR |
[size=10.5000pt]LDR R0, =[size=10.5000pt] [size=10.5000pt]OSPrioCur | [size=10.5000pt]R0 = &OSPrioCur |
[size=10.5000pt]LDR R1, =[size=10.5000pt] [size=10.5000pt]OSPrioHighRdy | [size=10.5000pt]R1 = &[size=10.5000pt]OSPrioHighRdy |
[size=10.5000pt]LDRB R2, [R1] | [size=10.5000pt]R2 = *(U16*)R1 |
[size=10.5000pt]STRB R2, [R0] | [size=10.5000pt] *(U16*)R1 = R2 |
[size=10.5000pt]LDR R0, =OSTCBCur | [size=10.5000pt] R0 = &[size=10.5000pt]OSTCBCur |
[size=10.5000pt]LDR R1, =OSTCBHighRdy | [size=10.5000pt] R1 = &[size=10.5000pt]OSTCBHighRdy |
[size=10.5000pt]LDR R2, [R1] | [size=10.5000pt] R2 = *([size=10.5000pt]U32[size=10.5000pt]*)R1 |
[size=10.5000pt]STR R2, [R0] | [size=10.5000pt] *([size=10.5000pt]uU32[size=10.5000pt]*)R0 = R2 |
[size=10.5000pt]LDR R0, [R2] | [size=10.5000pt]注意上面[size=10.5000pt]R2的值 [size=10.5000pt]R2 = &([size=10.5000pt]OSTCBHighRdy[size=10.5000pt]->[size=10.5000pt]OSTCBStkPtr[size=10.5000pt]) [size=10.5000pt]R0 = [size=10.5000pt]OSTCBStkPtr |
[size=10.5000pt]LDM R0, {R4-R11} | [size=10.5000pt]for(i=0; i<8; i++) [size=10.5000pt]R(i+4) = *(OSTCBStkPtr+i) [size=10.5000pt]其实就是恢复R4-R11的值 [size=10.5000pt]这里只保存R4-R11是因为其他重要的寄存器中断发生时硬件会保存 |
[size=10.5000pt]ADDS R0, R0, #0x20 | [size=10.5000pt]R0 = R0 + 0x20 |
[size=10.5000pt]MSR PSP, R0 | [size=10.5000pt]PSP = R0 |
[size=10.5000pt]ORR LR, LR, #0x04 | [size=10.5000pt]LR |= 0x04切换到线程模式 [size=10.5000pt]这时SP就映射到了PSP [size=10.5000pt]之后返回线程模式在执行PUSH,POP等就使用PSP了。 |
[size=10.5000pt]CPSIE I | [size=10.5000pt]开中断 |
[size=10.5000pt]BX LR | [size=10.5000pt]中断返回(注意是中断返回) |
[size=10.5000pt]LDR R0, [R2] |
[size=10.5000pt]LDM R0, {R4-R11} |
[size=10.5000pt]ADDS R0, R0, #0x20 |
[size=10.5000pt]MSR PSP, R0 |
[size=10.5000pt]LDM R0, {R4-R11} |
[size=10.5000pt]ADDS R0, R0, #0x20 |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。