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

📄 tick-al.as

📁 uCOS-II 在51单片机上移植的源码
💻 AS
字号:
;********************************************************************************************************
;                                                 uC/OS
;                                          The Real-Time Kernel
;
;                                                TICK ISR
;
;                                       Philips Semiconductors, Inc.
;                                             XA (Large Model)
;
; File : TICK-AL.AS
;********************************************************************************************************

            global  _OSTickISR
            signat  _OSTickISR,24

            global  _OSIntEnter
            global  _OSIntExit
            global  _OSTimeTick

BIT_SSEL0   equ     218h                         ; Segment selection register bit definition
BIT_SSEL1   equ     219h
BIT_SSEL2   equ     21ah
BIT_SSEL3   equ     21bh
BIT_SSEL4   equ     21ch
BIT_SSEL5   equ     21dh
BIT_SSEL6   equ     21eh
BIT_SSEL7   equ     21fh

REG_CS      equ     440h                         ; XA registers
REG_DS      equ     441h
REG_ES      equ     442h
REG_SSEL    equ     403h
REG_PSWH    equ     401h

REG_TCON    equ     410h                         ; TCON register
;/*$PAGE*/
;*********************************************************************************************************
;                                            HANDLE TICK ISR
;                                          void OSTickISR(void)
;
; Total execution time : 151 + Function calls (bus cycles)
;*********************************************************************************************************
            psect   ltext,class=CODE,space=0,align=2

_OSTickISR:
            pushu   r0,r1,r2,r3,r4,r5,r6          ;24~, Save interrupted task's context
            pushu.b REG_ES                        ; 5~, Save ES
            pushu.b REG_SSEL                      ; 5~, Save SSEL
            pop     r2                            ; 5~, Move PSW from SS to US
            pushu   r2                            ; 5~
            pop     r2                            ; 5~, Move PCH from SS to US
            pushu   r2                            ; 5~
            pop     r2                            ; 5~, Move PCL from SS to US
            pushu   r2                            ; 5~

            fcall   _OSIntEnter                   ;     Notify uC/OS about ISR
            or.b    REG_TCON,#10h                 ;     Enable timer #0
            mov.b   REG_PSWH,#80h                 ;     PSWH = 0x80;  Allow interrupts to be nested
            fcall   _OSTimeTick                   ;     Handle system tick
            fcall   _OSIntExit                    ;     Exit uC/OS through scheduler if HPT ready

            popu    r2                            ; 5~, Move PCL from US to SS
            push    r2                            ; 5~
            popu    r2                            ; 5~, Move PCH from US to SS
            push    r2                            ; 5~
            popu    r2                            ; 5~, Move PSW from US to SS
            push    r2                            ; 5~
            popu.b  REG_SSEL                      ; 5~, Get SSEL
            popu.b  REG_ES                        ; 5~, Get ES
            popu    r0,r1,r2,r3,r4,r5,r6          ;18~, Load interrupted task's context
            reti                                  ;10~, Return to interrupted task

⌨️ 快捷键说明

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