www.pudn.com > ucos port forf240.rar > OS_CPU_A.ASM, change:2003-11-18,size:2760b


_EVIFRB  .set 7430h 
          
    .global	I$$SAVE						 
    .global	I$$REST 
	.global	_OSIntEnter 
	.global	_OSIntExit 
    .global	_OSTimeTick				 
	.global	_OSTCBCur 
	.global	_OSTCBHighRdy 
	.global	_OSStartHighRdy 
    .global	_OSCtxSw 
    .global	_OSIntCtxSw 
    .global _OSTaskSwHook 
    .global _OSRunning 
    .global _OSPrioCur 
    .global _OSPrioHighRdy 
	.global _OSIntNesting 
	.global	_OSTickISR 
	 
	.text 
     
 
_OSStartHighRdy: 
    call _OSTaskSwHook,ar1		    ; call _OSTaskSwHook 
    ldpk _OSRunning                 ;set OSRunning true 
    splk #1,_OSRunning 
    ldpk _OSTCBHighRdy 
    lar	 AR1,_OSTCBHighRdy     ; point to the pointer to the highest priority task. 
    ;lar AR1,#_OSTCBHighRdy 
    ;lar  AR1,*                  ; point to the highest priority task. 
    nop 
    nop 
    lar  AR1,*	                ; get OSTCBCur->OSTCBStkPtr. 
    nop 
    nop 
    b	I$$REST			        ; go let TI do the hard work. 
 
     
_OSCtxSw: 
	 
    call	I$$SAVE		; save this task's context. 
    
     
_OSCtxSw_0: 
    call _OSTaskSwHook 
    ldpk    _OSPrioCur 
    bldd   #_OSPrioHighRdy,_OSPrioCur 
    lar   AR2,#_OSTCBCur	                     ; point AR2 at the OSTCBCur pointer. 
    mar   *,AR2		                     ; make AR2 the currently used address register. 
    lar	  AR0,*,AR0			     ; point AR0 at current TCB, and switch to using AR0. 
    sar	  AR1,*	          		     ; save the current task's current stack ptr in the current TCB. 
      
    lar	  AR0,#_OSTCBHighRdy		     ; point to OSTCBHighRdy pointer. 
    lar	  AR0,* 			     ; point to the highest priority task that is ready. 
    lar	  AR1,*,AR2       		     ; get the new task's stack ptr, switch 
    					     ; to using AR2 which points to OSTCBCur pointer. 
    sar	  AR0,*,AR1              	     ; move _OSTCBHighRdy to _OSTCBCur, 
    					     ; and switch to using the new current stack pointer. 
    b    I$$REST			     ; let TI do the hard work of restoring this task's context. 
     
 
_OSIntCtxSw: 
	 
    POP 			    ; pop-off the return address 
    sbrk   3			; clean-up the sw stack's pushed frame pointer and return address from the call to "OSIntExit." 
                        ;before v2.15 these instructions are needed 
    b	_OSCtxSw_0		 
 
_OSTickISR:                              
	call I$$SAVE			; save the interrupted task's context. 
     
    ldpk _OSIntNesting 
    lacc _OSIntNesting 
    add #1 
    sacl _OSIntNesting 
     
    ldp #232 
    splk #0001h,_EVIFRB 
    clrc INTM               ;enable interrupt 
    call _OSTimeTick		; increment the uC/OS timer tick. 
    call   _OSIntExit		; inform uC/OS we're leaving the ISR; we may exit through that path if there is a context switch. 
    b	I$$REST			 
 
     .end