tct.s

来自「nuclues plus 源代码程序」· S 代码 · 共 1,126 行 · 第 1/5 页

S
1,126
字号
;
        ldd     38,y                        ; Pickup the stack size
        subd    #12                         ; Subtract initial amount
        std     42,y                        ; Save it in the minimum field
        clra                                ; Clear D
        clrb                                ; 
        std     40,y                        ; Clear upper portion of minimum
;
;    /* Prepare to return to the caller.  */
;
        pulx                                ; Recover X
        rts                                 ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Build_HISR_Stack                                             */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function builds an HISR stack frame that allows quick       */
;/*      scheduling of the HISR.                                          */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      TCC_Create_HISR                     Create HISR function         */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      hisr                                HISR control block pointer   */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      W. Lamie        06-01-1993      Created initial version 1.0      */
;/*      D. Lamie        06-01-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
;VOID  TCT_Build_HISR_Stack(TC_HCB *hisr)
;{
        .public _TCT_Build_HISR_Stack
_TCT_Build_HISR_Stack:
                                            ; Note: D contains the task ptr
        pshx                                ; Save x on the stack
;
;    /* Pickup the stack base.  */
;    REG_Stack_Base =  (BYTE_PTR) hisr -> tc_stack_start;
;
        xgdy                                ; Move task pointer to Y
        ldd     30,y                        ; Pickup the start of the stack
;    
;    /* Pickup the stack size.  */
;    REG_Stack_Size =  hisr -> tc_stack_size;
;    
;    /* Calculate the stack ending address.  */
;    hisr -> tc_stack_end =  REG_Stack_Base + REG_Stack_Size;
;
        addd    38,y                        ; Calculate the last address of the
                                            ;   stack area
        subd    #1                          ; Subtract 1 for size
        std     32,y                        ; Save in control block
;    
;    /* Build an initial stack.  */
;
        subd    #6                          ; Position to top of stack frame
        xgdx                                ; Put stack pointer into IX
        clra                                ; Clear D
        clrb                                ; 
        std     5,x                         ; Place a NULL at the bottom of the
                                            ;   stack
        ldd     #_TCT_HISR_Shell            ; Build entry point into the HISR
        std     3,x                         ; Place it on the stack
        clra                                ; Build clear value for initial 
        clrb                                ;   value of IX and stack type
        std     1,x                         ; Place initial IX on the stack
        staa    0,x                         ; Place stack type on the stack
;    
;    /* Save the new stack pointer into the task's control block.  */
;    hisr -> tc_stack_pointer =  (VOID *) (REG_Stack_End);
;
        stx     34,y                        ; Store stack pointer in TCB
;    
;    /* Save the minimum amount of remaining stack memory.  */
;    hisr -> tc_stack_minimum =  REG_Stack_Size - 7;
;
        ldd     38,y                        ; Pickup the stack size
        subd    #7                          ; Subtract initial amount
        std     42,y                        ; Save it in the minimum field
        clra                                ; Clear D
        clrb                                ; 
        std     40,y                        ; Clear upper portion of minimum
;
;    /* Prepare to return to the caller.  */
;
        pulx                                ; Recover X
        rts                                 ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Build_Signal_Frame                                           */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function builds a frame on top of the task's stack to       */
;/*      cause the task's signal handler to execute the next time         */
;/*      the task is executed.                                            */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      TCC_Send_Signals                    Send signals to a task       */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      task                                Task control block pointer   */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      W. Lamie        06-01-1993      Created initial version 1.0      */
;/*      D. Lamie        06-01-1993      Verified version 1.0             */
;/*                                                                       */
;/*************************************************************************/
;VOID  TCT_Build_Signal_Frame(TC_TCB *task)
;{
        .public _TCT_Build_Signal_Frame
_TCT_Build_Signal_Frame:
;
        pshx                                ; Save IX on the stack
;
;    /* Pickup the stack pointer.  */
;    REG_Stack_Ptr =  (BYTE_PTR) task -> tc_stack_pointer;
;
        xgdy                                ; Move task pointer into IY
        ldd     34,y                        ; Pickup the current stack pointer
;    
;    /* Save the previous stack pointer into the task's control block.  */
;    task -> tc_saved_stack_ptr =  REG_Stack_Ptr;
;
        std     46,y                        ; Save the current stack pointer
                                            ;   in the TCB
;
;    /* Build a signal stack.  */
;
        subd    #10                         ; Allocate enough for signal frame
        xgdx                                ; Move stack pointer into IX
        clra                                ; Clear D
        clrb                                ; 
        std     5,x                         ; Place a NULL at the bottom of the
                                            ;   stack
        ldd     #_TCC_Signal_Shell          ; Build entry point to the signal
                                            ;   handler
        std     3,x                         ; Place it on the stack
        clra                                ; Build clear value for initial 
        clrb                                ;   value of IX and stack type
        std     1,x                         ; Place initial IX on the stack
        staa    0,x                         ; Place stack type on the stack
;
;    /* Save the new stack pointer into the task's control block.  */
;    hisr -> tc_stack_pointer =  (VOID *) (REG_Stack_End);
;
        stx     34,y                        ; Store stack pointer in TCB
;
        pulx                                ; Recover IX from the stack
        rts                                 ; Return to caller
;}
;
;
;
;/*************************************************************************/
;/*                                                                       */
;/* FUNCTION                                                              */
;/*                                                                       */
;/*      TCT_Check_Stack                                                  */
;/*                                                                       */
;/* DESCRIPTION                                                           */
;/*                                                                       */
;/*      This function checks the current stack for overflow conditions.  */
;/*      Additionally, this function keeps track of the minimum amount    */
;/*      of stack space for the calling thread and returns the current    */
;/*      available stack space.                                           */
;/*                                                                       */
;/* AUTHOR                                                                */
;/*                                                                       */
;/*      William E. Lamie, Accelerated Technology, Inc.                   */
;/*                                                                       */
;/* CALLED BY                                                             */
;/*                                                                       */
;/*      TCC_Send_Signals                    Send signals to a task       */
;/*                                                                       */
;/* CALLS                                                                 */
;/*                                                                       */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?