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

📄 ps2.lst

📁 Cypress 的(鼠标+键盘)复合设备汇编源程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
0000            TIMER_MSB_MASK:             equ     3Fh     ; six bits
0000            
0000            ;========================================================================
0000            ; Processor Status and Control
0000            
0000            ENTER_SUSPEND:              equ      9h
0000            
0000            RUNBIT:                     equ      1h     ; CPU Run bit
0000            SINGLESTEP:                 equ      2h     ; Single Step
0000            INTERRUPTENABLE:            equ      4h     ; interrupt enable
0000            SUSPENDWAIT:                equ      8h     ; Suspend, wait for interrupt
0000            POWERONRESET:               equ      10h    ; power-on reset
0000            USBRESET:                   equ      20h    ; USB Bus Reset bit
0000            WATCHDOG_RESET:             equ      40h    ; Watchdog Reset bit
0000            IRQPENDING:                 equ      80h    ; IRQ pending
0000            
0000            ;========================================================================
0000            ; USB Status and Control
0000            NOT_FORCING:                equ     00h       ; SIE controls D+/D-
0000            FORCE_K:                    equ     01h       ; D+ high, D- low (resume signal)
0000            FORCE_J:                    equ     02h   ; D+ low, D- high (idle state)
0000            
0000            
0000            
0000            ;========================================================================
0000            ;   FILE: ps2.inc
0000            ;
0000            ;   This file contains ps2-specific delarations
0000            ;
0000            ;========================================================================
0000            BAT_PASS:               equ 0aah
0000            BAT_FAIL:               equ 055h
0000            
0000            
0000            ;status bits for ps2 command processor
0000            
0000            PS2_RESEND:                 equ 1                       
0000            PS2_XMIT:                   equ 2                       
0000            PS2_RESEND_REQUESTED:   equ     4               
0000            PS2_SCAN_KBD:           equ     8                       
0000            
0000            
0000            
0000            PS2_ENABLED_INTERRUPTS: equ     4       ; 1msec interrupt enabled
0000            
0000            ;ps2 clock, data bits are D+ and D-
0000            
0000            PS2_CLOCK_BIT:          equ     DP      ;
0000            PS2_DATA_BIT:           equ     DM      ;
0000            
0000            
0000            ;PS2 response byte declarations
0000            PS2_RSND:           equ 0feh    ;Resend response (request resend from host)
0000            PS2_ACK:                equ     0fah    ;ACK response
0000            PS2_ECHO:               equ     0eeh    ;ECHO response
0000            
0000            
0000            PS2_SCAN_INTERVAL:      equ     4       ;4msec between key scans
0000            
0000            ;define key types for scan set 3. These are carefully chosen to match
0000            ;the enumerations in the ps2-host commands 0xf7 - 0xfd (set all keys, and
0000            ;set key type).
0000            
0000            TYPEMATIC:                      equ 0               
0000            MAKE_BREAK:                     equ 1
0000            MAKE:                           equ 2
0000            TYPEMATIC_MAKE_BREAK:           equ 3
0000            
0000            SCAN_SET_1:                     equ 1
0000            SCAN_SET_2:                     equ 2
0000            SCAN_SET_3:                     equ 3
0000            
0000            ;========================================================================
0000            ;   FILE: macros.inc 
0000            ;
0000            ;   contains useful macro definitions
0000            ;
0000            ;========================================================================
0000                ;clear bit(s) in a RAM location
0000                MACRO CLRBIT BIT REG
0000                mov A,~BIT
0000                and [REG],A
0000                ENDM
0000            
0000                ;set bit(s) in a RAM location
0000                MACRO SETBIT BIT REG
0000                mov A,BIT
0000                or  [REG],A
0000                ENDM
0000              
0000                ;test bit(s) in a RAM location
0000                MACRO TSTBIT BIT REG
0000                mov A,BIT
0000                and A,[REG]
0000                ENDM
0000            
0000                ;clear carry
0000                MACRO CLEARC
0000                or    A,0
0000                ENDM
0000            
0000                ;set carry
0000                MACRO SETC
0000                cpl   A
0000                cpl   A
0000                ENDM
0000            
0000            
0000                ;macro for clearing blocks of RAM
0000                ;destroys X and A
0000                MACRO   CLEARRAM base,length
0000                mov     X,length - 1
0000                mov     A,0
0000            lp:
0000                mov     [X + base],A
0000                dec     X
0000                jnc     lp
0000                ENDM
0000            
0000            
0000                ;macro for packing 4 2-bit fields into a byte
0000            
0000                MACRO TYPE a,b,c,d
0000                    db  (a + b*4 + c*16 + d*64)
0000                ENDM
0000            
0000            
0000                ;delay macro is the front-end for a call to the delay subroutine
0000                ;The fixed overhead of the macro plus the subroutine is 3 us,
0000                ;so this technique is good for delays of 4us or greater.
0000                ;
0000            
0000                MACRO DELAY US
0000                push    A
0000                mov     A,(US-3)
0000                call    delay
0000                ENDM
0000            ;*****
0000            ; CLRC
0000            ;       Clears C bit
0000            ;*****
0000            MACRO CLRC
0000                    add     A,0     ;Clear C-bit
0000                                    ;*** END MACRO CLRC
0000            ENDM
0000            
0000            
0000            ;*****
0000            ; SETFLAG       F
0000            ;       Sets flag F in mouse_flagsV
0000            ;*****
0000            MACRO SETFLAG F
0000                    mov     a,F                     ;a <- F bit
0000                    or      [mouse_flagsV],a        ;set flag
0000                                                    ;*** END MACRO SETFLAG
0000            ENDM
0000            
0000            
0000            ;*****
0000            ; CLRFLAG F
0000            ;       Clear flag F in mouse_flagsV
0000            ;*****
0000            MACRO CLRFLAG F
0000                    mov     a,~F                    ;a <- F mask
0000                    and     [mouse_flagsV],a        ;clear flag
0000                                                    ;*** END MACRO CLRFLAG
0000            ENDM
0000            
0000            
0000            ;*****
0000            ; CHKFLAG F
0000            ;       Check flag F in mouse_flagsV
0000            ;*****
0000            MACRO CHKFLAG F
0000                    mov     a,F                     ;a <- F flag
0000                    and     a,[mouse_flagsV]        ;isolate flag
0000                                                    ;*** END MACRO CHKFLAG
0000            ENDM
0000            
0000            
0000            ;*****
0000            ; CPLFLAG F
0000            ;       Complement flag F in mouse_flagsV
0000            ;*****
0000            MACRO CPLFLAG F
0000                    mov     a,F                     ;a <- F flag
0000                    xor     [mouse_flagsV],a        ;toggle flag
0000                                                    ;*** END MACRO CPLFLAG
0000            ENDM
0000            
0000            
0000            ;=============================================================================
0000            ; PS2_WR_PORT3
0000            ;       Replaces "iowr IO_mouse_port" instruction to the following lines of
0000            ;       code. Makes writes to bit 6 and 7 of Port3 not affecting other bits
0000            ;       which are used for keyboard LED and scan matrix columns.
0000            ;       Assumes the data to be written is in register A.
0000            ;=============================================================================
0000            MACRO PS2_WR_PORT3
0000                    and A, P3_PS2_MASK              ; clear all bits except bit 6 and 7
0000                    mov [ps2_tmp], A                ; move write data to a temporary variable
0000                    mov A,[ksc_p3out]                       ; read current content of port 3
0000                    and A, ~P3_PS2_MASK             ; reset bit 6 and 7
0000                    or A, [ps2_tmp]                 ; or current port 3 data with the write data
0000                    iowr IO_mouse_port
0000                    mov [ksc_p3out], A                      ; store most recent data back to p3out
0000                    
0000            ENDM
0000            MACRO enable_1ms_int
0000                iord    Global_Interrupt
0000                    or              A,  TIMER_ISR_MASK              ; enable 1ms interrupt
0000                    iowr    Global_Interrupt
0000            ENDM
0000            MACRO disable_1ms_int:
0000                iord    Global_Interrupt
0000                    and             A, ~TIMER_ISR_MASK                                  ; enable 1ms interrupt
0000                    iowr    Global_Interrupt
0000            ENDM
0000            
0000            
0000            MACRO enable_EP0_int
0000                mov     A,[configuration_status]
0000                cmp     A,UNCONFIGURED
0000                mov     A,ENDPOINT_ZERO
0000                jz      .exit
0000                or      A,(ENDPOINT_ONE + ENDPOINT_TWO)
0000            .exit:
0000                iowr    ENDPOINT_INTERRUPT_REG
0000            ENDM
0000            MACRO disable_EP0_int
0000                mov     A,[configuration_status]
0000                cmp     A,UNCONFIGURED
0000                mov     A,0
0000                jz      .exit
0000                or      A,(ENDPOINT_ONE + ENDPOINT_TWO)
0000            .exit:
0000                iowr    ENDPOINT_INTERRUPT_REG
0000            ENDM
0000            
0000            ;========================================================================
0000            ;   FILE: at101.inc 
0000            ;
0000            ;   contains the defines for the keys on a 101/102 key keyboard.
0000            ;
0000            ;   The definitions are standard with the addition of the following
0000            ;   codes:
0000            ;
0000            ;   AT101KB_POWER:            EQU         130

⌨️ 快捷键说明

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