MyISR:
Save ALL registers;
OSIntNesting++;
OSTCBCur->OSTCBStkPtr = SP; /* <<<< NEW */
/* Handle ISR */
OSIntExit();
Restore ALL registers;
Return from Interrupt;
OSIntCtxSw:
OSTaskSwHook();
OSTCBCur = OSTCBHighRdy;
SP = OSTCBHighRdy->OSTCBStkPtr;
Restore ALL registers;
Return from Interrupt;
80x86 (Large model)¿¡¼ ¾î¼Àºí¸®¾îÀÇ °æ¿ì:
_MyISR PROC FAR
;
PUSHA ; Save interrupted task's context
PUSH ES
PUSH DS
;
MOV AX, SEG(_OSIntNesting) ; Reload DS
MOV DS, AX
INC BYTE PTR _OSIntNesting ; Notify uC/OS-II of ISR
;
LES BX, DWORD PTR DS:_OSTCBCur ; OSTCBCur->OSTCBStkPtr = SS:SP
MOV ES:[BX+2], SS
MOV ES:[BX+0], SP
CALL FAR PTR _MyISRHandler ; Process the Interrupt
;
CALL FAR PTR _OSIntExit ; Notify uC/OS-II of end of ISR
;
POP DS ; Restore interrupted task's context
POP ES
POPA
;
IRET ; Return to interrupted task
;
_MyISR ENDP
_OSIntCtxSw PROC FAR
;
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
;
_OSIntCtxSw ENDP