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

📄 tmt.asm

📁 电力系统中的保护装置全部代码
💻 ASM
📖 第 1 页 / 共 4 页
字号:
    ADDI   *+AR1(5),R0           ;秒
    CMPI   @SECCNT,R0
    BLOD   WR_T
    LDIHS  0,R0
    STI    R0,*+AR1(5)
    
    LDI    *+AR1(4),R0           ;分
    ADDI   1,R0
    CMPI   60,R0
    BLOD   WR_T
    LDIHS  0,R0
    STI    R0,*+AR1(4)

    LDI    *+AR1(3),R0           ;时
    ADDI   1,R0
    CMPI   24,R0
    BLOD   WR_T
    LDIHS  0,R0
    STI    R0,*+AR1(3)
    
    LDI    *AR1,R0
    AND    3,R0
    BNZ    GETDAY
    LDI    *+AR1(1),R0
    CMPI   2,R0
    BNE    GETDAY
    LDI    29,R1
    BR     INCDAY

GETDAY:
    PUSH   AR2
    LDP    @pDAYTAB
    LDI    @pDAYTAB,R0
    ADDI   *+AR1,R0,AR2
    LDI    *AR2,R1
    POP    AR2

INCDAY:    
    LDI    *+AR1(2),R0           ;日
    ADDI   1,R0
    CMPI   R1,R0
    BLSD   WR_T
    LDIHI  1,R0
    STI    R0,*+AR1(2)
    
    LDI    *+AR1,R0
    ADDI   1,R0
    CMPI   12,R0
    BLSD   WR_T
    LDIHI  1,R0
    STI    R0,*+AR1
    
    LDI    *AR1,R0
    ADDI   1,R0
    STI    R0,*AR1

WR_T:
    LDI    *+AR1(3),R0
    LSH    24,R0
    LDI    *+AR1(4),R1
    LSH    16,R1
    OR     R1,R0
    OR     *+AR1(5),R0
    STI    R0,*AR0
    LDI    *AR1,R0
    LSH    16,R0
    LDI    *+AR1,R1
    LSH    8,R1
    OR     R1,R0
    OR     *+AR1(2),R0
    STI    R0,*+AR0(TIMELEN)
    .if NU_BIG
    LDP    @_TMD_Timer_State                ; Load Data Page Pointer
    .endif
    POP    AR1
    POP    R1
