📄 ex.lst
字号:
0018 ;********************************************************************
001A ORG 1Ah
001A
001A errorHandler:
001A 73 [08] reti ; do nothing
001B
001B ps2Error:
001B 00 [07] halt
001C 80 1B [05] jmp ps2Error
001E
001E ;********************************************************************
001E ;
001E ; Interrupt handler: dualMain
001E ; Purpose: The program jumps to this routine when the microcontroller
001E ; has a power on reset.
001E ;
001E ;********************************************************************
001E dualMain:
001E ;
001E ; General Setup
001E ;
001E
001E 70 [04] di ; disable interrupts
001F
001F 19 20 [04] mov A, DUAL_DSP_DATA ; set DSP stack pointer
0021 30 [05] swap A, DSP ;
0022
0022 19 00 [04] mov A, 00h ; set up program stack pointer
0024 60 [04] mov psp, A ;
0025
0025 ;
0025 ; clear dual interface variables
0025 ;
0025 31 33 [05] mov [delayCounter], A
0027 31 34 [05] mov [dualInterface1ms], A
0029
0029 ;
0029 ; Initialize button/optics variables
0029 ;
0029 31 20 [05] mov [debounceCount], A
002B 31 24 [05] mov [xCount], A
002D 31 25 [05] mov [yCount], A
002F 31 26 [05] mov [zCount], A
0031 31 30 [05] mov [buttonValue], A
0033 31 27 [05] mov [buttonMachine], A
0035 31 2D [05] mov [lastHorzState], A
0037 31 2C [05] mov [lastVertState], A
0039 31 2E [05] mov [lastZstate], A
003B 31 28 [05] mov [eventMachine], A
003D
003D 19 83 [04] mov A, (LEFT_BUTTON_MASK | RIGHT_BUTTON_MASK | MIDDLE_BUTTON_MASK)
003F 31 21 [05] mov [currentButtonState], A
0041 31 22 [05] mov [lastButtonState], A
0043
0043 19 00 [04] mov A, PS2_MOUSE ; default is PS2 interface
0045 31 32 [05] mov [dualInterfaceMouse], A ;
0047
0047 19 07 [04] mov A, FORCE_HIZ ; set D+, D- to HI-Z
0049 2A 1F [05] iowr USB_STATUS_CONTROL_REG ;
004B
004B ;
004B ; Set buttons in resistive/CMOS, LED in medium sink/CMOS
004B ; and optics in HI-Z/CMOS
004B ;
004B
004B 19 80 [04] mov A, PORT0_NORMAL
004D 2A 00 [05] iowr PORT0
004F 19 80 [04] mov A, PORT0_MODE1_NORMAL
0051 2A 0B [05] iowr PORT0_MODE1
0053 19 40 [04] mov A, PORT0_MODE0_NORMAL
0055 2A 0A [05] iowr PORT0_MODE0
0057
0057 19 03 [04] mov A, PORT1_NORMAL
0059 2A 01 [05] iowr PORT1
005B 19 03 [04] mov A, PORT1_MODE1_NORMAL
005D 2A 0D [05] iowr PORT1_MODE1
005F 19 00 [04] mov A, PORT1_MODE0_NORMAL
0061 2A 0C [05] iowr PORT1_MODE0
0063
0063 ;
0063 ; set up interrupts
0063 ;
0063 19 00 [04] mov A, 00h ; clear all endpoint interrupts
0065 2A 21 [05] iowr ENDPOINT_INT ;
0067
0067 19 04 [04] mov A, 1MS_INT ; enable 1 ms interrupt
0069 2A 20 [05] iowr GLOBAL_INTERRUPT_REG ;
006B
006B 72 [04] ei ; enable interrupts
006C
006C 9C 00 [10] call getMouseType ; get mouse type in (A)
006E 31 32 [05] mov [dualInterfaceMouse], A ; and save it for later use
0070
0070 16 01 [05] cmp A, USB_MOUSE
0072 A5 0F [05] jz usbMain ; go if USB interface
0074 80 76 [05] jmp ps2Main ; go if PS/2 interface
0076
0076 ;********************************************************************
0076 ;
0076 ; Main Entry for PS/2 Interface
0076 ;
0076 ;********************************************************************
0076 ps2Main:
0076 70 [04] di ; disable interrupts
0077
0077 ;
0077 ; Initialize PS2 Variables
0077 ;
0077 19 00 [04] mov A, 00h
0079 31 35 [05] mov [ps2Temp0], A
007B 31 36 [05] mov [ps2LastValidCmd], A
007D 31 47 [05] mov [ps2XmitBufferLen], A
007F 31 48 [05] mov [ps2XmitLen], A
0081 19 0A [04] mov A, 10 ; set for 10 reports/sec
0083 31 40 [05] mov [ps2IntervalCount], A ;
0085 92 A2 [10] call ps2SetDefault ; set default parameters
0087
0087 72 [04] ei ; enable interrupts
0088 93 1F [10] call ps2BAT ; load BAT code onto transmit
008A ; buffer (AAh followed by 00h)
008A
008A ;********************************************************************
008A ;
008A ; Main PS/2 Task Loop
008A ;
008A ;********************************************************************
008A ps2TaskLoop:
008A 2A 26 [05] iowr WATCHDOG_REG ; clear watchdog timer
008C 9B 5A [10] call processButtons ; determine button value
008E 9A AC [10] call readProcessOptics ; compute (x,y,z) of optics
0090 93 3F [10] call ps2GetHostByte ; get data from host, if any,
0092 ; but does not save it in buffer
0092 D0 B8 [05] jnc doCommand ; go & process data received from host
0094
0094 ;
0094 ; At here, we either have an error in receiving data or
0094 ; host does not send any data
0094 ;
0094 1A 48 [05] mov A, [ps2XmitLen] ; get remaining bytes to be sent to host
0096 16 00 [05] cmp A, 00h
0098 A0 9E [05] jz mouseTask ; go if no byte to send
009A 93 7A [10] call ps2SendNextByte ; send next remaining byte to host
009C ; from xmit buffer
009C 80 8A [05] jmp ps2TaskLoop ; go back for next transaction
009E
009E mouseTask:
009E 27 40 [07] dec [ps2IntervalCount]
00A0 1A 40 [05] mov A, [ps2IntervalCount]
00A2 16 00 [05] cmp A, 00h
00A4 B0 8A [05] jnz ps2TaskLoop ; go if report interval not expired
00A6
00A6 92 C9 [10] call ps2ResetMouseReportInterval
00A8 1A 3B [05] mov A, [ps2StreamMode]
00AA 16 01 [05] cmp A, 01h
00AC B0 8A [05] jnz ps2TaskLoop ; go if not in stream mode
00AE
00AE 1A 3D [05] mov A, [ps2MouseEnabled]
00B0 16 01 [05] cmp A, 01h
00B2 B0 8A [05] jnz ps2TaskLoop ; go if mouse not enabled
00B4
00B4 ;
00B4 ; At here, stream mode is on, mouse is enabled and report interval
00B4 ; has expired
00B4 ;
00B4
00B4 92 CE [10] call loadMousePacket ; load mouse packet into xmit buffer
00B6 80 8A [05] jmp ps2TaskLoop ; ready to send packet out
00B8
00B8 doCommand:
00B8 91 34 [10] call ps2DoCommand ; process host commands
00BA 80 8A [05] jmp ps2TaskLoop ; next transaction
00BC
00BC
00BC ;********************************************************************
00BC ;
00BC ; Processing of Host PS2 Commands
00BC ;
00BC ;********************************************************************
0100 ORG 100h
0100
0100 ;========================================================================
0100 ; FUNCTION: ps2DoCommand
0100 ;
0100 ; Decodes commands and process them thru appropriate functions defined
0100 ; in the dispatch table below.
0100 ;
0100 ; On Entry: (A) = command byte received from host
0100 ;
0100 ;========================================================================
0100
0100 XPAGEOFF
0100
0100 ps2CmdTable: ; dispatch table for ps2 host commands
0100 81 C4 [05] jmp ps2ResetScaling ; (command byte = 0E6h)
0102 81 C9 [05] jmp ps2SetScaling2_1 ; (0E7h)
0104 81 CE [05] jmp ps2SetResolution ; (0E8h)
0106 81 E6 [05] jmp ps2StatusRequest ; (0E9h)
0108 82 31 [05] jmp ps2SetStreamMode ; (0EAh)
010A 82 38 [05] jmp ps2ReadData ; (0EBh)
010C 82 41 [05] jmp ps2ResetWrapMode ; (0ECh)
010E 81 AC [05] jmp ps2DoCmdError ; Not defined
0110 82 50 [05] jmp ps2SetWrapMode ; (0EEh)
0112 81 AC [05] jmp ps2DoCmdError ; Not defined
0114 82 55 [05] jmp ps2SetRemoteMode ; (0F0h)
0116 81 AC [05] jmp ps2DoCmdError ; Not defined
0118 82 5A [05] jmp ps2ReadDeviceType ; (0F2h)
011A 82 7B [05] jmp ps2SetSampleRate ; (0F3h)
011C 82 98 [05] jmp ps2EnableMouse ; (0F4h)
011E 82 9D [05] jmp ps2DisableMouse ; (0F5h)
0120 82 A2 [05] jmp ps2SetDefault ; (0F6h)
0122 81 AC [05] jmp ps2DoCmdError ; Not defined (0F7h)
0124 81 AC [05] jmp ps2DoCmdError ; Not defined (0F8h)
0126 81 AC [05] jmp ps2DoCmdError ; Not defined (0F9h)
0128 81 AC [05] jmp ps2DoCmdError ; Not defined (0FAh)
012A 81 AC [05] jmp ps2DoCmdError ; Not defined (0FBh)
012C 81 AC [05] jmp ps2DoCmdError ; Not defined (0FCh)
012E 81 AC [05] jmp ps2DoCmdError ; Not defined (0FDh)
0130 82 BD [05] jmp ps2Resend ; (0FEh)
0132 82 C2 [05] jmp ps2Reset ; (0FFh)
0134
0134 XPAGEON
0134
0134 ps2DoCommand:
0134 31 42 [05] mov [saveCmd], A ; save command byte for later use
0136 1A 3F [05] mov A, [ps2WrapMode]
0138 16 01 [05] cmp A, 01h
013A B1 4E [05] jnz checkLastValidCmd ; go if not in echo mode
013C
013C 19 00 [04] mov A, 00h ; clear last valid command
013E 31 36 [05] mov [ps2LastValidCmd], A ;
0140 1A 42 [05] mov A, [saveCmd] ; get host command/data byte back
0142 16 FF [05] cmp A, PS2_RESET_CMD
0144 A1 4E [05] jz checkLastValidCmd ; "reset" gets us out of echo mode
0146 16 EC [05] cmp A, PS2_RESET_WRAP_MODE_CMD
0148 A1 4E [05] jz checkLastValidCmd ; "reset wrap" gets us out of echo mode
014A 93 96 [10] call ps2SendResponseByte ; echo byte in (A) back to host
014C 81 C3 [05] jmp doCmdExit ; exit
014E
014E ;
014E ; Check for commands that have 2 bytes, namely, ps2SetSampleRate
014E ; and ps2SetResolution
014E ;
014E
014E checkLastValidCmd:
014E 1A 36 [05] mov A, [ps2LastValidCmd]
0150 16 F3 [05] cmp A, PS2_SET_SAMPLE_RATE_CMD ; is last command set sample rate?
0152 B1 6C [05] jnz doCmd1 ; no, go and continue
0154
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -