ucos-ii任务切换代码分析 30
任务级的任务切换,请您逐行分析,并注明汇编语句的具体意思_OSCTXSWPROCFAR;PUSHA;Savecurrenttask'scontextPUSHES;PUSH...
任务级的任务切换,请您逐行分析,并注明汇编语句的具体意思
_OSCTXSW PROC FAR
;
PUSHA ; Save current task's context
PUSH ES ;
PUSH DS ;
;
MOV AX, SEG _OSTCBCUR ; Reload DS in case it was altered
MOV DS, AX ;
;
LES BX, DWORD PTR DS:_OSTCBCUR ; OSTCBCur->OSTCBStkPtr = SS:SP
MOV ES:[BX+2], SS ;
MOV ES:[BX+0], SP ;
;
CALL FAR PTR _OSTASKSWHOOK ; Call user defined task switch hook
;
MOV AX, WORD PTR DS:_OSTCBHIGHRDY+2 ; OSTCBCur = OSTCBHighRdy
MOV DX, WORD PTR DS:_OSTCBHIGHRDY ;
MOV WORD PTR DS:_OSTCBCUR+2, AX ;
MOV WORD PTR DS:_OSTCBCUR, DX ;
;
MOV AL, BYTE PTR DS:_OSPRIOHIGHRDY ; OSPrioCur = OSPrioHighRdy
MOV BYTE PTR DS:_OSPRIOCUR, AL ;
;
LES BX, DWORD PTR DS:_OSTCBHIGHRDY ; SS:SP = OSTCBHighRdy->OSTCBStkPtr
MOV SS, ES:[BX+2] ;
MOV SP, ES:[BX] ;
;
POP DS ; Load new task's context
POP ES ;
POPA ;
;
IRET ; Return to new task
;
_OSCTXSW ENDP
PAGE ; /*$PAGE*/
解释任务切换是如何把cpu信息存储在任务的堆栈里的,请据此写个简单的任务切换小程序 展开
_OSCTXSW PROC FAR
;
PUSHA ; Save current task's context
PUSH ES ;
PUSH DS ;
;
MOV AX, SEG _OSTCBCUR ; Reload DS in case it was altered
MOV DS, AX ;
;
LES BX, DWORD PTR DS:_OSTCBCUR ; OSTCBCur->OSTCBStkPtr = SS:SP
MOV ES:[BX+2], SS ;
MOV ES:[BX+0], SP ;
;
CALL FAR PTR _OSTASKSWHOOK ; Call user defined task switch hook
;
MOV AX, WORD PTR DS:_OSTCBHIGHRDY+2 ; OSTCBCur = OSTCBHighRdy
MOV DX, WORD PTR DS:_OSTCBHIGHRDY ;
MOV WORD PTR DS:_OSTCBCUR+2, AX ;
MOV WORD PTR DS:_OSTCBCUR, DX ;
;
MOV AL, BYTE PTR DS:_OSPRIOHIGHRDY ; OSPrioCur = OSPrioHighRdy
MOV BYTE PTR DS:_OSPRIOCUR, AL ;
;
LES BX, DWORD PTR DS:_OSTCBHIGHRDY ; SS:SP = OSTCBHighRdy->OSTCBStkPtr
MOV SS, ES:[BX+2] ;
MOV SP, ES:[BX] ;
;
POP DS ; Load new task's context
POP ES ;
POPA ;
;
IRET ; Return to new task
;
_OSCTXSW ENDP
PAGE ; /*$PAGE*/
解释任务切换是如何把cpu信息存储在任务的堆栈里的,请据此写个简单的任务切换小程序 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询