⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tct.asm

📁 电力系统中的保护装置全部代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;
;    /* Return to the caller.  */
    LDI    *-FP(1),R1
    BD    R1
    LDI    *FP,FP
    NOP
    SUBI    2,SP
***    B    R1    ;BRANCH OCCURS
;}
;
;
;/*************************************************************************/
;/*                                                                       */
;/* 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               */
;/*                                                                       */
;/*      D. Foxall       02-07-1996          TMS320C30 version 1.0        */
;/*      J. Trippi       03-11-1997       Modified for large memory model */
;/*                                                                       */
;/*************************************************************************/
        .global  _TCT_Build_Signal_Frame
_TCT_Build_Signal_Frame:
;VOID  TCT_Build_Signal_Frame(TC_TCB *task)
;{
    PUSH   FP                               ; Save caller's frame pointer
    LDI    SP,FP                            ; Setup local frame
;
;    /* register use: AR0 - task pointer (function argument)
;              AR1 - task stack pointer 
;              R0, R1 - temporary values */
;
    .if NU_STACK
    LDI    *-FP(2),AR0                      ; Pickup the task pointer
    .else
    LDI    AR2,AR0
    .endif
;
;    /* Pickup the stack pointer.  */
;    AR1 =  task -> tc_stack_pointer;
    LDI    *+AR0(TCB_STKPTR),AR1            ; Point at task's stack
;    
;    /* Build a signal stack frame: a solicited type of stack. */
    .if NU_BIG
    LDP    @_TCT_Signal_Shell_Addr          ; Load Data Page Pointer
    .endif
    LDI    @_TCT_Signal_Shell_Addr,R0       ; Pickup signal shell's address 
    STI    R0,*++AR1                        ; Put it on the stack
    LDI    0,R0                             ; Clear R0 for initialization
    STI    R0,*++AR1                        ; Reserve space for frame ptr AR3
    STI    DP,*++AR1                        ; Put current value of Data Page
    LDI    MINREGSAVSIZE-2,R1                 ; Init space on stack for init value
    SUBI   1,R1                             ;    of minimum context registers
    RPTS   R1                               ;    R1 is repeat count - 1
    STI    R0,*++AR1                        ; Repeat this instruction
    LDI    0,R2
    STI    R2,*++AR1                        ; Put solicited stack type on stack
;     
;    /* Save the new stack pointer into the task's control block.  */
;    task -> tc_stack_pointer =  AR1;
;
    STI    AR1,*+AR0(TCB_STKPTR)            ; Save top of stack in TCB
;
;    /* Return to the caller.  */
    LDI    *-FP(1),R1
    BD    R1
    LDI    *FP,FP
    NOP
    SUBI    2,SP
***    B    R1    ;BRANCH OCCURS
;}
;
;
;/*************************************************************************/
;/*                                                                       */
;/* 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                                                                 */
;/*                                                                       */
;/*      ERC_System_Error                    System error handler         */
;/*                                                                       */
;/* INPUTS                                                                */
;/*                                                                       */
;/*      None                                                             */
;/*                                                                       */
;/* OUTPUTS                                                               */
;/*                                                                       */
;/*      available bytes in stack                                         */
;/*                                                                       */
;/* HISTORY                                                               */
;/*                                                                       */
;/*         NAME            DATE                    REMARKS               */
;/*                                                                       */
;/*      D. Foxall       02-07-1996          TMS320C30 version 1.0        */
;/*      J. Trippi       03-11-1997       Modified for large memory model */
;/*                                                                       */
;/*************************************************************************/
        .global  _TCT_Check_Stack
_TCT_Check_Stack:
;UNSIGNED  _TCT_Check_Stack(void)
;{
;
    PUSH   FP                               ; Save caller's frame pointer
    LDI    SP,FP                            ; Setup local frame
;
;    /* register use: AR0 - TCD_Current_Thread pointer 
;              R0 - remaining bytes on stack (return value)
;              R1 - task stack pointer */
;
;    /* Determine if there is a current thread.  */
;    if (TCD_Current_Thread == 0)
;    {
    .if NU_BIG
    LDP    @_TCD_Current_Thread             ; Load Data Page Pointer
    .endif
    LDI    @_TCD_Current_Thread,R0          ; Pickup current thread pointer 
    BNZ    _TCT_New_Minimum                 ; If task or HISR, do check
;
;        /* Set the remaining bytes to 0.  */
;        remaining =  0;
;
    LDI    0,R0                             ; Clear return value
    BR     _TCT_Stack_Check_Finished
;    }
;    else
;    {
;
_TCT_New_Minimum:
;
;        /* Determine if the stack pointers are out of range.  */
;        if ((thread -> tc_stack_pointer >= thread -> tc_stack_start) &&
;            (thread -> tc_stack_pointer <= thread -> tc_stack_end))
;
    LDI    R0,AR0                           ; Put thread pointer in AR0
    LDI    *+AR0(TCB_STKPTR),R1             ; Pickup the stack pointer
    CMPI   *+AR0(TCB_STKSTART),R1           ; Compare with start of stack addr
    BLO    _TCT_Stack_Overflow              ;   stack overflow condition
    CMPI   *+AR0(TCB_STKEND),R1             ; Compare with end of stack address
    BHI    _TCT_Stack_Overflow              ;   stack overflow condition
;
;     else
;     {
;        /* Calculate the amount of available space on the stack.  */
;        remaining = TCD_Current_Thread -> tc_stack_end  -
;                        TCD_Current_Thread -> tc_stack_pointer;
;
    LDI    *+AR0(TCB_STKEND),R0
    SUBI   R1,R0                            ; Calculate remaining stack space
;
;        /* Is there enough memory on the stack to save all registers?  */
;        if (remaining < REGSAVSIZE)
;
    CMPI   REGSAVSIZE,R0                    ; Is there enough to save context?
    BLO    _TCT_Stack_Overflow              ; No, stack overflow condition
;
;        /* Determine if this is a new minimum amount of stack space.  */
;        else if (remaining < TCD_Current_Thread -> tc_stack_minimum)
;
    CMPI   *+AR0(TCB_STKMIN),R0             ; Is this a new minimum?
    BHS    _TCT_Stack_Check_Finished        ; No, stack checking is finished
;
;            /* Save the new stack minimum.  */
;            TCD_Current_Thread -> tc_stack_minimum =  remaining;
;
    STI    R0,*+AR0(TCB_STKMIN)             ; Save the new minimum
;     }
;    }
_TCT_Stack_Check_Finished:
;
;    /* Return the remaining number of bytes on the stack: already in R0.  */
;    return(remaining);
;
    LDI    *-FP(1),R1
    BD     R1
    LDI    *FP,FP
    NOP
    SUBI   2,SP
***    B    R1    ;BRANCH OCCURS
;
_TCT_Stack_Overflow:
;
;            /* Stack overflow condition exists.  */
;            ERC_System_Error(NU_STACK_OVERFLOW);
;
    LDI    3,R0                             ; Load value of NU_STACK_OVERFLOW
    .if NU_STACK
    PUSH   R0                               ; Put type on the stack
    .else
    LDI    R0,AR2
    .endif
    CALL   _ERC_System_Error                ; Call system error handler-
                                            ;   Does Not return!
;}
;
;
;/*************************************************************************/
;/*                                                                       */

⌨️ 快捷键说明

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