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

📄 comm_pca.asm

📁 用与嵌入式系统的通用接口源码包括:lcd ,led, com口,keyboard and so on
💻 ASM
字号:
;********************************************************************************************************
;                                     Embedded Systems Building Blocks
;                                  Complete and Ready-to-Use Modules in C
;
;                                    Asynchronous Serial Communications
;                                    IBM-PC Serial I/O Low Level Driver
;
;                          (c) Copyright 1999-2003, Jean J. Labrosse, Weston, FL
;                                           All Rights Reserved
;
; Filename   : COMM_PCA.ASM
; Programmer : Jean J. Labrosse
; Notes      : If you are not using uC/OS-II you will need to DELETE the increments of OSIntNesting and
;              the calls to OSIntExit().
;********************************************************************************************************

            PUBLIC _Comm1ISR
            PUBLIC _Comm2ISR

            EXTRN  _OSIntExit:FAR
            EXTRN  _CommISRHandler:FAR

            EXTRN  _OSIntNesting:BYTE
            EXTRN  _OSTCBCur:DWORD

.MODEL      LARGE
.CODE
.186

;/*$PAGE*/
;*********************************************************************************************************
;                                           HANDLE COM1 ISR
;
; Note(s)    : 1) This code has been modified to work with uC/OS-II V2.52 and higher
;
;              2) The following C-like pseudo-code describe the operation being performed in the code below.
;
;                 Save all registers on the current task's stack;
;                 OSIntNesting++;
;                 if (OSIntNesting == 1) {
;                     OSTCBCur->OSTCBStkPtr = SS:SP
;                 }
;                 CommISRHandler(1);         Handle the communication interrupt in C
;                 OSIntExit();               Notify uC/OS-II about end of ISR
;                 Restore all registers that were save on the current task's stack;
;                 Return from Interrupt;
;*********************************************************************************************************
;
_Comm1ISR   PROC   FAR
;
            PUSHA                                ; Save interrupted task's context
            PUSH   ES
            PUSH   DS
;
            MOV    AX, DGROUP                    ; Reload DS with DGROUP
            MOV    DS, AX
;
            MOV    AX, SEG(_OSIntNesting)        ; Reload DS 
            MOV    DS, AX
            INC    BYTE PTR DS:_OSIntNesting     ; Notify uC/OS-II of ISR
;
            CMP    BYTE PTR DS:_OSIntNesting, 1	 ; if (OSIntNesting == 1)
            JNE    SHORT _Comm1ISR_1             
            MOV    AX, SEG(_OSTCBCur)            ;     Reload DS
            MOV    DS, AX
            LES    BX, DWORD PTR DS:_OSTCBCur    ;     OSTCBCur->OSTCBStkPtr = SS:SP
            MOV    ES:[BX+2], SS                 ;
            MOV    ES:[BX+0], SP                 ;
;
_Comm1ISR_1:
            PUSH   1                             ; Indicate COMM1
            CALL   FAR PTR _CommISRHandler       ; Process COMM interrupt
            ADD    SP,2
;
            CALL   FAR PTR _OSIntExit            ; Notify OS of end of ISR
;
            POP    DS                            ; Restore interrupted task's context
            POP    ES
            POPA
;
            IRET                                 ; Return to interrupted task
;
_Comm1ISR   ENDP
;
;/*$PAGE*/
;*********************************************************************************************************
;                                           HANDLE COM2 ISR
;
; Note(s)    : 1) This code has been modified to work with uC/OS-II V2.52 and higher
;
;              2) The following C-like pseudo-code describe the operation being performed in the code below.
;
;                 Save all registers on the current task's stack;
;                 OSIntNesting++;
;                 if (OSIntNesting == 1) {
;                     OSTCBCur->OSTCBStkPtr = SS:SP
;                 }
;                 CommISRHandler(2);         Handle the communication interrupt in C
;                 OSIntExit();               Notify uC/OS-II about end of ISR
;                 Restore all registers that were save on the current task's stack;
;                 Return from Interrupt;
;*********************************************************************************************************
;
_Comm2ISR   PROC   FAR
;
            PUSHA                                ; Save interrupted task's context
            PUSH   ES
            PUSH   DS
;
            MOV    AX, SEG(_OSIntNesting)        ; Reload DS 
            MOV    DS, AX
            INC    BYTE PTR DS:_OSIntNesting     ; Notify uC/OS-II of ISR
;
            CMP    BYTE PTR DS:_OSIntNesting, 1	 ; if (OSIntNesting == 1)
            JNE    SHORT _Comm2ISR_1             
            MOV    AX, SEG(_OSTCBCur)            ;     Reload DS
            MOV    DS, AX
            LES    BX, DWORD PTR DS:_OSTCBCur    ;     OSTCBCur->OSTCBStkPtr = SS:SP
            MOV    ES:[BX+2], SS                 ;
            MOV    ES:[BX+0], SP                 ;
;
_Comm2ISR_1:
            PUSH   2                             ; Indicate COMM2
            CALL   FAR PTR _CommISRHandler       ; Process COMM interrupt
            ADD    SP,2
;
            CALL   FAR PTR _OSIntExit            ; Notify OS of end of ISR
;
            POP    DS                            ; Restore interrupted task's context
            POP    ES
            POPA
;
            IRET                                 ; Return to interrupted task
;
_Comm2ISR   ENDP
;
            END

⌨️ 快捷键说明

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