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

📄 ps2.lst

📁 Cypress 的(鼠标+键盘)复合设备汇编源程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
00D6 19 FB [04]     mov A,~PS2_RESEND_REQUESTED
00D8 35 22 [07]     and [ps2_flags      ],A
00DA 81 04 [05]    jmp      .il2                             
00DC            
00DC            .il0:
**** MACRO ****    TSTBIT   PS2_RESEND,ps2_flags                ;if host wants last byte resent
00DC 19 01 [04]     mov A,PS2_RESEND
00DE 11 22 [06]     and A,[ps2_flags                ]
00E0 A0 EE [05]    jz       .il1                             
00E2            
00E2 1A 23 [06]    mov      A,[ps2_last_xmit]                   ;get it
00E4 92 BC [10]    call     ps2_send                            ;resent it
00E6 C1 04 [05]    jc       .il2                             
**** MACRO ****    CLRBIT   PS2_RESEND,ps2_flags                ;reset flag
00E8 19 FE [04]     mov A,~PS2_RESEND
00EA 35 22 [07]     and [ps2_flags                ],A
00EC 81 04 [05]    jmp  .il2                             
00EE            
00EE            .il1:
**** MACRO ****    TSTBIT   PS2_XMIT,ps2_flags                  ;if we've got something interesting to send
00EE 19 02 [04]     mov A,PS2_XMIT
00F0 11 22 [06]     and A,[ps2_flags                  ]
00F2 A1 04 [05]    jz       .il2                             
00F4            
00F4 1A 24 [06]    mov      A,[ps2_xmit_holding_reg]            ;get it
00F6 92 BC [10]    call     ps2_send                            ;send it
00F8 C1 04 [05]    jc       .il2                             
**** MACRO ****    CLRBIT   PS2_XMIT,ps2_flags                  ;clear flag saying we've got something
00FA 19 FD [04]     mov A,~PS2_XMIT
00FC 35 22 [07]     and [ps2_flags                  ],A
00FE 20    [04]         NOP
00FF 1F    [04]         XPAGE
0100 1A 24 [06]    mov      A,[ps2_xmit_holding_reg]            ;save last transmission
0102 31 23 [05]    mov      [ ps2_last_xmit],A                   
0104            
0104            .il2:
0104 3F    [08]        ret                                     ;that is it
0105            
0105            
0105            
0105            ;========================================================================
0105            ; FUNCTION: ps2_do_command
0105            ;
0105            ; host command processor switch statement
0105            ;
0105            ; Returns: nothing
0105            ;========================================================================
0105            
0105            ps2_do_command:
0105            
0105 07 ED [04]    sub      A,0EDh                              ;subtract off base of command                  
0107 C1 3B [05]    jc       ps2_invalid_command                 ;whoops, bad command
0109 41    [04]    mov      X,A                                 ;else save zero-based command in X
010A                                                            ;clear all resend requirementd
**** MACRO ****    CLRBIT  (PS2_RESEND_REQUESTED + PS2_RESEND),ps2_flags       
010A 19 FA [04]     mov A,~(PS2_RESEND_REQUESTED + PS2_RESEND)
010C 35 22 [07]     and [ps2_flags       ],A
010E 40    [04]    mov      A,X                                 ;get back zero-based command
010F 3D    [04]    rlc                                          ;prepare for case jump
0110                                                         ;to proper routine
0110 E1 12 [07]    jacc    .switch              
0112            
0112            XPAGEOFF
0112            .switch:
0112 81 43 [05]     jmp    ps2_set_status_indicators
0114 81 69 [05]     jmp    ps2_echo_enable
0116 81 3B [05]     jmp    ps2_invalid_command
0118 81 71 [05]     jmp    ps2_select_alternate_scan_code
011A 81 3B [05]     jmp    ps2_invalid_command
011C 81 97 [05]     jmp    ps2_read_id
011E 81 D3 [05]     jmp    ps2_set_typematic_rate_delay
0120 81 F8 [05]     jmp    ps2_enable
0122 82 0A [05]     jmp    ps2_default_disable
0124 82 0E [05]     jmp    ps2_set_default
0126 82 1C [05]     jmp    ps2_set_keys
0128 82 1C [05]     jmp    ps2_set_keys
012A 82 1C [05]     jmp    ps2_set_keys
012C 82 1C [05]     jmp    ps2_set_keys
012E 82 64 [05]     jmp    ps2_set_key_type
0130 82 64 [05]     jmp    ps2_set_key_type
0132 82 64 [05]     jmp    ps2_set_key_type
0134 82 37 [05]     jmp    ps2_resend
0136 82 3F [05]     jmp    ps2_reset
0138            endswitch:
0138 C1 05 [05]     jc      ps2_do_command                          ;if command failed,
013A 3F    [08]     ret
013B            XPAGEON
013B            
013B            ;========================================================================
013B            ; FUNCTION: ps2_invalid_command
013B            ;
013B            ; handles invalid commands
013B            ;
013B            ;
013B            ; Returns:
013B            ;   C = 0 for success
013B            ;========================================================================
013B            
013B            ps2_invalid_command:
**** MACRO ****     SETBIT  PS2_RESEND_REQUESTED,ps2_flags          ;flag that we need a resend
013B 19 04 [04]     mov A,PS2_RESEND_REQUESTED
013D 33 22 [07]     or  [ps2_flags          ],A
**** MACRO ****     CLEARC                                          ;clear C indicating we're done
013F 0D 00 [04]     or    A,0
0141 81 38 [05]     jmp     endswitch                               ;and return
0143            
0143            
0143            
0143            ;========================================================================
0143            ; FUNCTION: ps2_set_status_indicators
0143            ;
0143            ; sets indicator leds
0143            ;
0143            ; Returns:
0143            ;
0143            ;   C: 0 if command was sucessful
0143            ;   C: 1 if command failed 
0143            ;
0143            ;========================================================================
0143            
0143            ps2_set_status_indicators:
0143 92 81 [10]     call    ps2_ack_byte                ;ack this command
0145 90 9D [10]     call    ps2_wait_byte               ;wait for 2nd byte
0147 16 08 [04]     cmp           A,8                   ;if 2nd byte invalid                             
0149 C1 4F [05]     jc           .ed0                                
**** MACRO ****     SETC                                ;indicate it
014B 3A    [04]     cpl   A
014C 3A    [04]     cpl   A
014D 81 38 [05]     jmp     endswitch                   ;and return
014F            
014F            .ed0:                                   ;else
014F 10 07 [04]     and     A,7                         ;mask off all but 3 ls bits
0151 F1 61 [14]     index   ps2_led_tbl                 ;use translation table 
0153 2D    [05]     push    A                           ;save it
0154 9B 64 [10]     call    ksc_writeLED              ;write the leds
0156 2B    [04]     pop     A                           ;get it back
0157 10 01 [04]     and     A,NUM_LOCK_LED              ;save state of numlock
0159 31 31 [05]     mov     [ps2key_numlock],A          ;locally
015B 92 81 [10]     call    ps2_ack_byte                ;ack this byte too
**** MACRO ****     CLEARC                              ;indicate we are done
015D 0D 00 [04]     or    A,0
015F 81 38 [05]     jmp     endswitch
0161            
0161            
0161            ;table to translate ps2-command enumeration of leds into our own bits
0161            XPAGEOFF
0161            ps2_led_tbl:
0161 00    [00]     db  0
0162 04    [00]     db  SCROLL_LOCK_LED
0163 01    [00]        db       NUM_LOCK_LED
0164 05    [00]     db  SCROLL_LOCK_LED + NUM_LOCK_LED
0165 02    [00]     db  CAPS_LOCK_LED
0166 06    [00]     db  CAPS_LOCK_LED + SCROLL_LOCK_LED
0167 03    [00]     db  CAPS_LOCK_LED + NUM_LOCK_LED
0168 07    [00]     db  CAPS_LOCK_LED + NUM_LOCK_LED + SCROLL_LOCK_LED       
0169            XPAGEON
0169            
0169            
0169            
0169            
0169            
0169            ;========================================================================
0169            ; 
0169            ; FUNCTION: ps2_echo_enable -- burps back an echo byte
0169            ;
0169            ; Returns:
0169            ;
0169            ;   C: 0 command can't fail
0169            ;========================================================================
0169            
0169            ps2_echo_enable:
0169 19 EE [04]     mov     A,PS2_ECHO                      ;send echo response
016B 92 A2 [10]     call    ps2_put_byte                        ;and respond
**** MACRO ****     CLEARC
016D 0D 00 [04]     or    A,0
016F 81 38 [05]     jmp     endswitch
0171            
0171            ;========================================================================
0171            ;   FUNCTION: ps2_select_alternate_scan_code
0171            ;
0171            ; Returns:
0171            ;
0171            ;   C: 0 if command was sucessful
0171            ;   C: 1 if command failed 
0171            ;========================================================================
0171            
0171            ps2_select_alternate_scan_code:
0171 92 81 [10]     call    ps2_ack_byte                        ;ack this byte
0173 90 9D [10]     call    ps2_wait_byte                       ;wait for alternate code byte
0175 16 04 [04]     cmp     A,4                                 ;if out of range
0177 D1 93 [05]     jnc     .error                              ;exit with C bit set
0179 96 E2 [10]     call    ps2key_clear_key_buffer             ;clear out buffer and stop any typematic stuff       
017B 96 86 [10]     call    ps2key_disable_typematic_action
017D 0D 00 [04]     or      A,0                                 ;else if 1-4
017F A1 87 [05]     jz      .send                                                     
0181 31 30 [05]     mov     [ps2key_scan_set],A                 ;  save it
0183 92 81 [10]     call    ps2_ack_byte                        ;  ack the byte
0185 81 8F [05]     jmp     .exit
0187            .send:                                          ;else, a 0 indicates to send back current scan set
0187 92 81 [10]     call    ps2_ack_byte                        ;ack the byte
0189 C1 8F [05]     jc      .exit                               ;if host inhibit, exit
018B 1A 30 [06]     mov     A,[ps2key_scan_set]                 ;else return current scan set 
018D 92 A2 [10]     call       ps2_put_byte
018F            .exit:
**** MACRO ****     CLEARC
018F 0D 00 [04]     or    A,0
0191 81 38 [05]     jmp     endswitch
0193            .error:
**** MACRO ****     SETC
0193 3A    [04]     cpl   A
0194 3A    [04]     cpl   A
0195 81 38 [05]     jmp     endswitch
0197            
0197            ;========================================================================
0197            ; FUNCTION: ps2_read_id
0197            ;
0197            ;
0197            ; Returns:
0197            ;   C: 0, command can't fail
0197            ;========================================================================
0197            
0197            
0197            ps2_read_id:
0197 92 81 [10]     call    ps2_ack_byte                        ;ack the byte
0199 C1 AB [05]     jc      .exit                               ;if host inhibit during ack, exit
019B            
019B 19 AB [04]     mov     A,0abh                              ;respond with hard coded id bytes
019D 92 A2 [10]     call    ps2_put_byte                     
019F C1 AB [05]     jc      .exit                               ;problem xmitting 1st id, exit
01A1            
01A1 19 83 [04]     mov     A,83h                               ;transmit 2nd byte
01A3 92 A2 [10]     call    ps2_put_byte                     
01A5 96 E2 [10]     call     ps2key_clear_key_buffer             ;clear the key buffer
**** MACRO ****     SETBIT   PS2_SCAN_KBD,ps2_flags              ;enable scanning
01A7 19 08 [04]     mov A,PS2_SCAN_KBD
01A9 33 22 [07]     or  [ps2_flags              ],A
01AB            .exit:
**** MACRO ****     CLEARC
01AB 0D 00 [04]     or    A,0
01AD 81 38 [05]     jmp     endswitch
01AF            ;========================================================================
01AF            ; FUNCTION: ps2_set_typematic_rate_delay
01AF            ;
01AF            ; sets the global typematic rate and delay settings.
01AF            ; this routine uses 2 lookups to convert the values sent by the host,
01AF            ; into the proper 4ms counts that will be used to achieve the rate and delay
01AF            ; functions.  the rate t

⌨️ 快捷键说明

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