|
UCOS任务切换用的是汇编代码,看不太懂
- #define uCOS 0x80 /* Interrupt vector # used for context switch */
- #define OS_TASK_SW() asm INT uCOS
复制代码
基于PC的汇编代码
- _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*/
复制代码
看它的意思好像是调用了0x80的中断,然后不知道怎么跑的了?汇编代码也看不太懂。。。
|
|