;
;    /* Determine if the count-down timer is active.  */
;    if (TMD_Timer_State == TM_ACTIVE)
;    {
;
    LDI    @_TMD_Timer_State,R0             ; Determine if timer state is active
    BNZD   _TMT_Timer_Not_Active            ; Not active (non-zero)
;
;        /* Decrement the count-down timer.  */
;        TMD_Timer--;
;
    .if NU_BIG
    LDP    @_TMD_Timer                      ; Load Data Page Pointer
    .endif
    LDI    1,R0
    SUBRI  @_TMD_Timer,R0
    STI    R0,@_TMD_Timer 
;        
;        /* Determine if the timer has expired. If so, modify the state 
;           to indicate that it has expired.  */
;        if (TMD_Timer == 0)
;
    BNZ    _TMT_Timer_Not_Active            ; Time non-zero, not expired
;
;            TMD_Timer_State =  TM_EXPIRED;
;
    .if NU_BIG
    LDP    @_TMD_Timer_State                ; Load Data Page Pointer
    .endif
    LDI    TM_EXPIRED,R0                    ; Indicate that timer has expired
    STI    R0,@_TMD_Timer_State
;    }
;
_TMT_Timer_Not_Active:
;
;    /* Determine if the time-slice timer is active. Note that the parameters
;       for the time-slice are controlled by the Thread Control (TC) 
;       component.  */
;    if (TMD_Time_Slice_State == TM_ACTIVE)
;    {
;
    .if NU_BIG
    LDP    @_TMD_Time_Slice_State           ; Load Data Page Pointer
    .endif
    LDI    @_TMD_Time_Slice_State,R0        ; Determine if time slice active
    BNZD   _TMT_Time_Slice_Not_Active       ; Time slice not active (non-zero)
;
;        /* Decrement the time slice counter.  */
;        TMD_Time_Slice--;
;
    .if NU_BIG
    LDP    @_TMD_Time_Slice                 ; Load Data Page Pointer
    .endif
    LDI    1,R0
    SUBRI  @_TMD_Time_Slice,R0
    STI    R0,@_TMD_Time_Slice
;        
;        /* Determine if the time-slice timer has expired. If so, modify the
;           time-slice state to indicate that it has.  */
;        if (TMD_Time_Slice == TM_ACTIVE)
;     {
    BNZ    _TMT_Time_Slice_Not_Active
;
;            TMD_Time_Slice_State =  TM_EXPIRED;
;
    .if NU_BIG
    LDP    @_TMD_Time_Slice_State           ; Load Data Page Pointer
    .endif
    LDI    TM_EXPIRED,R0                    ; Indicate that time-slice timer 
    STI    R0,@_TMD_Time_Slice_State        ;   has expired
;
;            /* Copy the current thread into the time-slice task pointer.  */
;         /* Set the current time slice to 1 just in case it gets missed.  */
;         TMD_Time_Slice_Task = TCD_Current_Thread;
;
    .if NU_BIG
    LDP    @_TCD_Current_Thread             ; Load Data Page Pointer
    .endif
    LDI    @_TCD_Current_Thread,AR0         ; Pickup pointer to tcb
    .if NU_BIG
    LDP    @_TMD_Time_Slice_Task            ; Load Data Page Pointer
    .endif
    BRD    _TMT_Expiration
    STI    AR0,@_TMD_Time_Slice_Task        ; Copy to time_slice task pointer
;
;            /* Set the current time slice to 1, so that it's not lost.  */
;         TCD_Current_Thread -> tc_cur_time_slice = 1;
;
    LDI    1,R0                             ; Set current task's time slice to
    STI    R0,*+AR0(TCB_CURTIMESLC)         ;     minimal value
;
;     }
;    }
_TMT_Time_Slice_Not_Active:
;    
;    /* Determine if either of the basic timers have expired.  If so, 
;       activate the timer HISR.  */
;    if ((TMD_Timer_State != TM_EXPIRED) &&
;        (TMD_Time_Slice_State != TM_EXPIRED))
;    {
;
    .if NU_BIG
    LDP    @_TMD_Timer_State                ; Load Data Page Pointer
    .endif
    LDI    TM_EXPIRED,R0
    CMPI   @_TMD_Timer_State,R0
    BEQD   _TMT_Expiration1
;    .if NU_BIG
;    LDP    @_TMD_Time_Slice_State           ; Load Data Page Pointer
;    .endif
;    LDI    @_TMD_Time_Slice_State,R0
;    CMPI   TM_EXPIRED,R0
;    BEQ    _TMT_Expiration
;
;    /* Recover minimal context and return to point of interrupt.  */
    POP    DP
    POP    AR0
    POP    R0
    POP    ST
    RETI
;    }
;    else
;    {
_TMT_Expiration:
;
;        /* Save context of the system.  */
;     /* Note that interrupts are restored at end of Context_Save */
;     TCT_Interrupt_Context_Save();
    POP    DP
    POP    AR0
    POP    R0

_TMT_Expiration1:

    POP    ST
    PUSH   AR0                  ; Save AR0 before call to Context Save
    CALL   _TCT_Interrupt_Context_Save
;
;        /* Activate the HISR timer function.  */
;        TCT_Activate_HISR((NU_HISR *)&TMD_HISR);
;
    .if NU_BIG
    LDP    @_TMT_Timer_HISR                 ; Load Data Page Pointer
    .endif
    LDI    @_TMT_Timer_HISR,R0
    .if NU_STACK
    PUSH   R0                               ; Put timer's HISR pointer on stack
    .else
    LDI    R0,AR2
    .endif
    CALL   _TCT_Activate_HISR               ; Activate the HISR
    .if NU_STACK
    SUBI   1,SP                             ; Cleanup the stack
    .endif
;
;        /* Restore context.  Note that control does not return from the
;           TCT_Interrupt_Context_Restore function.  */
;        TCT_Interrupt_Context_Restore();
;
    BR     _TCT_Interrupt_Context_Restore
;    }
;}
    .end

⌨️ 快捷键说明

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