MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 00002 ; 00003 ; ============================================================================ 00004 ; 00005 ; Peripheral Description: 00006 ; 00007 ; This peripheral enumerates as a vendor-specific device. The main event loop 00008 ; blinks an LED connected to RA1 on and off at about 5 Hz. 00009 ; The firmware is configured to use an external 24-MHz 00010 ; crystal, to operate as a full-speed USB device, and to use the internal 00011 ; pull-up resistor. 00012 ; 00013 ; ============================================================================ 00014 ; 00015 00016 #include 00001 LIST 00002 00003 ;========================================================================== 00004 ; $Id: P18F4550.INC,v 1.8.2.2 2005/10/11 01:51:28 curtiss Exp $ 00005 ; MPASM PIC18F4550 processor include 00006 ; 00007 ; (c) Copyright 1999-2005 Microchip Technology, All rights reserved 00008 ;========================================================================== 00009 01642 LIST 00017 #include "usb_defs.inc" 00001 #define NUM_CONFIGURATIONS 1 00002 #define NUM_INTERFACES 1 00003 #define NUM_ENDPOINTS 3 00004 #define NUM_STRINGS 2 00005 #define MAX_PACKET_SIZE 8 ; maximum packet size for low-speed peripherals is 8 bytes, for full-speed peripherals it can be 8, 16, 32, or 64 bytes 00006 00007 #define EP01_OUT 0x01 00008 #define EP01_IN 0x81 00009 #define EP02_OUT 0x02 00010 #define EP02_IN 0x82 00011 #define EP03_OUT 0x03 00012 #define EP03_IN 0x83 00013 #define EP04_OUT 0x04 00014 #define EP04_IN 0x84 00015 #define EP05_OUT 0x05 00016 #define EP05_IN 0x85 00017 #define EP06_OUT 0x06 00018 #define EP06_IN 0x86 00019 #define EP07_OUT 0x07 00020 #define EP07_IN 0x87 00021 #define EP08_OUT 0x08 00022 #define EP08_IN 0x88 00023 #define EP09_OUT 0x09 00024 #define EP09_IN 0x89 00025 #define EP10_OUT 0x0A MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00026 #define EP10_IN 0x8A 00027 #define EP11_OUT 0x0B 00028 #define EP11_IN 0x8B 00029 #define EP12_OUT 0x0C 00030 #define EP12_IN 0x8C 00031 #define EP13_OUT 0x0D 00032 #define EP13_IN 0x8D 00033 #define EP14_OUT 0x0E 00034 #define EP14_IN 0x8E 00035 #define EP15_OUT 0x0F 00036 #define EP15_IN 0x8F 00037 00038 #define CONTROL 0x00 ; Control Endpoint 00039 #define ISOCHRONOUS 0x01 ; Isochronous Endpoint (Look also Synchronization and Usage Type ) 00040 #define BULK 0x02 ; Bulk Endpoint 00041 #define INTERRUPT 0x03 ; Interrupt Endpoint 00042 00043 ; Define the states that the USB interface can be in 00044 #define POWERED_STATE 0x00 00045 #define DEFAULT_STATE 0x01 00046 #define ADDRESS_STATE 0x02 00047 #define CONFIG_STATE 0x03 00048 00049 ; Define the states for Control EndPoints 00050 #define EP_IDLE_STATE 0x00 00051 #define EP_SETUP_STATE 0x01 00052 #define EP_DISABLED_STATE 0xff 00053 00054 #define ENDPT_DISABLED 0x00 00055 #define ENDPT_IN_ONLY 0x12 00056 #define ENDPT_OUT_ONLY 0x14 00057 #define ENDPT_CONTROL 0x16 ; enable for in, out and setup 00058 #define ENDPT_NON_CONTROL 0x1E ; enable for in, and out 00059 00060 #define INT_STAT_MASK_RESET 0x01 00061 #define INT_STAT_MASK_ERROR 0x02 00062 #define INT_STAT_MASK_TOKEN_DONE 0x04 00063 #define INT_STAT_MASK_SLEEP 0x08 00064 #define INT_STAT_MASK_STALL 0x10 00065 00066 #define TOKEN_OUT (0x01<<2) 00067 #define TOKEN_ACK (0x02<<2) 00068 #define TOKEN_IN (0x09<<2) 00069 #define TOKEN_SETUP (0x0D<<2) 00070 00071 ; Define buffer descriptor table register mapping for no ping-pong buffers 00072 #define BD0OST 0x0400 00073 #define BD0OBC 0x0401 00074 #define BD0OAL 0x0402 00075 #define BD0OAH 0x0403 00076 #define BD0IST 0x0404 00077 #define BD0IBC 0x0405 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00078 #define BD0IAL 0x0406 00079 #define BD0IAH 0x0407 00080 #define BD1OST 0x0408 00081 #define BD1OBC 0x0409 00082 #define BD1OAL 0x040A 00083 #define BD1OAH 0x040B 00084 #define BD1IST 0x040C 00085 #define BD1IBC 0x040D 00086 #define BD1IAL 0x040E 00087 #define BD1IAH 0x040F 00088 #define BD2OST 0x0410 00089 #define BD2OBC 0x0411 00090 #define BD2OAL 0x0412 00091 #define BD2OAH 0x0413 00092 #define BD2IST 0x0414 00093 #define BD2IBC 0x0415 00094 #define BD2IAL 0x0416 00095 #define BD2IAH 0x0417 00096 #define BD3OST 0x0418 00097 #define BD3OBC 0x0419 00098 #define BD3OAL 0x041A 00099 #define BD3OAH 0x041B 00100 #define BD3IST 0x041C 00101 #define BD3IBC 0x041D 00102 #define BD3IAL 0x041E 00103 #define BD3IAH 0x041F 00104 #define BD4OST 0x0420 00105 #define BD4OBC 0x0421 00106 #define BD4OAL 0x0422 00107 #define BD4OAH 0x0423 00108 #define BD4IST 0x0424 00109 #define BD4IBC 0x0425 00110 #define BD4IAL 0x0426 00111 #define BD4IAH 0x0427 00112 #define BD5OST 0x0428 00113 #define BD5OBC 0x0429 00114 #define BD5OAL 0x042A 00115 #define BD5OAH 0x042B 00116 #define BD5IST 0x042C 00117 #define BD5IBC 0x042D 00118 #define BD5IAL 0x042E 00119 #define BD5IAH 0x042F 00120 #define BD6OST 0x0430 00121 #define BD6OBC 0x0431 00122 #define BD6OAL 0x0432 00123 #define BD6OAH 0x0433 00124 #define BD6IST 0x0434 00125 #define BD6IBC 0x0435 00126 #define BD6IAL 0x0436 00127 #define BD6IAH 0x0437 00128 #define BD7OST 0x0438 00129 #define BD7OBC 0x0439 00130 #define BD7OAL 0x043A MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 4 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00131 #define BD7OAH 0x043B 00132 #define BD7IST 0x043C 00133 #define BD7IBC 0x043D 00134 #define BD7IAL 0x043E 00135 #define BD7IAH 0x043F 00136 #define BD8OST 0x0440 00137 #define BD8OBC 0x0441 00138 #define BD8OAL 0x0442 00139 #define BD8OAH 0x0443 00140 #define BD8IST 0x0444 00141 #define BD8IBC 0x0445 00142 #define BD8IAL 0x0446 00143 #define BD8IAH 0x0447 00144 #define BD9OST 0x0448 00145 #define BD9OBC 0x0449 00146 #define BD9OAL 0x044A 00147 #define BD9OAH 0x044B 00148 #define BD9IST 0x044C 00149 #define BD9IBC 0x044D 00150 #define BD9IAL 0x044E 00151 #define BD9IAH 0x044F 00152 #define BD10OST 0x0450 00153 #define BD10OBC 0x0451 00154 #define BD10OAL 0x0452 00155 #define BD10OAH 0x0453 00156 #define BD10IST 0x0454 00157 #define BD10IBC 0x0455 00158 #define BD10IAL 0x0456 00159 #define BD10IAH 0x0457 00160 #define BD11OST 0x0458 00161 #define BD11OBC 0x0459 00162 #define BD11OAL 0x045A 00163 #define BD11OAH 0x045B 00164 #define BD11IST 0x045C 00165 #define BD11IBC 0x045D 00166 #define BD11IAL 0x045E 00167 #define BD11IAH 0x045F 00168 #define BD12OST 0x0460 00169 #define BD12OBC 0x0461 00170 #define BD12OAL 0x0462 00171 #define BD12OAH 0x0463 00172 #define BD12IST 0x0464 00173 #define BD12IBC 0x0465 00174 #define BD12IAL 0x0466 00175 #define BD12IAH 0x0467 00176 #define BD13OST 0x0468 00177 #define BD13OBC 0x0469 00178 #define BD13OAL 0x046A 00179 #define BD13OAH 0x046B 00180 #define BD13IST 0x046C 00181 #define BD13IBC 0x046D 00182 #define BD13IAL 0x046E 00183 #define BD13IAH 0x046F MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 5 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00184 #define BD14OST 0x0470 00185 #define BD14OBC 0x0471 00186 #define BD14OAL 0x0472 00187 #define BD14OAH 0x0473 00188 #define BD14IST 0x0474 00189 #define BD14IBC 0x0475 00190 #define BD14IAL 0x0476 00191 #define BD14IAH 0x0477 00192 #define BD15OST 0x0478 00193 #define BD15OBC 0x0479 00194 #define BD15OAL 0x047A 00195 #define BD15OAH 0x047B 00196 #define BD15IST 0x047C 00197 #define BD15IBC 0x047D 00198 #define BD15IAL 0x047E 00199 #define BD15IAH 0x047F 00200 00201 #define USB_Buffer 0x0480 ; Register location after last buffer descriptor register 00202 00203 #define UOWN 0x07 00204 00205 ; offsets from the beginning of the Buffer Descriptor 00206 #define BYTECOUNT 0x01 00207 #define ADDRESSL 0x02 00208 #define ADDRESSH 0x03 00209 00210 ; standard descriptor types 00211 #define DEVICE 1 00212 #define CONFIGURATION 2 00213 #define STRING 3 00214 #define INTERFACE 4 00215 #define ENDPOINT 5 00216 00217 ; HID class descriptor types 00218 #define HID 0x21 00219 #define REPORT 0x22 00220 #define PHYSICAL 0x23 00221 00222 ; offsets from the beginning of the setup data record 00223 #define bmRequestType 0x00 00224 #define bRequest 0x01 00225 #define wValue 0x02 00226 #define wValueHigh 0x03 00227 #define wIndex 0x04 00228 #define wIndexHigh 0x05 00229 #define wLength 0x06 00230 #define wLengthHigh 0x07 00231 00232 ; Standard USB requests 00233 #define NO_REQUEST 0xFF 00234 #define GET_STATUS 0x00 00235 #define CLEAR_FEATURE 0x01 00236 #define SET_FEATURE 0x03 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 6 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00237 #define SET_ADDRESS 0x05 00238 #define GET_DESCRIPTOR 0x06 00239 #define SET_DESCRIPTOR 0x07 00240 #define GET_CONFIGURATION 0x08 00241 #define SET_CONFIGURATION 0x09 00242 #define GET_INTERFACE 0x0A 00243 #define SET_INTERFACE 0x0B 00244 #define SYNCH_FRAME 0x0C 00245 00246 ; HID Class requests 00247 #define GET_REPORT 0x01 00248 #define GET_IDLE 0x02 00249 #define GET_PROTOCOL 0x03 00250 #define SET_REPORT 0x09 00251 #define SET_IDLE 0x0A 00252 #define SET_PROTOCOL 0x0B 00253 00254 #define GET_STRING_DESCRIPTOR 0x66 00255 #define HID_SET_REPORT 0x21 00256 #define VEND_SET_MEMORY 0x80 00257 00258 #define SVCUSBINT 0x01 << 2 00259 #define SVCTOKENDONE 0x02 << 2 00260 #define SVCRESET 0x03 << 2 00261 #define SVCSLEEP 0x04 << 2 00262 #define SVCSTALL 0x05 << 2 00263 #define SVCERROR 0x06 << 2 00264 #define SVCACTIVITY 0x07 << 2 00265 #define TOKENOUT 0x08 << 2 00266 #define TOKENIN 0x09 << 2 00267 #define TOKENSETUP 0x0A << 2 00268 #define CLEARFEATURE 0x0B << 2 00269 #define GETCONFIG 0x0C << 2 00270 #define GETDESCRIPTOR 0x0D << 2 00271 #define GETINTERFACE 0x0E << 2 00272 #define GETSTATUS 0x0F << 2 00273 #define SETADDRESS 0x10 << 2 00274 #define SETCONFIG 0x11 << 2 00275 #define SETFEATURE 0x12 << 2 00276 #define SETINTERFACE 0x13 << 2 00277 #define FINISHSETADDRESS 0x14 << 2 00278 #define COPYDESC2EP0 0x15 << 2 00279 #define COPYSTRINGDESC2EP0 0x16 << 2 00280 #define ZEROLENPACKET 0x17 << 2 00281 00282 #define EP0 0x00 << 3 00283 #define EP1 0x01 << 3 00284 #define EP2 0x02 << 3 00285 00286 #define STANDARD 0x00 << 5 00287 #define CLASS 0x01 << 5 00288 #define VENDOR 0x02 << 5 00289 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 7 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00290 #define RECIPIENT_DEVICE 0x00 00291 #define RECIPIENT_INTERFACE 0x01 00292 #define RECIPIENT_ENDPOINT 0x02 00293 00294 #define DEVICE_REMOTE_WAKEUP 0x01 00295 #define ENDPOINT_HALT 0x00 00018 #include "ENGR2210.inc" 00001 ; ------------------------------------------------------------------------------- 00002 ; ENGR 2210 PIC ASSEMBLER MACROS 00003 ; ------------------------------------------------------------------------------- 00004 ; Created by Bradley A. Minch 9/2004 to facilitate reasonably structured 00005 ; programming in PIC assembler. These macros were inspired and informed 00006 ; both by Karl Lunt's PIC macros, described in an atricle in the July 1999 00007 ; Nuts & Volts magazine, and by Myke Predko's structured programming macros, 00008 ; which are described on pp. 542-546 of the second edition of Programming and 00009 ; Customizing PICmicro Microcontrollers. These macros provide facilities for 00010 ; for-next loops, repeat-until loops, select satatements, and if statements. 00011 ; ------------------------------------------------------------------------------- 00012 ; Revision History: 00013 ; 01/06/2006 - Fixed problem with <= and >= in until, untilf, ifl, iff, andif, 00014 ; andiff, orif, oriff, elsif, and elsiff macros. 00015 ; 04/21/2005 - Initial public release. 00016 ; 04/08/2005 - Port from 16C instruction set to 18C instruction set completed. 00017 ; 10/19/2004 - Macros for 16C instruction set completed. 00018 ; -------------------------------------------------------------------------------- 00019 ; FOR-NEXT LOOP MACROS 00020 ; ------------------------------------------------------------------------------- 00021 ; Macros: for, forf, forlf, forfl, next, nextl, nextf, exitfor, escfor 00022 ; ------------------------------------------------------------------------------- 00023 ; The for-next group of macros provides an iterated looping structure in which 00024 ; an index variable takes on a succession of values from the specified starting 00025 ; value to the specified ending value. The loop begins with one of the four for 00026 ; macros. These each take three arguments: the register to use as an index 00027 ; variable, the initial value of the index, and the final value of the index. 00028 ; The only difference between the for macros is whether the initial values and 00029 ; final values are literals (i.e., constants) or contained in registers (i.e., 00030 ; variables). Before the first loop iteration, the index register is set to the 00031 ; specified initial value. At the top of the loop, the current value of the 00032 ; index is compared to the specified ending value; if the index exceeds the 00033 ; ending value, the loop terminates. The loop ends with one of the three next 00034 ; macros. They each take the index register as an argument. Two of them take 00035 ; a second argument, which specifies the step size. The index is incremented 00036 ; by the specified step size at the bottom of the loop. Any one of the for 00037 ; macros can be used with any one of the next macros. In the present version, 00038 ; the index variable can only count up. An example of the basic form of the for 00039 ; loop is as follows: 00040 ; 00041 ; for i, 1, 10 00042 ; . 00043 ; . 00044 ; . 00045 ; next i 00046 ; MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 8 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00047 ; In this case, the body of the loop would be executed ten times with the index 00048 ; variable, i, taking on each integer value between 1 and 10 on each succesive 00049 ; iteration of the loop. For loops may be nested to any depth. The macros 00050 ; exitfor and escfor respectively exit the innermost and outermost for loop in 00051 ; a nested for-loop structure. Both the for and next macros make use of the W 00052 ; register. 00053 ; ------------------------------------------------------------------------------- 0000 00054 variable _forcount = 0 0000 00055 variable _forstackptr = 0 00056 00057 ; ------------------------------------------------------------------------------- 00058 ; FOR (START OF A FOR-NEXT LOOP) 00059 ; ------------------------------------------------------------------------------- 00060 ; Syntax: for index, begl, endl 00061 ; ------------------------------------------------------------------------------- 00062 ; Arguments: index the register to be used as the loop index variable 00063 ; begl a literal value used as the initial value of the index 00064 ; endl a literal value used as the final value of the index 00065 ; ------------------------------------------------------------------------------- 00066 ; The body of the loop executes until the value of the index exceeds the endl 00067 ; literal value, at which point the loop terminates with the statement following 00068 ; the next that terminates the loop. This test is performed at the top of the 00069 ; loop. This macro destroys the contents of the W register. You can terminate 00070 ; a for loop with next, nextl, or nextf. 00071 ; ------------------------------------------------------------------------------- 00072 for macro index,begl,endl 00073 movlw begl 00074 movwf index,BANKED 00075 _for#v(_forcount) 00076 movf index,W,BANKED 00077 sublw endl 00078 btfss STATUS,C,ACCESS 00079 goto _next#v(_forcount) 00080 variable _forstack#v(_forstackptr) = _forcount 00081 _forstackptr ++ 00082 _forcount ++ 00083 endm 00084 00085 ; ------------------------------------------------------------------------------- 00086 ; FORF (START OF A FORF-NEXT LOOP) 00087 ; ------------------------------------------------------------------------------- 00088 ; Syntax: forf index, begf, endf 00089 ; ------------------------------------------------------------------------------- 00090 ; Arguments: index the register to be used as the loop index variable 00091 ; begf a register whose value is used to initialize the index 00092 ; endf a register whose value is used as the final index 00093 ; ------------------------------------------------------------------------------- 00094 ; The body of the loop executes until the value of the index exceeds the endl 00095 ; literal value, at which point the loop terminates with the statement following 00096 ; the next that terminates the loop. This test is performed at the top of the 00097 ; loop. This macro destroys the contents of the W register. You can terminate 00098 ; a forf loop with next, nextl, or nextf. 00099 ; ------------------------------------------------------------------------------- MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 9 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00100 forf macro index,begf,endf 00101 movf begf,W,BANKED 00102 movwf index,BANKED 00103 _for#v(_forcount) 00104 movf index,W,BANKED 00105 subwf endf,W,BANKED 00106 btfss STATUS,C,ACCESS 00107 goto _next#v(_forcount) 00108 variable _forstack#v(_forstackptr) = _forcount 00109 _forstackptr ++ 00110 _forcount ++ 00111 endm 00112 00113 ; ------------------------------------------------------------------------------- 00114 ; FORLF (START OF A FORLF-NEXT LOOP) 00115 ; ------------------------------------------------------------------------------- 00116 ; Syntax: forlf index, begl, endf 00117 ; ------------------------------------------------------------------------------- 00118 ; Arguments: index the register to be used as the loop index variable 00119 ; begl a literal value used as the initial value of the index 00120 ; endf a register whose value is used as the final index 00121 ; ------------------------------------------------------------------------------- 00122 ; The body of the loop executes until the value of the index exceeds the endl 00123 ; literal value, at which point the loop terminates with the statement following 00124 ; the next that terminates the loop. This test is performed at the top of the 00125 ; loop. This macro destroys the contents of the W register. You can terminate 00126 ; a forlf loop with next, nextl, or nextf. 00127 ; ------------------------------------------------------------------------------- 00128 forlf macro index,begl,endf 00129 movlw begl 00130 movwf index,BANKED 00131 _for#v(_forcount) 00132 movf index,W,BANKED 00133 subwf endf,W,BANKED 00134 btfss STATUS,C,ACCESS 00135 goto _next#v(_forcount) 00136 variable _forstack#v(_forstackptr) = _forcount 00137 _forstackptr ++ 00138 _forcount ++ 00139 endm 00140 00141 ; ------------------------------------------------------------------------------- 00142 ; FORFL (START OF A FORFL-NEXT LOOP) 00143 ; ------------------------------------------------------------------------------- 00144 ; Syntax: forfl index, begf, endl 00145 ; ------------------------------------------------------------------------------- 00146 ; Arguments: index the register to be used as the loop index variable 00147 ; begf a register whose value is used to initialize the index 00148 ; endl a literal value used as the final value of the index 00149 ; ------------------------------------------------------------------------------- 00150 ; The body of the loop executes until the value of the index exceeds the endl 00151 ; literal value, at which point the loop terminates with the statement following 00152 ; the next that terminates the loop. This test is performed at the top of the MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 10 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00153 ; loop. This macro destroys the contents of the W register. You can terminate 00154 ; a forfl loop with next, nextl, or nextf. 00155 ; ------------------------------------------------------------------------------- 00156 forfl macro index,begf,endl 00157 movf begf,W,BANKED 00158 movwf index,BANKED 00159 _for#v(_forcount) 00160 movf index,W,BANKED 00161 sublw endl 00162 btfss STATUS,C,ACCESS 00163 goto _next#v(_forcount) 00164 variable _forstack#v(_forstackptr) = _forcount 00165 _forstackptr ++ 00166 _forcount ++ 00167 endm 00168 00169 ; ------------------------------------------------------------------------------- 00170 ; NEXT (END OF A FOR-NEXT LOOP) 00171 ; ------------------------------------------------------------------------------- 00172 ; Syntax: next index 00173 ; ------------------------------------------------------------------------------- 00174 ; Arguments: index the register being used as the loop index variable 00175 ; ------------------------------------------------------------------------------- 00176 ; The next macro increments the index and jumps back to the test at the top of 00177 ; the for loop. This macro can be used with for, forf, forlf, and forfl. 00178 ; ------------------------------------------------------------------------------- 00179 next macro index 00180 _forstackptr -- 00181 incf index,F,BANKED 00182 goto _for#v(_forstack#v(_forstackptr)) 00183 _next#v(_forstack#v(_forstackptr)) 00184 endm 00185 00186 ; ------------------------------------------------------------------------------- 00187 ; NEXTL (END OF A FOR-NEXTL LOOP) 00188 ; ------------------------------------------------------------------------------- 00189 ; Syntax: nextl index, stepl 00190 ; ------------------------------------------------------------------------------- 00191 ; Arguments: index the register being used as the loop index variable 00192 ; stepl a literal value used as the step size 00193 ; ------------------------------------------------------------------------------- 00194 ; The next macro adds stepl to the index and jumps back to the test at the 00195 ; top of the for loop. This macro alters the contents of the W register. 00196 ; This macro can be used with for, forf, forlf, and forfl. 00197 ; ------------------------------------------------------------------------------- 00198 nextl macro index,stepl 00199 _forstackptr -- 00200 movf index,W,BANKED 00201 addlw stepl 00202 movwf index,BANKED 00203 goto _for#v(_forstack#v(_forstackptr)) 00204 _next#v(_forstack#v(_forstackptr)) 00205 endm MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 11 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00206 00207 ; ------------------------------------------------------------------------------- 00208 ; NEXTF (END OF A FOR-NEXTF LOOP) 00209 ; ------------------------------------------------------------------------------- 00210 ; Syntax: nextf index, stepf 00211 ; ------------------------------------------------------------------------------- 00212 ; Arguments: index the register being used as the loop index variable 00213 ; stepf a register whose value is used as the step size 00214 ; ------------------------------------------------------------------------------- 00215 ; The next macro adds the value contained in stepf to the index and jumps back 00216 ; to the test at the top of the for loop. This macro alters the contents of 00217 ; the W register. This macro can be used with for, forf, forlf, and forfl. 00218 ; ------------------------------------------------------------------------------- 00219 nextf macro index,stepf 00220 _forstackptr -- 00221 movf index,W,BANKED 00222 addwf stepf,W,BANKED 00223 movwf index,BANKED 00224 goto _for#v(_forstack#v(_forstackptr)) 00225 _next#v(_forstack#v(_forstackptr)) 00226 endm 00227 00228 ; ------------------------------------------------------------------------------- 00229 ; EXITFOR (TERMINATE EXECUTION OF THE INNERMOST FOR-NEXT LOOP) 00230 ; ------------------------------------------------------------------------------- 00231 ; Syntax: exitfor 00232 ; ------------------------------------------------------------------------------- 00233 ; The exitfor macro terminates the execution of the innermost for-next loop in 00234 ; a nested for-loop structure. 00235 ; ------------------------------------------------------------------------------- 00236 exitfor macro 00237 goto _next#v(_forstack#v(_forstackptr - 1)) 00238 endm 00239 00240 ; ------------------------------------------------------------------------------- 00241 ; ESCFOR (TERMINATE EXECUTION OF THE OUTERMOST FOR-NEXT LOOP) 00242 ; ------------------------------------------------------------------------------- 00243 ; Syntax: escfor 00244 ; ------------------------------------------------------------------------------- 00245 ; The escfor macro terminates the execution of the outermost for-next loop in 00246 ; a nested for-loop structure. In the context of a single for-next loop, this 00247 ; macro behaves in the same manner as does exitfor. 00248 ; ------------------------------------------------------------------------------- 00249 escfor macro 00250 goto _next#v(_forstack0) 00251 endm 00252 00253 ; ------------------------------------------------------------------------------- 00254 ; REPEAT-UNTIL LOOP MACROS 00255 ; ------------------------------------------------------------------------------- 00256 ; Macros: repeat, forever, until, untilf, untilset, untilclr, 00257 ; exitrepeat, escrepeat 00258 ; ------------------------------------------------------------------------------- MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 12 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00259 ; The repeat-until loop provides a mechanism for repeatedly executing the 00260 ; instructions comprising the body of the loop until a specified condition 00261 ; holds. The condition is tested at the bottom of the loop, so the body 00262 ; of the loop is always executed at least once. An example of the basic 00263 ; strucutre of a repeat-until loop is as follows: 00264 ; 00265 ; repeat 00266 ; . 00267 ; . 00268 ; . 00269 ; untilset reg, b, a 00270 ; 00271 ; In this example, the instructions between the repeat and untilset macros 00272 ; would be executed until bit b of register reg is set. Repeat-until loops 00273 ; may be nested to any depth. The macros exitrepeat and escrepeat respectively 00274 ; exit the innermost and outermost loop in a nested repeat-until loop structure. 00275 ; ------------------------------------------------------------------------------- 0000 00276 variable _rptcount = 0 0000 00277 variable _rptstackptr = 0 00278 00279 ; ------------------------------------------------------------------------------- 00280 ; REPEAT (START OF A REPEAT-UNTIL LOOP) 00281 ; ------------------------------------------------------------------------------- 00282 ; Syntax: repeat 00283 ; ------------------------------------------------------------------------------- 00284 ; The body of the loop executes repeatedly until the condition specified at 00285 ; the close of the loop holds. The test occurs at the bottom of the loop, so 00286 ; even if the condition holds before the execution of the loop begins, the 00287 ; body of the loop will be executed. The repeat macro can be used with any of 00288 ; the forever, untilset, untilclr, untileq, untilne, untilcs, and untilcc 00289 ; macros. It does not alter the contents of the W register. 00290 ; ------------------------------------------------------------------------------- 00291 repeat macro 00292 _repeat#v(_rptcount) 00293 variable _rptstack#v(_rptstackptr) = _rptcount 00294 _rptstackptr ++ 00295 _rptcount ++ 00296 endm 00297 00298 ; ------------------------------------------------------------------------------- 00299 ; FOREVER (END OF A REPEAT-FOREVER LOOP) 00300 ; ------------------------------------------------------------------------------- 00301 ; Syntax: forever 00302 ; ------------------------------------------------------------------------------- 00303 ; The forever macro creates an infinite loop by unconditionally jumping back 00304 ; to the top of the loop. The body of the loop is executed endlessly until 00305 ; an exitrepeat or escrepeat statement is executed. 00306 ; ------------------------------------------------------------------------------- 00307 forever macro 00308 _rptstackptr -- 00309 goto _repeat#v(_rptstack#v(_rptstackptr)) 00310 _endrepeat#v(_rptstack#v(_rptstackptr)) 00311 endm MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 13 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00312 00313 ; ------------------------------------------------------------------------------- 00314 ; UNTIL (END OF A REPEAT-UNTIL LOOP) 00315 ; ------------------------------------------------------------------------------- 00316 ; Syntax: until var, relop, lit 00317 ; ------------------------------------------------------------------------------- 00318 ; Arguments: var the register to be tested against a literal 00319 ; relop the relational operator to use for the test, which 00320 ; must be one of ==, !=, <, <=, >, >= 00321 ; lit the literal to test the contents of register var against 00322 ; ------------------------------------------------------------------------------- 00323 ; This macro performs a comparison between the contents of register var and a 00324 ; literal. If the specified relation holds, the loop terminates. This macro 00325 ; makes use of the W register. 00326 ; ------------------------------------------------------------------------------- 00327 ; This macro borrows heavily from Myke Predko's structured programming macros, 00328 ; which are described on pp. 542-546 of the second edition of Programming and 00329 ; Customizing PICmicro Microcontrollers. 00330 ; ------------------------------------------------------------------------------- 00331 until macro var,relop,lit 00332 _rptstackptr -- 00333 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 00334 movf var,W,BANKED 00335 sublw lit 00336 btfss STATUS,Z,ACCESS 00337 else 00338 if (1 relop 0) ; See if relop is !=, >, or >= 00339 if (0 relop 1) ; See if relop is != 00340 movf var,W,BANKED 00341 sublw lit 00342 btfsc STATUS,Z,ACCESS 00343 else 00344 if (1 relop 1) ; See if relop is >= 00345 movlw lit 00346 subwf var,W,BANKED 00347 btfss STATUS,C,ACCESS 00348 else ; Relop must be > 00349 movf var,W,BANKED 00350 sublw lit 00351 btfsc STATUS,C,ACCESS 00352 endif 00353 endif 00354 else 00355 if (0 relop 1) ; See if relop is < or < = 00356 if (1 relop 1) ; See if relop is <= 00357 movf var,W,BANKED 00358 sublw lit 00359 btfss STATUS,C,ACCESS 00360 else ; Relop must be < MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 14 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00361 movlw lit 00362 subwf var,W,BANKED 00363 btfsc STATUS,C,ACCESS 00364 endif 00365 else 00366 error "Illegal relational operator in until statement." 00367 endif 00368 endif 00369 endif 00370 goto _repeat#v(_rptstack#v(_rptstackptr)) 00371 _endrepeat#v(_rptstack#v(_rptstackptr)) 00372 endm 00373 00374 ; ------------------------------------------------------------------------------- 00375 ; UNTILF (END OF A REPEAT-UNTILF LOOP) 00376 ; ------------------------------------------------------------------------------- 00377 ; Syntax: untilf var1, relop, var2 00378 ; ------------------------------------------------------------------------------- 00379 ; Arguments: var1 the first register whose contents are to be tested 00380 ; against those of a second register 00381 ; relop the relational operator to use for the test, which 00382 ; must be one of ==, !=, <, <=, >, >= 00383 ; var2 a second register 00384 ; ------------------------------------------------------------------------------- 00385 ; This macro performs a comparison between the contents of register var1 and 00386 ; those of register var2. If the specified relation holds, the loop terminates. 00387 ; This macro makes use of the W register. 00388 ; ------------------------------------------------------------------------------- 00389 ; This macro borrows heavily from Myke Predko's structured programming macros, 00390 ; which are described on pp. 542-546 of the second edition of Programming and 00391 ; Customizing PICmicro Microcontrollers. 00392 ; ------------------------------------------------------------------------------- 00393 untilf macro var1,relop,var2 00394 _rptstackptr -- 00395 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 00396 movf var1,W,BANKED 00397 subwf var2,W,BANKED 00398 btfss STATUS,Z,ACCESS 00399 else 00400 if (1 relop 0) ; See if relop is !=, >, or >= 00401 if (0 relop 1) ; See if relop is != 00402 movf var1,W,BANKED 00403 subwf var2,W,BANKED 00404 btfsc STATUS,Z,ACCESS 00405 else 00406 if (1 relop 1) ; See if relop is >= 00407 movf var2,W,BANKED 00408 subwf var1,W,BANKED 00409 btfss STATUS,C,ACCESS 00410 else ; Relop must be > 00411 movf var1,W,BANKED MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 15 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00412 subwf var2,W,BANKED 00413 btfsc STATUS,C,ACCESS 00414 endif 00415 endif 00416 else 00417 if (0 relop 1) ; See if relop is < or < = 00418 if (1 relop 1) ; See if relop is <= 00419 movf var1,W,BANKED 00420 subwf var2,W,BANKED 00421 btfss STATUS,C,ACCESS 00422 else ; Relop must be < 00423 movf var2,W,BANKED 00424 subwf var1,W,BANKED 00425 btfsc STATUS,C,ACCESS 00426 endif 00427 else 00428 error "Illegal relational operator in untilf statement." 00429 endif 00430 endif 00431 endif 00432 goto _repeat#v(_rptstack#v(_rptstackptr)) 00433 _endrepeat#v(_rptstack#v(_rptstackptr)) 00434 endm 00435 00436 ; ------------------------------------------------------------------------------- 00437 ; UNTILSET (END OF A REPEAT-UNTILSET LOOP) 00438 ; ------------------------------------------------------------------------------- 00439 ; Syntax: untilset reg, bit, a 00440 ; ------------------------------------------------------------------------------- 00441 ; Arguments: reg the register containing the bit to be tested 00442 ; bit a literal value between 0 and 7 specifying the bit 00443 ; position to be tested 00444 ; a if a is 0, the access bank is selected. if a is 1, 00445 ; the BSR specifies the bank used to select reg. 00446 ; ------------------------------------------------------------------------------- 00447 ; The untilset macro tests the specified bit of register reg and terminates 00448 ; loop execution if it is set. 00449 ; ------------------------------------------------------------------------------- 00450 untilset macro reg,bit,a 00451 _rptstackptr -- 00452 btfss reg,bit,a 00453 goto _repeat#v(_rptstack#v(_rptstackptr)) 00454 _endrepeat#v(_rptstack#v(_rptstackptr)) 00455 endm 00456 00457 ; ------------------------------------------------------------------------------- 00458 ; UNTILCLR (END OF A REPEAT-UNTILCLR LOOP) 00459 ; ------------------------------------------------------------------------------- 00460 ; Syntax: untilclr reg, bit, a 00461 ; ------------------------------------------------------------------------------- 00462 ; Arguments: reg the register containing the bit to be tested MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 16 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00463 ; bit a literal value between 0 and 7 specifying the bit 00464 ; position to be tested 00465 ; a if a is 0, the access bank is selected. if a is 1, 00466 ; the BSR specifies the bank used to select reg. 00467 ; ------------------------------------------------------------------------------- 00468 ; The untilclr macro tests the specified bit of register reg and terminates 00469 ; loop execution if it is clear. 00470 ; ------------------------------------------------------------------------------- 00471 untilclr macro reg,bit,a 00472 _rptstackptr -- 00473 btfsc reg,bit,a 00474 goto _repeat#v(_rptstack#v(_rptstackptr)) 00475 _endrepeat#v(_rptstack#v(_rptstackptr)) 00476 endm 00477 00478 ; ------------------------------------------------------------------------------- 00479 ; EXITREPEAT (TERMINATE EXECUTION OF THE INNERMOST REPEAT-UNTIL LOOP) 00480 ; ------------------------------------------------------------------------------- 00481 ; Syntax: exitrepeat 00482 ; ------------------------------------------------------------------------------- 00483 ; The exitrepeat macro terminates the execution of the innermost loop in a 00484 ; nested repeat-until loop structure. 00485 ; ------------------------------------------------------------------------------- 00486 exitrepeat macro 00487 goto _endrepeat#v(_rptstack#v(_rptstackptr - 1)) 00488 endm 00489 00490 ; ------------------------------------------------------------------------------- 00491 ; ESCREPEAT (TERMINATE EXECUTION OF THE OUTERMOST REPEAT-UNTIL LOOP) 00492 ; ------------------------------------------------------------------------------- 00493 ; Syntax: escrepeat 00494 ; ------------------------------------------------------------------------------- 00495 ; The escrepeat macro terminates the execution of the outermost loop in a 00496 ; nested repeat-until loop structure. In the context of a single repeat-until 00497 ; loop, this macro behaves in the same manner as does exitrepeat. 00498 ; ------------------------------------------------------------------------------- 00499 escrepeat macro 00500 goto _endrepeat#v(_rptstack0) 00501 endm 00502 00503 ; ------------------------------------------------------------------------------- 00504 ; SELECT STATEMENT MACROS 00505 ; ------------------------------------------------------------------------------- 00506 ; Macros: select, selectf, case, casef, caseset, caseclr, default, break, ends 00507 ; ------------------------------------------------------------------------------- 00508 ; This group of macros allows a program to selectively execute sequences of 00509 ; instructions based on the value of a variable and/or based on the bit values 00510 ; in certain registers. An example of a select statement is as follows: 00511 ; 00512 ; select 00513 ; case 1 00514 ; . 00515 ; . MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 17 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00516 ; . 00517 ; break 00518 ; case 4 00519 ; casef foo 00520 ; . 00521 ; . 00522 ; . 00523 ; break 00524 ; caseset reg, 0, a 00525 ; . 00526 ; . 00527 ; . 00528 ; break 00529 ; default 00530 ; . 00531 ; . 00532 ; . 00533 ; ends 00534 ; 00535 ; In this case, the first group of instructions is executed if the value 00536 ; of the W register is 1. The second group of instructions is executed if 00537 ; the value of the W register is 4 or if it matches the value of register 00538 ; foo. The third group of instructions is executed if bit 0 of register 00539 ; reg is set. The fourth group of instructions is executed in the event 00540 ; that none of the specified cases held. The default block is optional. 00541 ; The break macro terminates the execution of the select statement; if no 00542 ; break macro exists at the end of a block of instructions, execution 00543 ; continues in the next block. The contents of the W register are preserved 00544 ; by the case macros. Select statements may be nested to any depth. 00545 ; ------------------------------------------------------------------------------- 0000 00546 variable _selcount = 0 0000 00547 variable _selstackptr = 0 0000 00548 variable _casecount = 0 00549 00550 ; ------------------------------------------------------------------------------- 00551 ; SELECT (START OF A SELECT STATEMENT) 00552 ; ------------------------------------------------------------------------------- 00553 ; Syntax: select 00554 ; ------------------------------------------------------------------------------- 00555 ; This macro begins a select statement. The W register is used as 00556 ; the selection variable. 00557 ; ------------------------------------------------------------------------------- 00558 select macro 00559 variable _casestack#v(_selstackptr) = _casecount 00560 variable _selstack#v(_selstackptr) = _selcount 00561 _selstackptr ++ 00562 _casecount = 0 00563 _select#v(_selstack#v(_selstackptr - 1)) 00564 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00565 _selcount ++ 00566 endm 00567 00568 ; ------------------------------------------------------------------------------- MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 18 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00569 ; SELECTF (START OF A SELECT STATEMENT) 00570 ; ------------------------------------------------------------------------------- 00571 ; Syntax: selectf var 00572 ; ------------------------------------------------------------------------------- 00573 ; Arguments: var the register whose value will be tested in each case 00574 ; ------------------------------------------------------------------------------- 00575 ; This macro begins a selectf statement. It begins by moving the contents of 00576 ; var into the W register. 00577 ; ------------------------------------------------------------------------------- 00578 selectf macro var 00579 variable _casestack#v(_selstackptr) = _casecount 00580 variable _selstack#v(_selstackptr) = _selcount 00581 _selstackptr ++ 00582 _casecount = 0 00583 _select#v(_selstack#v(_selstackptr - 1)) 00584 movf var,W,BANKED 00585 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00586 _selcount ++ 00587 endm 00588 00589 ; ------------------------------------------------------------------------------- 00590 ; CASE (START OF A CASE IN A SELECT STATEMENT) 00591 ; ------------------------------------------------------------------------------- 00592 ; Syntax: case val 00593 ; ------------------------------------------------------------------------------- 00594 ; Arguments: val a literal value to be compared with the contents of 00595 ; the W register 00596 ; ------------------------------------------------------------------------------- 00597 ; This macro compares the value containted in the W register with val; if they 00598 ; match, the instructions following the case macro are executed. Otherwise, 00599 ; the next case is tested. This macro preserves the value of the W register. 00600 ; ------------------------------------------------------------------------------- 00601 case macro val 00602 goto _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00603 _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00604 xorlw val 00605 btfsc STATUS,Z,ACCESS 00606 goto _casematch#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00607 xorlw val 00608 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount + 1) 00609 _casematch#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00610 xorlw val 00611 _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00612 _casecount ++ 00613 endm 00614 00615 ; ------------------------------------------------------------------------------- 00616 ; CASEF (START OF A CASE IN A SELECT STATEMENT) 00617 ; ------------------------------------------------------------------------------- 00618 ; Syntax: casef var 00619 ; ------------------------------------------------------------------------------- 00620 ; Arguments: var a register whose value is to be compared with that of 00621 ; the W register MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 19 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00622 ; ------------------------------------------------------------------------------- 00623 ; This macro compares the value containted in the W register with that in 00624 ; register var; if they match, the instructions following the case macro are 00625 ; executed. Otherwise, the next case is tested. This macro preserves the 00626 ; value of the W register. 00627 ; ------------------------------------------------------------------------------- 00628 casef macro var 00629 goto _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00630 _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00631 xorwf var,W,BANKED 00632 btfsc STATUS,Z,ACCESS 00633 goto _casematch#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00634 xorwf var,W,BANKED 00635 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount + 1) 00636 _casematch#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00637 xorwf var,W,BANKED 00638 _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00639 _casecount ++ 00640 endm 00641 00642 ; ------------------------------------------------------------------------------- 00643 ; CASESET (START OF A CASE IN A SELECT STATEMENT) 00644 ; ------------------------------------------------------------------------------- 00645 ; Syntax: caseset reg, bit, a 00646 ; ------------------------------------------------------------------------------- 00647 ; Arguments: reg the register containing the bit to be tested 00648 ; bit a literal value between 0 and 7 specifying the bit 00649 ; position to be tested 00650 ; a if a is 0, the access bank is selected. if a is 1, 00651 ; the BSR specifies the bank used to select reg. 00652 ; ------------------------------------------------------------------------------- 00653 ; This macro tests the specified bit in register reg; if it is set, the 00654 ; instructions following the case macro are executed. Otherwise, the next 00655 ; case is tested. This macro does not change the value of the W register. 00656 ; ------------------------------------------------------------------------------- 00657 caseset macro reg,bit,a 00658 goto _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00659 _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00660 btfss reg,bit,a 00661 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount + 1) 00662 _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00663 _casecount ++ 00664 endm 00665 00666 ; ------------------------------------------------------------------------------- 00667 ; CASECLR (START OF A CASE IN A SELECT STATEMENT) 00668 ; ------------------------------------------------------------------------------- 00669 ; Syntax: caseclr reg, bit, a 00670 ; ------------------------------------------------------------------------------- 00671 ; Arguments: reg the register containing the bit to be tested 00672 ; bit a literal value between 0 and 7 specifying the bit 00673 ; position to be tested 00674 ; a if a is 0, the access bank is selected. if a is 1, MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 20 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00675 ; the BSR specifies the bank used to select reg. 00676 ; ------------------------------------------------------------------------------- 00677 ; This macro tests the specified bit in register reg; if it is clear, the 00678 ; instructions following the case macro are executed. Otherwise, the next 00679 ; case is tested. This macro does not change the value of the W register. 00680 ; ------------------------------------------------------------------------------- 00681 caseclr macro reg,bit,a 00682 goto _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00683 _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00684 btfsc reg,bit,a 00685 goto _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount + 1) 00686 _casebypass#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00687 _casecount ++ 00688 endm 00689 00690 ; ------------------------------------------------------------------------------- 00691 ; DEFAULT (START OF A DEFAULT CASE IN A SELECT STATEMENT) 00692 ; ------------------------------------------------------------------------------- 00693 ; Syntax: default 00694 ; ------------------------------------------------------------------------------- 00695 ; This macro begins the sequence of instructions that is executed if none 00696 ; of the other cases held. The default block is optional. 00697 ; ------------------------------------------------------------------------------- 00698 default macro 00699 _case#v(_selstack#v(_selstackptr - 1))_#v(_casecount) 00700 _casecount ++ 00701 endm 00702 00703 ; ------------------------------------------------------------------------------- 00704 ; BREAK (TERMINATES EXECUTION OF A SELECT STATEMENT) 00705 ; ------------------------------------------------------------------------------- 00706 ; Syntax: break 00707 ; ------------------------------------------------------------------------------- 00708 ; This macro terminates the execution of a select statement. 00709 ; ------------------------------------------------------------------------------- 00710 break macro 00711 goto _endselect#v(_selstack#v(_selstackptr - 1)) 00712 endm 00713 00714 ; ------------------------------------------------------------------------------- 00715 ; ENDS (END OF A SELECT STATEMENT) 00716 ; ------------------------------------------------------------------------------- 00717 ; Syntax: ends 00718 ; ------------------------------------------------------------------------------- 00719 ; This macro marks the end of a select statement. 00720 ; ------------------------------------------------------------------------------- 00721 ends macro 00722 _selstackptr -- 00723 _case#v(_selstack#v(_selstackptr))_#v(_casecount) 00724 _endselect#v(_selstack#v(_selstackptr)) 00725 _casecount = _casestack#v(_selstackptr) 00726 endm 00727 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 21 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00728 ; ------------------------------------------------------------------------------- 00729 ; IF STATEMENT MACROS 00730 ; ------------------------------------------------------------------------------- 00731 ; Macros: ifl, iff, ifset, ifclr, 00732 ; andif, andiff, andifset, andifclr, 00733 ; orif, oriff, orifset, orifclr, 00734 ; elsif, elsiff, elsifset, elsifclr, 00735 ; otherwise, endi 00736 ; ------------------------------------------------------------------------------- 00737 ; This set of macros allows the selective exectution of groups of instructions 00738 ; based on the values of one or more bits. An example of an if statement is 00739 ; as follows: 00740 ; 00741 ; ifset foo, 0, a 00742 ; . 00743 ; . 00744 ; . 00745 ; elsifclr bar, 5, a 00746 ; andifset foo, 1, a 00747 ; . 00748 ; . 00749 ; . 00750 ; elsifset foo, 2, a 00751 ; orifset foo, 3, a 00752 ; . 00753 ; . 00754 ; . 00755 ; otherwise 00756 ; . 00757 ; . 00758 ; . 00759 ; endi 00760 ; 00761 ; In this example, the first group of instructions is executed if bit 0 of 00762 ; register foo is set. The second group of instructions is executed if bit 00763 ; 5 of register bar is clear and bit 1 of register foo is set. The third 00764 ; group is executed if either of bit 2 or bit 3 of register foo is set. 00765 ; Otherwise, the fourth group of instructions is executed. The elsif and 00766 ; otherwise blocks are optional. If statements can be nested to any depth. 00767 ; ------------------------------------------------------------------------------- 0000 00768 variable _ifcount = 0 0000 00769 variable _ifstackptr = 0 0000 00770 variable _ifclausecount = 0 00771 00772 ; ------------------------------------------------------------------------------- 00773 ; IFL (START OF AN IF CLAUSE IN AN IF STATEMENT) 00774 ; ------------------------------------------------------------------------------- 00775 ; Syntax: ifl var, relop, lit 00776 ; ------------------------------------------------------------------------------- 00777 ; Arguments: var the register to be tested against a literal 00778 ; relop the relational operator to use for the test, which 00779 ; must be one of ==, !=, <, <=, >, >= 00780 ; lit the literal to test the contents of register var against MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 22 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00781 ; ------------------------------------------------------------------------------- 00782 ; This macro performs a comparison between the contents of register var and a 00783 ; literal. If the specified relation holds, the block of statements following 00784 ; the ifl are executed. This macro makes use of the W register. 00785 ; ------------------------------------------------------------------------------- 00786 ; This macro borrows heavily from Myke Predko's structured programming macros, 00787 ; which are described on pp. 542-546 of the second edition of Programming and 00788 ; Customizing PICmicro Microcontrollers. 00789 ; ------------------------------------------------------------------------------- 00790 ifl macro var,relop,lit 00791 variable _ifclausestack#v(_ifstackptr) = _ifclausecount 00792 variable _ifstack#v(_ifstackptr) = _ifcount 00793 _ifstackptr ++ 00794 _ifclausecount = 0 00795 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 00796 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 00797 movf var,W,BANKED 00798 sublw lit 00799 btfss STATUS,Z,ACCESS 00800 else 00801 if (1 relop 0) ; See if relop is !=, >, or >= 00802 if (0 relop 1) ; See if relop is != 00803 movf var,W,BANKED 00804 sublw lit 00805 btfsc STATUS,Z,ACCESS 00806 else 00807 if (1 relop 1) ; See if relop is >= 00808 movlw lit 00809 subwf var,W,BANKED 00810 btfss STATUS,C,ACCESS 00811 else ; Relop must be > 00812 movf var,W,BANKED 00813 sublw lit 00814 btfsc STATUS,C,ACCESS 00815 endif 00816 endif 00817 else 00818 if (0 relop 1) ; See if relop is < or < = 00819 if (1 relop 1) ; See if relop is <= 00820 movf var,W,BANKED 00821 sublw lit 00822 btfss STATUS,C,ACCESS 00823 else ; Relop must be < 00824 movlw lit 00825 subwf var,W,BANKED 00826 btfsc STATUS,C,ACCESS 00827 endif 00828 else 00829 error "Illegal relational operator in ifl statement." MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 23 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00830 endif 00831 endif 00832 endif 00833 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 00834 _ifcount ++ 00835 _ifclausecount ++ 00836 endm 00837 00838 ; ------------------------------------------------------------------------------- 00839 ; IFF (START OF AN IF CLAUSE IN AN IF STATEMENT) 00840 ; ------------------------------------------------------------------------------- 00841 ; Syntax: iff var1, relop, var2 00842 ; ------------------------------------------------------------------------------- 00843 ; Arguments: var1 the first register whose contents are to be tested 00844 ; against those of a second register 00845 ; relop the relational operator to use for the test, which 00846 ; must be one of ==, !=, <, <=, >, >= 00847 ; var2 a second register 00848 ; ------------------------------------------------------------------------------- 00849 ; This macro performs a comparison between the contents of register var1 and 00850 ; those of register var2. If the specified relation holds, the block of 00851 ; statements following the iff are executed. This macro makes use of the W 00852 ; register. 00853 ; ------------------------------------------------------------------------------- 00854 ; This macro borrows heavily from Myke Predko's structured programming macros, 00855 ; which are described on pp. 542-546 of the second edition of Programming and 00856 ; Customizing PICmicro Microcontrollers. 00857 ; ------------------------------------------------------------------------------- 00858 iff macro var1,relop,var2 00859 variable _ifclausestack#v(_ifstackptr) = _ifclausecount 00860 variable _ifstack#v(_ifstackptr) = _ifcount 00861 _ifstackptr ++ 00862 _ifclausecount = 0 00863 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 00864 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 00865 movf var1,W,BANKED 00866 subwf var2,W,BANKED 00867 btfss STATUS,Z,ACCESS 00868 else 00869 if (1 relop 0) ; See if relop is !=, >, or >= 00870 if (0 relop 1) ; See if relop is != 00871 movf var1,W,BANKED 00872 subwf var2,W,BANKED 00873 btfsc STATUS,Z,ACCESS 00874 else 00875 if (1 relop 1) ; See if relop is >= 00876 movf var2,W,BANKED 00877 subwf var1,W,BANKED 00878 btfss STATUS,C,ACCESS 00879 else ; Relop must be > 00880 movf var1,W,BANKED MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 24 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00881 subwf var2,W,BANKED 00882 btfsc STATUS,C,ACCESS 00883 endif 00884 endif 00885 else 00886 if (0 relop 1) ; See if relop is < or < = 00887 if (1 relop 1) ; See if relop is <= 00888 movf var1,W,BANKED 00889 subwf var2,W,BANKED 00890 btfss STATUS,C,ACCESS 00891 else ; Relop must be < 00892 movf var2,W,BANKED 00893 subwf var1,W,BANKED 00894 btfsc STATUS,C,ACCESS 00895 endif 00896 else 00897 error "Illegal relational operator in iff statement." 00898 endif 00899 endif 00900 endif 00901 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 00902 _ifcount ++ 00903 _ifclausecount ++ 00904 endm 00905 00906 ; ------------------------------------------------------------------------------- 00907 ; IFSET (START OF AN IF CLAUSE IN AN IF STATEMENT) 00908 ; ------------------------------------------------------------------------------- 00909 ; Syntax: ifset reg, bit, a 00910 ; ------------------------------------------------------------------------------- 00911 ; Arguments: reg the register containing the bit to be tested 00912 ; bit a literal value between 0 and 7 specifying the bit 00913 ; position to be tested 00914 ; a if a is 0, the access bank is selected. if a is 1, 00915 ; the BSR specifies the bank used to select reg. 00916 ; ------------------------------------------------------------------------------- 00917 ; This macro tests the specified bit in register reg; if it is set, the 00918 ; instructions following the ifset macro are executed. Otherwise, the next 00919 ; case is tested. 00920 ; ------------------------------------------------------------------------------- 00921 ifset macro reg,bit,a 00922 variable _ifclausestack#v(_ifstackptr) = _ifclausecount 00923 variable _ifstack#v(_ifstackptr) = _ifcount 00924 _ifstackptr ++ 00925 _ifclausecount = 0 00926 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 00927 btfss reg,bit,a 00928 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 00929 _ifcount ++ 00930 _ifclausecount ++ 00931 endm MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 25 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00932 00933 ; ------------------------------------------------------------------------------- 00934 ; IFCLR (START OF AN IF CLAUSE IN AN IF STATEMENT) 00935 ; ------------------------------------------------------------------------------- 00936 ; Syntax: ifclr reg, bit, a 00937 ; ------------------------------------------------------------------------------- 00938 ; Arguments: reg the register containing the bit to be tested 00939 ; bit a literal value between 0 and 7 specifying the bit 00940 ; position to be tested 00941 ; a if a is 0, the access bank is selected. if a is 1, 00942 ; the BSR specifies the bank used to select reg. 00943 ; ------------------------------------------------------------------------------- 00944 ; This macro tests the specified bit in register reg; if it is clear, the 00945 ; instructions following the ifclr macro are executed. Otherwise, the next 00946 ; case is tested. 00947 ; ------------------------------------------------------------------------------- 00948 ifclr macro reg,bit,a 00949 variable _ifclausestack#v(_ifstackptr) = _ifclausecount 00950 variable _ifstack#v(_ifstackptr) = _ifcount 00951 _ifstackptr ++ 00952 _ifclausecount = 0 00953 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 00954 btfsc reg,bit,a 00955 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 00956 _ifcount ++ 00957 _ifclausecount ++ 00958 endm 00959 00960 ; ------------------------------------------------------------------------------- 00961 ; ANDIF (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 00962 ; ------------------------------------------------------------------------------- 00963 ; Syntax: andif var, relop, lit 00964 ; ------------------------------------------------------------------------------- 00965 ; Arguments: var the register to be tested against a literal 00966 ; relop the relational operator to use for the test, which 00967 ; must be one of ==, !=, <, <=, >, >= 00968 ; lit the literal to test the contents of register var against 00969 ; ------------------------------------------------------------------------------- 00970 ; This macro performs a comparison between the contents of register var and a 00971 ; literal. If the specified relation holds, the block of statements following 00972 ; the ifl are executed. This macro makes use of the W register. 00973 ; ------------------------------------------------------------------------------- 00974 ; This macro borrows heavily from Myke Predko's structured programming macros, 00975 ; which are described on pp. 542-546 of the second edition of Programming and 00976 ; Customizing PICmicro Microcontrollers. 00977 ; ------------------------------------------------------------------------------- 00978 andif macro var,relop,lit 00979 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 00980 movf var,W,BANKED 00981 sublw lit 00982 btfss STATUS,Z,ACCESS 00983 else 00984 if (1 relop 0) ; See if relop is !=, >, MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 26 LOC OBJECT CODE LINE SOURCE TEXT VALUE or >= 00985 if (0 relop 1) ; See if relop is != 00986 movf var,W,BANKED 00987 sublw lit 00988 btfsc STATUS,Z,ACCESS 00989 else 00990 if (1 relop 1) ; See if relop is >= 00991 movlw lit 00992 subwf var,W,BANKED 00993 btfss STATUS,C,ACCESS 00994 else ; Relop must be > 00995 movf var,W,BANKED 00996 sublw lit 00997 btfsc STATUS,C,ACCESS 00998 endif 00999 endif 01000 else 01001 if (0 relop 1) ; See if relop is < or < = 01002 if (1 relop 1) ; See if relop is <= 01003 movf var,W,BANKED 01004 sublw lit 01005 btfss STATUS,C,ACCESS 01006 else ; Relop must be < 01007 movlw lit 01008 subwf var,W,BANKED 01009 btfsc STATUS,C,ACCESS 01010 endif 01011 else 01012 error "Illegal relational operator in andif statement." 01013 endif 01014 endif 01015 endif 01016 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01017 endm 01018 01019 ; ------------------------------------------------------------------------------- 01020 ; ANDIFF (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01021 ; ------------------------------------------------------------------------------- 01022 ; Syntax: andiff var1, relop, var2 01023 ; ------------------------------------------------------------------------------- 01024 ; Arguments: var1 the first register whose contents are to be tested 01025 ; against those of a second register 01026 ; relop the relational operator to use for the test, which 01027 ; must be one of ==, !=, <, <=, >, >= 01028 ; var2 a second register 01029 ; ------------------------------------------------------------------------------- 01030 ; This macro performs a comparison between the contents of register var1 and 01031 ; those of register var2. If the specified relation holds, the block of 01032 ; statements following the iff are executed. This macro makes use of the W 01033 ; register. MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 27 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01034 ; ------------------------------------------------------------------------------- 01035 ; This macro borrows heavily from Myke Predko's structured programming macros, 01036 ; which are described on pp. 542-546 of the second edition of Programming and 01037 ; Customizing PICmicro Microcontrollers. 01038 ; ------------------------------------------------------------------------------- 01039 andiff macro var1,relop,var2 01040 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 01041 movf var1,W,BANKED 01042 subwf var2,W,BANKED 01043 btfss STATUS,Z,ACCESS 01044 else 01045 if (1 relop 0) ; See if relop is !=, >, or >= 01046 if (0 relop 1) ; See if relop is != 01047 movf var1,W,BANKED 01048 subwf var2,W,BANKED 01049 btfsc STATUS,Z,ACCESS 01050 else 01051 if (1 relop 1) ; See if relop is >= 01052 movf var2,W,BANKED 01053 subwf var1,W,BANKED 01054 btfss STATUS,C,ACCESS 01055 else ; Relop must be > 01056 movf var1,W,BANKED 01057 subwf var2,W,BANKED 01058 btfsc STATUS,C,ACCESS 01059 endif 01060 endif 01061 else 01062 if (0 relop 1) ; See if relop is < or < = 01063 if (1 relop 1) ; See if relop is <= 01064 movf var1,W,BANKED 01065 subwf var2,W,BANKED 01066 btfss STATUS,C,ACCESS 01067 else ; Relop must be < 01068 movf var2,W,BANKED 01069 subwf var1,W,BANKED 01070 btfsc STATUS,C,ACCESS 01071 endif 01072 else 01073 error "Illegal relational operator in andiff statement." 01074 endif 01075 endif 01076 endif 01077 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01078 endm 01079 01080 ; ------------------------------------------------------------------------------- 01081 ; ANDIFSET (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01082 ; ------------------------------------------------------------------------------- MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 28 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01083 ; Syntax: andifset reg, bit, a 01084 ; ------------------------------------------------------------------------------- 01085 ; Arguments: reg the register containing the bit to be tested 01086 ; bit a literal value between 0 and 7 specifying the bit 01087 ; position to be tested 01088 ; a if a is 0, the access bank is selected. if a is 1, 01089 ; the BSR specifies the bank used to select reg. 01090 ; ------------------------------------------------------------------------------- 01091 andifset macro reg,bit,a 01092 btfss reg,bit,a 01093 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01094 endm 01095 01096 ; ------------------------------------------------------------------------------- 01097 ; ANDIFCLR (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01098 ; ------------------------------------------------------------------------------- 01099 ; Syntax: andifclr reg, bit, a 01100 ; ------------------------------------------------------------------------------- 01101 ; Arguments: reg the register containing the bit to be tested 01102 ; bit a literal value between 0 and 7 specifying the bit 01103 ; position to be tested 01104 ; a if a is 0, the access bank is selected. if a is 1, 01105 ; the BSR specifies the bank used to select reg. 01106 ; ------------------------------------------------------------------------------- 01107 andifclr macro reg,bit,a 01108 btfsc reg,bit,a 01109 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01110 endm 01111 01112 ; ------------------------------------------------------------------------------- 01113 ; ORIF (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01114 ; ------------------------------------------------------------------------------- 01115 ; Syntax: orif var, relop, lit 01116 ; ------------------------------------------------------------------------------- 01117 ; Arguments: var the register to be tested against a literal 01118 ; relop the relational operator to use for the test, which 01119 ; must be one of ==, !=, <, <=, >, >= 01120 ; lit the literal to test the contents of register var against 01121 ; ------------------------------------------------------------------------------- 01122 ; This macro performs a comparison between the contents of register var and a 01123 ; literal. If the specified relation holds, the block of statements following 01124 ; the ifl are executed. This macro makes use of the W register. 01125 ; ------------------------------------------------------------------------------- 01126 ; This macro borrows heavily from Myke Predko's structured programming macros, 01127 ; which are described on pp. 542-546 of the second edition of Programming and 01128 ; Customizing PICmicro Microcontrollers. 01129 ; ------------------------------------------------------------------------------- 01130 orif macro var,relop,lit 01131 goto _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01132 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01133 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 01134 movf var,W,BANKED 01135 sublw lit MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 29 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01136 btfss STATUS,Z,ACCESS 01137 else 01138 if (1 relop 0) ; See if relop is !=, >, or >= 01139 if (0 relop 1) ; See if relop is != 01140 movf var,W,BANKED 01141 sublw lit 01142 btfsc STATUS,Z,ACCESS 01143 else 01144 if (1 relop 1) ; See if relop is >= 01145 movlw lit 01146 subwf var,W,BANKED 01147 btfss STATUS,C,ACCESS 01148 else ; Relop must be > 01149 movf var,W,BANKED 01150 sublw lit 01151 btfsc STATUS,C,ACCESS 01152 endif 01153 endif 01154 else 01155 if (0 relop 1) ; See if relop is < or < = 01156 if (1 relop 1) ; See if relop is <= 01157 movf var,W,BANKED 01158 sublw lit 01159 btfss STATUS,C,ACCESS 01160 else ; Relop must be < 01161 movlw lit 01162 subwf var,W,BANKED 01163 btfsc STATUS,C,ACCESS 01164 endif 01165 else 01166 error "Illegal relational operator in orif statement." 01167 endif 01168 endif 01169 endif 01170 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01171 _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01172 _ifclausecount ++ 01173 endm 01174 01175 ; ------------------------------------------------------------------------------- 01176 ; ORIFF (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01177 ; ------------------------------------------------------------------------------- 01178 ; Syntax: oriff var1, relop, var2 01179 ; ------------------------------------------------------------------------------- 01180 ; Arguments: var1 the first register whose contents are to be tested 01181 ; against those of a second register 01182 ; relop the relational operator to use for the test, which 01183 ; must be one of ==, !=, <, <=, >, >= 01184 ; var2 a second register MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 30 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01185 ; ------------------------------------------------------------------------------- 01186 ; This macro performs a comparison between the contents of register var1 and 01187 ; those of register var2. If the specified relation holds, the block of 01188 ; statements following the iff are executed. This macro makes use of the W 01189 ; register. 01190 ; ------------------------------------------------------------------------------- 01191 ; This macro borrows heavily from Myke Predko's structured programming macros, 01192 ; which are described on pp. 542-546 of the second edition of Programming and 01193 ; Customizing PICmicro Microcontrollers. 01194 ; ------------------------------------------------------------------------------- 01195 oriff macro var1,relop,var2 01196 goto _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01197 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01198 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 01199 movf var1,W,BANKED 01200 subwf var2,W,BANKED 01201 btfss STATUS,Z,ACCESS 01202 else 01203 if (1 relop 0) ; See if relop is !=, >, or >= 01204 if (0 relop 1) ; See if relop is != 01205 movf var1,W,BANKED 01206 subwf var2,W,BANKED 01207 btfsc STATUS,Z,ACCESS 01208 else 01209 if (1 relop 1) ; See if relop is >= 01210 movf var2,W,BANKED 01211 subwf var1,W,BANKED 01212 btfss STATUS,C,ACCESS 01213 else ; Relop must be > 01214 movf var1,W,BANKED 01215 subwf var2,W,BANKED 01216 btfsc STATUS,C,ACCESS 01217 endif 01218 endif 01219 else 01220 if (0 relop 1) ; See if relop is < or < = 01221 if (1 relop 1) ; See if relop is <= 01222 movf var1,W,BANKED 01223 subwf var2,W,BANKED 01224 btfss STATUS,C,ACCESS 01225 else ; Relop must be < 01226 movf var2,W,BANKED 01227 subwf var1,W,BANKED 01228 btfsc STATUS,C,ACCESS 01229 endif 01230 else 01231 error "Illegal relational operator in oriff statement." 01232 endif 01233 endif MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 31 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01234 endif 01235 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01236 _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01237 _ifclausecount ++ 01238 endm 01239 01240 ; ------------------------------------------------------------------------------- 01241 ; ORIFSET (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01242 ; ------------------------------------------------------------------------------- 01243 ; Syntax: orifset reg, bit, a 01244 ; ------------------------------------------------------------------------------- 01245 ; Arguments: reg the register containing the bit to be tested 01246 ; bit a literal value between 0 and 7 specifying the bit 01247 ; position to be tested 01248 ; ------------------------------------------------------------------------------- 01249 orifset macro reg,bit,a 01250 goto _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01251 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01252 btfss reg,bit,a 01253 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01254 _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01255 _ifclausecount ++ 01256 endm 01257 01258 ; ------------------------------------------------------------------------------- 01259 ; ORIFCLR (CONTINUATION OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01260 ; ------------------------------------------------------------------------------- 01261 ; Syntax: orifclr reg, bit, a 01262 ; ------------------------------------------------------------------------------- 01263 ; Arguments: reg the register containing the bit to be tested 01264 ; bit a literal value between 0 and 7 specifying the bit 01265 ; position to be tested 01266 ; a if a is 0, the access bank is selected. if a is 1, 01267 ; the BSR specifies the bank used to select reg. 01268 ; ------------------------------------------------------------------------------- 01269 orifclr macro reg,bit,a 01270 goto _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01271 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01272 btfsc reg,bit,a 01273 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01274 _ifbypass#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01275 _ifclausecount ++ 01276 endm 01277 01278 ; ------------------------------------------------------------------------------- 01279 ; ELSIF (START OF AN ELSIF CLAUSE IN AN IF STATEMENT) 01280 ; ------------------------------------------------------------------------------- 01281 ; Syntax: elsif var, relop, lit 01282 ; ------------------------------------------------------------------------------- 01283 ; Arguments: var the register to be tested against a literal 01284 ; relop the relational operator to use for the test, which 01285 ; must be one of ==, !=, <, <=, >, >= 01286 ; lit the literal to test the contents of register var against MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 32 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01287 ; ------------------------------------------------------------------------------- 01288 ; This macro performs a comparison between the contents of register var and a 01289 ; literal. If the specified relation holds, the block of statements following 01290 ; the ifl are executed. This macro makes use of the W register. 01291 ; ------------------------------------------------------------------------------- 01292 ; This macro borrows heavily from Myke Predko's structured programming macros, 01293 ; which are described on pp. 542-546 of the second edition of Programming and 01294 ; Customizing PICmicro Microcontrollers. 01295 ; ------------------------------------------------------------------------------- 01296 elsif macro var,relop,lit 01297 goto _endif#v(_ifstack#v(_ifstackptr - 1)) 01298 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01299 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 01300 movf var,W,BANKED 01301 sublw lit 01302 btfss STATUS,Z,ACCESS 01303 else 01304 if (1 relop 0) ; See if relop is !=, >, or >= 01305 if (0 relop 1) ; See if relop is != 01306 movf var,W,BANKED 01307 sublw lit 01308 btfsc STATUS,Z,ACCESS 01309 else 01310 if (1 relop 1) ; See if relop is >= 01311 movlw lit 01312 subwf var,W,BANKED 01313 btfss STATUS,C,ACCESS 01314 else ; Relop must be > 01315 movf var,W,BANKED 01316 sublw lit 01317 btfsc STATUS,C,ACCESS 01318 endif 01319 endif 01320 else 01321 if (0 relop 1) ; See if relop is < or < = 01322 if (1 relop 1) ; See if relop is <= 01323 movf var,W,BANKED 01324 sublw lit 01325 btfss STATUS,C,ACCESS 01326 else ; Relop must be < 01327 movlw lit 01328 subwf var,W,BANKED 01329 btfsc STATUS,C,ACCESS 01330 endif 01331 else 01332 error "Illegal relational operator in elsif statement." 01333 endif 01334 endif 01335 endif MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 33 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01336 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01337 _ifclausecount ++ 01338 endm 01339 01340 ; ------------------------------------------------------------------------------- 01341 ; ELSIFF (START OF AN IF/ELSIF CLAUSE IN AN IF STATEMENT) 01342 ; ------------------------------------------------------------------------------- 01343 ; Syntax: elsiff var1, relop, var2 01344 ; ------------------------------------------------------------------------------- 01345 ; Arguments: var1 the first register whose contents are to be tested 01346 ; against those of a second register 01347 ; relop the relational operator to use for the test, which 01348 ; must be one of ==, !=, <, <=, >, >= 01349 ; var2 a second register 01350 ; ------------------------------------------------------------------------------- 01351 ; This macro performs a comparison between the contents of register var1 and 01352 ; those of register var2. If the specified relation holds, the block of 01353 ; statements following the iff are executed. This macro makes use of the W 01354 ; register. 01355 ; ------------------------------------------------------------------------------- 01356 ; This macro borrows heavily from Myke Predko's structured programming macros, 01357 ; which are described on pp. 542-546 of the second edition of Programming and 01358 ; Customizing PICmicro Microcontrollers. 01359 ; ------------------------------------------------------------------------------- 01360 elsiff macro var1,relop,var2 01361 goto _endif#v(_ifstack#v(_ifstackptr - 1)) 01362 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01363 if (1 relop 1) && !(0 relop 1) && !(1 relop 0) ; See if relop is == 01364 movf var1,W,BANKED 01365 subwf var2,W,BANKED 01366 btfss STATUS,Z,ACCESS 01367 else 01368 if (1 relop 0) ; See if relop is !=, >, or >= 01369 if (0 relop 1) ; See if relop is != 01370 movf var1,W,BANKED 01371 subwf var2,W,BANKED 01372 btfsc STATUS,Z,ACCESS 01373 else 01374 if (1 relop 1) ; See if relop is >= 01375 movf var2,W,BANKED 01376 subwf var1,W,BANKED 01377 btfss STATUS,C,ACCESS 01378 else ; Relop must be > 01379 movf var1,W,BANKED 01380 subwf var2,W,BANKED 01381 btfsc STATUS,C,ACCESS 01382 endif 01383 endif 01384 else 01385 if (0 relop 1) ; See if relop is < or < = MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 34 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01386 if (1 relop 1) ; See if relop is <= 01387 movf var1,W,BANKED 01388 subwf var2,W,BANKED 01389 btfss STATUS,C,ACCESS 01390 else ; Relop must be < 01391 movf var2,W,BANKED 01392 subwf var1,W,BANKED 01393 btfsc STATUS,C,ACCESS 01394 endif 01395 else 01396 error "Illegal relational operator in elsiff statement." 01397 endif 01398 endif 01399 endif 01400 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01401 _ifclausecount ++ 01402 endm 01403 01404 ; ------------------------------------------------------------------------------- 01405 ; ELSIFSET (START OF AN ELSIF CLAUSE IN AN IF STATEMENT) 01406 ; ------------------------------------------------------------------------------- 01407 ; Syntax: elsifset reg, bit, a 01408 ; ------------------------------------------------------------------------------- 01409 ; Arguments: reg the register containing the bit to be tested 01410 ; bit a literal value between 0 and 7 specifying the bit 01411 ; position to be tested 01412 ; a if a is 0, the access bank is selected. if a is 1, 01413 ; the BSR specifies the bank used to select reg. 01414 ; ------------------------------------------------------------------------------- 01415 ; This macro tests the specified bit in register reg; if it is set, the 01416 ; instructions following the elsifset macro are executed. Otherwise, the 01417 ; next case is tested. 01418 ; ------------------------------------------------------------------------------- 01419 elsifset macro reg,bit,a 01420 goto _endif#v(_ifstack#v(_ifstackptr - 1)) 01421 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01422 btfss reg,bit,a 01423 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01424 _ifclausecount ++ 01425 endm 01426 01427 ; ------------------------------------------------------------------------------- 01428 ; ELSIFCLR (START OF AN ELSIF CLAUSE IN AN IF STATEMENT) 01429 ; ------------------------------------------------------------------------------- 01430 ; Syntax: elsifclr reg, bit, a 01431 ; ------------------------------------------------------------------------------- 01432 ; Arguments: reg the register containing the bit to be tested 01433 ; bit a literal value between 0 and 7 specifying the bit 01434 ; position to be tested 01435 ; a if a is 0, the access bank is selected. if a is 1, 01436 ; the BSR specifies the bank used to select reg. 01437 ; ------------------------------------------------------------------------------- MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 35 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01438 ; This macro tests the specified bit in register reg; if it is clear, the 01439 ; instructions following the elsifset macro are executed. Otherwise, the 01440 ; next case is tested. 01441 ; ------------------------------------------------------------------------------- 01442 elsifclr macro reg,bit,a 01443 goto _endif#v(_ifstack#v(_ifstackptr - 1)) 01444 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01445 btfsc reg,bit,a 01446 goto _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount + 1) 01447 _ifclausecount ++ 01448 endm 01449 01450 ; ------------------------------------------------------------------------------- 01451 ; OTHERWISE (START OF AN OTHERWISE CLAUSE IN AN IF STATEMENT) 01452 ; ------------------------------------------------------------------------------- 01453 ; Syntax: OTHERWISE 01454 ; ------------------------------------------------------------------------------- 01455 ; This macro begins the sequence of instructions that is executed if none 01456 ; of the other conditions held. The otherwise block is optional. Note that 01457 ; this would normally be called 'else', but that was taken by MPASM for 01458 ; conditional assembly structures. 01459 ; ------------------------------------------------------------------------------- 01460 otherwise macro 01461 goto _endif#v(_ifstack#v(_ifstackptr - 1)) 01462 _if#v(_ifstack#v(_ifstackptr - 1))_#v(_ifclausecount) 01463 _ifclausecount ++ 01464 endm 01465 01466 ; ------------------------------------------------------------------------------- 01467 ; ENDI (END OF AN IF STATEMENT) 01468 ; ------------------------------------------------------------------------------- 01469 ; Syntax: endi 01470 ; ------------------------------------------------------------------------------- 01471 ; This macro marks the end of an if statement. 01472 ; ------------------------------------------------------------------------------- 01473 endi macro 01474 _ifstackptr -- 01475 _if#v(_ifstack#v(_ifstackptr))_#v(_ifclausecount) 01476 _endif#v(_ifstack#v(_ifstackptr)) 01477 _ifclausecount = _ifclausestack#v(_ifstackptr) 01478 endm 00019 00020 config PLLDIV = 6 ; PLL Prescaler Divide by 6 (24 MHz osci llator input) 00021 config CPUDIV = OSC1_PLL2 ; CPU System Clock Postscaler (CPU Clock:96MHz/2 =48MHz) 00022 config USBDIV = 2 00023 config FOSC = HSPLL_HS ; HS oscillator, PLL enabled, HS used by USB 00024 config FCMEM = OFF 00025 config IESO = OFF 00026 config PWRT = OFF 00027 config BOR = ON 00028 config BORV = 1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 36 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00029 config VREGEN = ON 00030 config WDT = OFF 00031 config WDTPS = 32768 00032 config MCLRE = ON 00033 config LPT1OSC = OFF 00034 config PBADEN = OFF 00035 config CCP2MX = ON 00036 config STVREN = ON 00037 config LVP = OFF 00038 config ICPRT = OFF 00039 config XINST = OFF 00040 config DEBUG = OFF 00041 config CP0 = OFF 00042 config CP1 = OFF 00043 config CP2 = OFF 00044 config CP3 = OFF 00045 config CPB = OFF 00046 config CPD = OFF 00047 config WRT0 = OFF 00048 config WRT1 = OFF 00049 config WRT2 = OFF 00050 config WRT3 = OFF 00051 config WRTB = OFF 00052 config WRTC = OFF 00053 config WRTD = OFF 00054 config EBTR0 = OFF 00055 config EBTR1 = OFF 00056 config EBTR2 = OFF 00057 config EBTR3 = OFF 00058 config EBTRB = OFF 00059 00060 #define SHOW_ENUM_STATUS 00061 00062 #define SET_RA0 0x01 ; vendor-specific request to set RA0 to high 00063 #define CLR_RA0 0x02 ; vendor-specific request to set RA0 to low 00064 00065 bank0 udata 000000 00066 USB_buffer_desc res 4 000004 00067 USB_buffer_data res 8 00000C 00068 USB_error_flags res 1 00000D 00069 USB_curr_config res 1 00000E 00070 USB_device_status res 1 00000F 00071 USB_dev_req res 1 000010 00072 USB_address_pending res 1 000011 00073 USB_desc_ptr res 1 000012 00074 USB_bytes_left res 1 000013 00075 USB_loop_index res 1 000014 00076 USB_packet_length res 1 000015 00077 USB_USTAT res 1 000016 00078 USB_USWSTAT res 1 000017 00079 COUNTER_L res 1 000018 00080 COUNTER_H res 1 00081 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 37 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00082 00083 STARTUP code 0x0000 000000 EF?? F??? 00084 goto Main ; Reset vector 000004 0000 00085 nop 000006 0000 00086 nop 000008 ED00 F000 00087 call ServiceUSB, FAST ; High-priority interrupt vector trap 00000C 0011 00088 retfie FAST ; <<< 00000E 0000 00089 nop 000010 0000 00090 nop 000012 0000 00091 nop 000014 0000 00092 nop 000016 0000 00093 nop 000018 0000 00094 nop 00001A EF?? F??? 00095 goto $ ; Low-priority i nterrupt vector trap 00096 00097 00098 USBSTUFF code 000000 00099 Descriptor 000000 0E?? 00100 movlw upper Descriptor_begin 000002 6EF8 00101 movwf TBLPTRU, ACCESS 000004 0E?? 00102 movlw high Descriptor_begin 000006 6EF7 00103 movwf TBLPTRH, ACCESS 000008 0E?? 00104 movlw low Descriptor_begin 00000A 010? 00105 banksel USB_desc_ptr 00000C 2500 00106 addwf USB_desc_ptr, W, BANKED 00107 ifset STATUS, C, ACCESS 0000 M variable _ifclausestack0 = _ifclausecount 0000 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00000E M _if0_0 00000E A0D8 M btfss STATUS,C,ACCESS 000010 EF?? F??? M goto _if0_1 00000001 M _ifcount ++ 00000001 M _ifclausecount ++ 000014 2AF7 00108 incf TBLPTRH, F, ACCESS 00109 ifset STATUS, Z, ACCESS 0001 M variable _ifclausestack1 = _ifclausecount 0001 M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000016 M _if1_0 000016 A4D8 M btfss STATUS,Z,ACCESS 000018 EF?? F??? M goto _if1_1 00000002 M _ifcount ++ 00000001 M _ifclausecount ++ 00001C 2AF8 00110 incf TBLPTRU, F, ACCESS 00111 endi 00000001 M _ifstackptr -- 00001E M _if1_1 00001E M _endif1 00000001 M _ifclausecount = _ifclausestack1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 38 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00112 endi 00000000 M _ifstackptr -- 00001E M _if0_1 00001E M _endif0 00000000 M _ifclausecount = _ifclausestack0 00001E 6EF6 00113 movwf TBLPTRL, ACCESS 000020 0008 00114 tblrd* 000022 50F5 00115 movf TABLAT, W 000024 0012 00116 return 00117 000026 00118 Descriptor_begin 000026 00119 Device 000026 0112 00120 db 0x12, DEVICE ; bLength, bDesc riptorType 000028 0110 00121 db 0x10, 0x01 ; bcdUSB (low byte), bcdUSB (high byte) 00002A 0000 00122 db 0x00, 0x00 ; bDevic eClass, bDeviceSubClass 00002C 0800 00123 db 0x00, MAX_PACKET_SIZE ; bDeviceProtocol, bMaxP acketSize 00002E 04D8 00124 db 0xD8, 0x04 ; idVend or (low byte), idVendor (high byte) 000030 0001 00125 db 0x01, 0x00 ; idProd uct (low byte), idProduct (high byte) 000032 0000 00126 db 0x00, 0x00 ; bcdDev ice (low byte), bcdDevice (high byte) 000034 0201 00127 db 0x01, 0x02 ; iManuf acturer, iProduct 000036 0100 00128 db 0x00, NUM_CONFIGURATIONS ; iSerialNumber (none), bNumConfigurations 000038 00129 Configuration1 000038 0209 00130 db 0x09, CONFIGURATION ; bLength, bDesc riptorType 00003A 0027 00131 db 0x27, 0x00 ; wTotal Length (low byte), wTotalLength (high byte) 00003C 0101 00132 db NUM_INTERFACES, 0x01 ; bNumInterfaces, bConfi gurationValue 00003E A000 00133 db 0x00, 0xA0 ; iConfi guration (none), bmAttributes 000040 0932 00134 db 0x32, 0x09 ; bMaxPo wer (100 mA), bLength (Interface1 descriptor starts here) 000042 0004 00135 db INTERFACE, 0x00 ; bDescriptorTyp e, bInterfaceNumber 000044 0300 00136 db 0x00, NUM_ENDPOINTS ; bAlternateSett ing, bNumEndpoints (excluding EP0) 000046 00FF 00137 db 0xFF, 0x00 ; bInter faceClass (vendor specific class code), bInterfaceSubClass 000048 00FF 00138 db 0xFF, 0x00 ; bInter faceProtocol (vendor specific protocol used), iInterface (none) 00004A 00139 ENDP1OUT 00004A 0507 00140 db 0x07, ENDPOINT ; bLength, bDesc riptorType 00004C 0101 00141 db EP01_OUT, ISOCHRONOUS ; bEndpointAddress (EP1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 39 LOC OBJECT CODE LINE SOURCE TEXT VALUE OUT), bmAttributes (Interrupt) 00004E 0008 00142 db 0x08, 0x00 ; wMaxPa cketSize (low byte), wMaxPacketSize (high byte) 000050 070A 00143 db 0x0A, 0x07 ; bInter val, Next Endpoint's bLength 000052 8105 00144 ENDP1IN db ENDPOINT, EP01_IN ; bDescriptorType, bEndp ointAddress (EP1 IN) 000054 0802 00145 db BULK, 0x08 ; bmAttr ibutes (Bulk), wMaxPacketSize (low byte) 000056 0A00 00146 db 0x00, 0x0A ; wMaxPa cketSize (high byte), bInterval 000058 0507 00147 ENDP2OUT db 0x07, ENDPOINT ; bLength, bDescriptorTy pe 00005A 0302 00148 db EP02_OUT, INTERRUPT ; bEndpointAddre ss (EP2 OUT), bmAttributes (Bulk) 00005C 0040 00149 db 0x40, 0x00 ; wMaxPa cketSize (low byte), wMaxPacketSize (high byte) 00005E 000A 00150 db 0x0A 00151 000060 00152 String0 000060 0304 00153 db String1-String0, STRING ; bLength, bDescriptorTy pe 000062 0409 00154 db 0x09, 0x04 ; wLANGI D[0] (low byte), wLANGID[0] (high byte) 000064 00155 String1 000064 0336 00156 db String2-String1, STRING ; bLength, bDescriptorTy pe 000066 004D 00157 db 'M', 0x00 ; bStrin g 000068 0069 00158 db 'i', 0x00 00006A 0063 00159 db 'c', 0x00 00006C 0072 00160 db 'r', 0x00 00006E 006F 00161 db 'o', 0x00 000070 0063 00162 db 'c', 0x00 000072 0068 00163 db 'h', 0x00 000074 0069 00164 db 'i', 0x00 000076 0070 00165 db 'p', 0x00 000078 0020 00166 db ' ', 0x00 00007A 0054 00167 db 'T', 0x00 00007C 0065 00168 db 'e', 0x00 00007E 0063 00169 db 'c', 0x00 000080 0068 00170 db 'h', 0x00 000082 006E 00171 db 'n', 0x00 000084 006F 00172 db 'o', 0x00 000086 006C 00173 db 'l', 0x00 000088 006F 00174 db 'o', 0x00 00008A 0067 00175 db 'g', 0x00 00008C 0079 00176 db 'y', 0x00 00008E 002C 00177 db ',', 0x00 000090 0020 00178 db ' ', 0x00 000092 0049 00179 db 'I', 0x00 000094 006E 00180 db 'n', 0x00 000096 0063 00181 db 'c', 0x00 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 40 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000098 002E 00182 db '.', 0x00 00009A 00183 String2 00009A 033A 00184 db Descriptor_end-String2, STRING ; bLength, bDescriptorTy pe 00009C 004E 00185 db 'N', 0x00 ; bString 00009E 0049 00186 db 'I', 0x00 0000A0 0043 00187 db 'C', 0x00 0000A2 004B 00188 db 'K', 0x00 0000A4 0020 00189 db ' ', 0x00 0000A6 0050 00190 db 'P', 0x00 0000A8 0049 00191 db 'I', 0x00 0000AA 0043 00192 db 'C', 0x00 0000AC 0031 00193 db '1', 0x00 0000AE 0038 00194 db '8', 0x00 0000B0 0046 00195 db 'F', 0x00 0000B2 0034 00196 db '4', 0x00 0000B4 0035 00197 db '5', 0x00 0000B6 0035 00198 db '5', 0x00 0000B8 0030 00199 db '0', 0x00 0000BA 0020 00200 db ' ', 0x00 0000BC 0055 00201 db 'U', 0x00 0000BE 0053 00202 db 'S', 0x00 0000C0 0042 00203 db 'B', 0x00 0000C2 0020 00204 db ' ', 0x00 0000C4 0046 00205 db 'F', 0x00 0000C6 0069 00206 db 'i', 0x00 0000C8 0072 00207 db 'r', 0x00 0000CA 006D 00208 db 'm', 0x00 0000CC 0077 00209 db 'w', 0x00 0000CE 0061 00210 db 'a', 0x00 0000D0 0072 00211 db 'r', 0x00 0000D2 0065 00212 db 'e', 0x00 0000D4 00213 Descriptor_end 00214 0000D4 00215 InitUSB 0000D4 6A69 00216 clrf UIE, ACCESS ; mask all USB interrupt s 0000D6 6A68 00217 clrf UIR, ACCESS ; clear all USB interrup t flags 0000D8 0E14 00218 movlw 0x14 0000DA 6E6F 00219 movwf UCFG, ACCESS ; configure USB for full-speed t ransfers and to use the on-chip transciever and pull-up resistor 0000DC 0E08 00220 movlw 0x08 0000DE 6E6D 00221 movwf UCON, ACCESS ; enable the USB module and its supporting circuitry 0000E0 010? 00222 banksel USB_curr_config 0000E2 6B00 00223 clrf USB_curr_config, BANKED 0000E4 6B00 00224 clrf USB_USWSTAT, BANKED ; default to powered state 0000E6 0E01 00225 movlw 0x01 0000E8 6F00 00226 movwf USB_device_status, BANKED 0000EA 0EFF 00227 movlw NO_REQUEST 0000EC 6F00 00228 movwf USB_dev_req, BANKED ; No device requests in process MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 41 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00229 #ifdef SHOW_ENUM_STATUS 0000EE 6A93 00230 clrf TRISB, ACCESS ; set all bits of PORTB as outpu ts 0000F0 0E01 00231 movlw 0x01 0000F2 6E81 00232 movwf PORTB, ACCESS ; set bit zero to indicate Power ed status 00233 #endif 00234 repeat ; do nothing... 0000F4 M _repeat0 0000 M variable _rptstack0 = _rptcount 00000001 M _rptstackptr ++ 00000001 M _rptcount ++ 00235 untilclr UCON, SE0, ACCESS ; ...until initial SE0 condition clears 00000000 M _rptstackptr -- 0000F4 BA6D M btfsc UCON,SE0,ACCESS 0000F6 EF?? F??? M goto _repeat0 0000FA M _endrepeat0 0000FA 0012 00236 return 00237 0000FC 00238 ServiceUSB 0000FC 9AA1 00239 bcf PIR2,USBIF 00240 select ; UIR: USB INTERRUPT STATUS REGISTER 0000 M variable _casestack0 = _casecount 0000 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 0000FE M _select0 0000FE EF?? F??? M goto _case0_0 00000001 M _selcount ++ 00241 caseset UIR, UERRIF, ACCESS ; UERRIF: USB Er ror Condition Interrupt bit 000102 EF?? F??? M goto _casebypass0_0 000106 M _case0_0 000106 A268 M btfss UIR,UERRIF,ACCESS 000108 EF?? F??? M goto _case0_1 00010C M _casebypass0_0 00000001 M _casecount ++ 00010C 6A6A 00242 clrf UEIR, ACCESS ; UEIR: USB ERRO R INTERRUPT STATUS REGISTER 00243 break 00010E EF?? F??? M goto _endselect0 00244 caseset UIR, SOFIF, ACCESS ; START-OF-FRAME Token Interrupt bit 000112 EF?? F??? M goto _casebypass0_1 000116 M _case0_1 000116 AC68 M btfss UIR,SOFIF,ACCESS 000118 EF?? F??? M goto _case0_2 00011C M _casebypass0_1 00000002 M _casecount ++ 00011C 9C68 00245 bcf UIR, SOFIF, ACCESS 00246 break MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 42 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00011E EF?? F??? M goto _endselect0 00247 caseset UIR, IDLEIF, ACCESS ; Idle condition detected (constant Idle state of 3 ms or more) 000122 EF?? F??? M goto _casebypass0_2 000126 M _case0_2 000126 A868 M btfss UIR,IDLEIF,ACCESS 000128 EF?? F??? M goto _case0_3 00012C M _casebypass0_2 00000003 M _casecount ++ 00012C 9868 00248 bcf UIR, IDLEIF, ACCESS 00012E 826D 00249 bsf UCON, SUSPND, ACCESS ; UCON: USB CONT ROL REGISTER, SUSPND: USB module and supporting circuitry in Power Conserve mode, SIE clock inac 00250 #ifdef SHOW_ENUM_STATUS 000130 0EE0 00251 movlw 0xE0 000132 1681 00252 andwf PORTB, F, ACCESS 000134 8881 00253 bsf PORTB, 4, ACCESS 00254 #endif 00255 break 000136 EF?? F??? M goto _endselect0 00256 caseset UIR, ACTVIF, ACCESS ; Bus Activity D etect Interrupt bit (Activity on the D+/D- lines was detected) 00013A EF?? F??? M goto _casebypass0_3 00013E M _case0_3 00013E A468 M btfss UIR,ACTVIF,ACCESS 000140 EF?? F??? M goto _case0_4 000144 M _casebypass0_3 00000004 M _casecount ++ 000144 9468 00257 bcf UIR, ACTVIF, ACCESS 000146 926D 00258 bcf UCON, SUSPND, ACCESS 00259 #ifdef SHOW_ENUM_STATUS 000148 0EE0 00260 movlw 0xE0 00014A 1681 00261 andwf PORTB, F, ACCESS 00014C 010? 00262 banksel USB_USWSTAT 00014E 5100 00263 movf USB_USWSTAT, W, BANKED 00264 select 0004 M variable _casestack1 = _casecount 0001 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000150 M _select1 000150 EF?? F??? M goto _case1_0 00000002 M _selcount ++ 00265 case POWERED_STATE 000154 EF?? F??? M goto _casebypass1_0 000158 M _case1_0 000158 0A00 M xorlw 0x00 00015A B4D8 M btfsc STATUS,Z,ACCESS 00015C EF?? F??? M goto _casematch1_0 000160 0A00 M xorlw 0x00 000162 EF?? F??? M goto _case1_1 000166 M _casematch1_0 000166 0A00 M xorlw 0x00 000168 M _casebypass1_0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 43 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000001 M _casecount ++ 000168 0E01 00266 movlw 0x01 00267 break 00016A EF?? F??? M goto _endselect1 00268 case DEFAULT_STATE 00016E EF?? F??? M goto _casebypass1_1 000172 M _case1_1 000172 0A01 M xorlw 0x01 000174 B4D8 M btfsc STATUS,Z,ACCESS 000176 EF?? F??? M goto _casematch1_1 00017A 0A01 M xorlw 0x01 00017C EF?? F??? M goto _case1_2 000180 M _casematch1_1 000180 0A01 M xorlw 0x01 000182 M _casebypass1_1 00000002 M _casecount ++ 000182 0E02 00269 movlw 0x02 00270 break 000184 EF?? F??? M goto _endselect1 00271 case ADDRESS_STATE 000188 EF?? F??? M goto _casebypass1_2 00018C M _case1_2 00018C 0A02 M xorlw 0x02 00018E B4D8 M btfsc STATUS,Z,ACCESS 000190 EF?? F??? M goto _casematch1_2 000194 0A02 M xorlw 0x02 000196 EF?? F??? M goto _case1_3 00019A M _casematch1_2 00019A 0A02 M xorlw 0x02 00019C M _casebypass1_2 00000003 M _casecount ++ 00019C 0E04 00272 movlw 0x04 00273 break 00019E EF?? F??? M goto _endselect1 00274 case CONFIG_STATE 0001A2 EF?? F??? M goto _casebypass1_3 0001A6 M _case1_3 0001A6 0A03 M xorlw 0x03 0001A8 B4D8 M btfsc STATUS,Z,ACCESS 0001AA EF?? F??? M goto _casematch1_3 0001AE 0A03 M xorlw 0x03 0001B0 EF?? F??? M goto _case1_4 0001B4 M _casematch1_3 0001B4 0A03 M xorlw 0x03 0001B6 M _casebypass1_3 00000004 M _casecount ++ 0001B6 0E08 00275 movlw 0x08 00276 ends 00000001 M _selstackptr -- 0001B8 M _case1_4 0001B8 M _endselect1 00000004 M _casecount = _casestack1 0001B8 1281 00277 iorwf PORTB, F, ACCESS MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 44 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00278 #endif 00279 break 0001BA EF?? F??? M goto _endselect0 00280 caseset UIR, STALLIF, ACCESS ; A STALL Handshake Inte rrupt bit (STALL handshake was sent by the SIE) 0001BE EF?? F??? M goto _casebypass0_4 0001C2 M _case0_4 0001C2 AA68 M btfss UIR,STALLIF,ACCESS 0001C4 EF?? F??? M goto _case0_5 0001C8 M _casebypass0_4 00000005 M _casecount ++ 0001C8 9A68 00281 bcf UIR, STALLIF, ACCESS 00282 break 0001CA EF?? F??? M goto _endselect0 00283 caseset UIR, URSTIF, ACCESS ; USB Reset Inte rrupt bit (Valid USB Reset occurred; 00h is loaded into UADDR register) 0001CE EF?? F??? M goto _casebypass0_5 0001D2 M _case0_5 0001D2 A068 M btfss UIR,URSTIF,ACCESS 0001D4 EF?? F??? M goto _case0_6 0001D8 M _casebypass0_5 00000006 M _casecount ++ 0001D8 010? 00284 banksel USB_curr_config 0001DA 6B00 00285 clrf USB_curr_config, BANKED 0001DC 9668 00286 bcf UIR, TRNIF, ACCESS ; Clear TRNIF four times to clear out the USTAT FIFO 0001DE 9668 00287 bcf UIR, TRNIF, ACCESS ; Transaction Co mplete Interrupt bit (Clearing this bit will cause the USTAT FIFO to advance) 0001E0 9668 00288 bcf UIR, TRNIF, ACCESS 0001E2 9668 00289 bcf UIR, TRNIF, ACCESS 0001E4 6A70 00290 clrf UEP0, ACCESS ; clear all EP c ontrol registers to disable all endpoints 0001E6 6A71 00291 clrf UEP1, ACCESS 0001E8 6A72 00292 clrf UEP2, ACCESS 0001EA 6A73 00293 clrf UEP3, ACCESS 0001EC 6A74 00294 clrf UEP4, ACCESS 0001EE 6A75 00295 clrf UEP5, ACCESS 0001F0 6A76 00296 clrf UEP6, ACCESS 0001F2 6A77 00297 clrf UEP7, ACCESS 0001F4 6A78 00298 clrf UEP8, ACCESS 0001F6 6A79 00299 clrf UEP9, ACCESS 0001F8 6A7A 00300 clrf UEP10, ACCESS 0001FA 6A7B 00301 clrf UEP11, ACCESS 0001FC 6A7C 00302 clrf UEP12, ACCESS 0001FE 6A7D 00303 clrf UEP13, ACCESS 000200 6A7E 00304 clrf UEP14, ACCESS 000202 6A7F 00305 clrf UEP15, ACCESS 000204 0104 00306 banksel BD0OBC 000206 0E08 00307 movlw MAX_PACKET_SIZE 000208 6F01 00308 movwf BD0OBC, BANKED 00020A 0E80 00309 movlw low USB_Buffer ; EP0 OUT gets a buffer... 00020C 6F02 00310 movwf BD0OAL, BANKED MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 45 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00020E 0E04 00311 movlw high USB_Buffer 000210 6F03 00312 movwf BD0OAH, BANKED ; ...set up its address 000212 0E88 00313 movlw 0x88 ; set UO WN bit (USB can write) 000214 6F00 00314 movwf BD0OST, BANKED 000216 0E88 00315 movlw low (USB_Buffer+MAX_PACKET_SIZE) ; EP0 IN gets a buffer... 000218 6F06 00316 movwf BD0IAL, BANKED 00021A 0E04 00317 movlw high (USB_Buffer+MAX_PACKET_SIZE) 00021C 6F07 00318 movwf BD0IAH, BANKED ; ...set up its address 00021E 0E08 00319 movlw 0x08 ; clear UOWN bit (MCU can write) 000220 6F04 00320 movwf BD0IST, BANKED 00321 000222 6A6E 00322 clrf UADDR, ACCESS ; set USB Addres s to 0 000224 6A68 00323 clrf UIR, ACCESS ; clear all the USB interrupt flags 000226 0E16 00324 movlw ENDPT_CONTROL 000228 6E70 00325 movwf UEP0, ACCESS ; EP0 is a contr ol pipe and requires an ACK 00326 00022A 0EFF 00327 movlw 0xFF ; enable all error interrupts 00022C 6E6B 00328 movwf UEIE, ACCESS 00022E 010? 00329 banksel USB_USWSTAT 000230 0E01 00330 movlw DEFAULT_STATE 000232 6F00 00331 movwf USB_USWSTAT, BANKED 000234 0E01 00332 movlw 0x01 000236 6F00 00333 movwf USB_device_status, BANKED ; self powered, remote wakeup disabled 00334 #ifdef SHOW_ENUM_STATUS 000238 0EE0 00335 movlw 0xE0 00023A 1681 00336 andwf PORTB, F, ACCESS 00023C 8281 00337 bsf PORTB, 1, ACCESS ; set bit 1 of P ORTB to indicate Powered state 00338 #endif 00339 break 00023E EF?? F??? M goto _endselect0 00340 caseset UIR, TRNIF, ACCESS ; Transaction Co mplete Interrupt bit (read USTAT register for endpoint information) 000242 EF?? F??? M goto _casebypass0_6 000246 M _case0_6 000246 A668 M btfss UIR,TRNIF,ACCESS 000248 EF?? F??? M goto _case0_7 00024C M _casebypass0_6 00000007 M _casecount ++ 00024C 0E04 00341 movlw 0x04 00024E 6EEA 00342 movwf FSR0H, ACCESS 000250 506C 00343 movf USTAT, W, ACCESS 000252 0B7C 00344 andlw 0x7C ; mask o MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 46 LOC OBJECT CODE LINE SOURCE TEXT VALUE ut bits 0, 1, and 7 of USTAT 000254 6EE9 00345 movwf FSR0L, ACCESS 000256 010? 00346 banksel USB_buffer_desc 000258 50EE 00347 movf POSTINC0, W 00025A 6F00 00348 movwf USB_buffer_desc, BANKED 00025C 50EE 00349 movf POSTINC0, W 00025E 6F00 00350 movwf USB_buffer_desc+1, BANKED 000260 50EE 00351 movf POSTINC0, W 000262 6F00 00352 movwf USB_buffer_desc+2, BANKED 000264 50EE 00353 movf POSTINC0, W 000266 6F00 00354 movwf USB_buffer_desc+3, BANKED 000268 506C 00355 movf USTAT, W, ACCESS 00026A 6F00 00356 movwf USB_USTAT, BANKED ; save the USB s tatus register 00026C 9668 00357 bcf UIR, TRNIF, ACCESS ; clear TRNIF interrupt flag 00358 #ifdef SHOW_ENUM_STATUS 00026E 0B18 00359 andlw 0x18 ; extrac t EP bits 00360 select 0007 M variable _casestack1 = _casecount 0002 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000270 M _select2 000270 EF?? F??? M goto _case2_0 00000003 M _selcount ++ 00361 case EP0 000274 EF?? F??? M goto _casebypass2_0 000278 M _case2_0 000278 0A00 M xorlw 0x00 << 3 00027A B4D8 M btfsc STATUS,Z,ACCESS 00027C EF?? F??? M goto _casematch2_0 000280 0A00 M xorlw 0x00 << 3 000282 EF?? F??? M goto _case2_1 000286 M _casematch2_0 000286 0A00 M xorlw 0x00 << 3 000288 M _casebypass2_0 00000001 M _casecount ++ 000288 0E20 00362 movlw 0x20 00363 break 00028A EF?? F??? M goto _endselect2 00364 case EP1 00028E EF?? F??? M goto _casebypass2_1 000292 M _case2_1 000292 0A08 M xorlw 0x01 << 3 000294 B4D8 M btfsc STATUS,Z,ACCESS 000296 EF?? F??? M goto _casematch2_1 00029A 0A08 M xorlw 0x01 << 3 00029C EF?? F??? M goto _case2_2 0002A0 M _casematch2_1 0002A0 0A08 M xorlw 0x01 << 3 0002A2 M _casebypass2_1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 47 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000002 M _casecount ++ 0002A2 0E40 00365 movlw 0x40 00366 break 0002A4 EF?? F??? M goto _endselect2 00367 case EP2 0002A8 EF?? F??? M goto _casebypass2_2 0002AC M _case2_2 0002AC 0A10 M xorlw 0x02 << 3 0002AE B4D8 M btfsc STATUS,Z,ACCESS 0002B0 EF?? F??? M goto _casematch2_2 0002B4 0A10 M xorlw 0x02 << 3 0002B6 EF?? F??? M goto _case2_3 0002BA M _casematch2_2 0002BA 0A10 M xorlw 0x02 << 3 0002BC M _casebypass2_2 00000003 M _casecount ++ 0002BC 0E80 00368 movlw 0x80 00369 break 0002BE EF?? F??? M goto _endselect2 00370 ends 00000001 M _selstackptr -- 0002C2 M _case2_3 0002C2 M _endselect2 00000007 M _casecount = _casestack1 0002C2 1A81 00371 xorwf PORTB, F, ACCESS ; toggle bit 5, 6, or 7 of PORTB to reflect EP activity 00372 #endif 0002C4 6B00 00373 clrf USB_error_flags, BANKED ; clear USB error flags 0002C6 5100 00374 movf USB_buffer_desc, W, BANKED 0002C8 0B3C 00375 andlw 0x3C ; extrac t PID bits 00376 select 0007 M variable _casestack1 = _casecount 0003 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 0002CA M _select3 0002CA EF?? F??? M goto _case3_0 00000004 M _selcount ++ 00377 case TOKEN_SETUP 0002CE EF?? F??? M goto _casebypass3_0 0002D2 M _case3_0 0002D2 0A34 M xorlw (0x0D<<2) 0002D4 B4D8 M btfsc STATUS,Z,ACCESS 0002D6 EF?? F??? M goto _casematch3_0 0002DA 0A34 M xorlw (0x0D<<2) 0002DC EF?? F??? M goto _case3_1 0002E0 M _casematch3_0 0002E0 0A34 M xorlw (0x0D<<2) 0002E2 M _casebypass3_0 00000001 M _casecount ++ 0002E2 EC?? F??? 00378 call ProcessSetupToken 00379 break MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 48 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0002E6 EF?? F??? M goto _endselect3 00380 case TOKEN_IN 0002EA EF?? F??? M goto _casebypass3_1 0002EE M _case3_1 0002EE 0A24 M xorlw (0x09<<2) 0002F0 B4D8 M btfsc STATUS,Z,ACCESS 0002F2 EF?? F??? M goto _casematch3_1 0002F6 0A24 M xorlw (0x09<<2) 0002F8 EF?? F??? M goto _case3_2 0002FC M _casematch3_1 0002FC 0A24 M xorlw (0x09<<2) 0002FE M _casebypass3_1 00000002 M _casecount ++ 0002FE EC?? F??? 00381 call ProcessInToken 00382 break 000302 EF?? F??? M goto _endselect3 00383 case TOKEN_OUT 000306 EF?? F??? M goto _casebypass3_2 00030A M _case3_2 00030A 0A04 M xorlw (0x01<<2) 00030C B4D8 M btfsc STATUS,Z,ACCESS 00030E EF?? F??? M goto _casematch3_2 000312 0A04 M xorlw (0x01<<2) 000314 EF?? F??? M goto _case3_3 000318 M _casematch3_2 000318 0A04 M xorlw (0x01<<2) 00031A M _casebypass3_2 00000003 M _casecount ++ 00031A EC?? F??? 00384 call ProcessOutToken 00385 break 00031E EF?? F??? M goto _endselect3 00386 ends 00000001 M _selstackptr -- 000322 M _case3_3 000322 M _endselect3 00000007 M _casecount = _casestack1 000322 010? 00387 banksel USB_error_flags 00388 ifset USB_error_flags, 0, BANKED ; if there was a Request Error... 0000 M variable _ifclausestack0 = _ifclausecount 0002 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000324 M _if2_0 000324 A100 M btfss USB_error_flags,0,BANKED 000326 EF?? F??? M goto _if2_1 00000003 M _ifcount ++ 00000001 M _ifclausecount ++ 00032A 0104 00389 banksel BD0OBC 00032C 0E08 00390 movlw MAX_PACKET_SIZE 00032E 6F01 00391 movwf BD0OBC ; ...get ready to receive the next Setup token... 000330 0E84 00392 movlw 0x84 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 49 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000332 6F04 00393 movwf BD0IST 000334 6F00 00394 movwf BD0OST ; ...and issue a protocol stall on EP0 00395 endi 00000000 M _ifstackptr -- 000336 M _if2_1 000336 M _endif2 00000000 M _ifclausecount = _ifclausestack0 00396 break 000336 EF?? F??? M goto _endselect0 00397 ends 00000000 M _selstackptr -- 00033A M _case0_7 00033A M _endselect0 00000000 M _casecount = _casestack0 00033A 0012 00398 return 00399 00033C 00400 ProcessSetupToken 00033C 010? 00401 banksel USB_buffer_data 00033E 5100 00402 movf USB_buffer_desc+ADDRESSH, W, BANKED 000340 6EEA 00403 movwf FSR0H, ACCESS 000342 5100 00404 movf USB_buffer_desc+ADDRESSL, W, BANKED 000344 6EE9 00405 movwf FSR0L, ACCESS 000346 50EE 00406 movf POSTINC0, W 000348 6F00 00407 movwf USB_buffer_data, BANKED 00034A 50EE 00408 movf POSTINC0, W 00034C 6F00 00409 movwf USB_buffer_data+1, BANKED 00034E 50EE 00410 movf POSTINC0, W 000350 6F00 00411 movwf USB_buffer_data+2, BANKED 000352 50EE 00412 movf POSTINC0, W 000354 6F00 00413 movwf USB_buffer_data+3, BANKED 000356 50EE 00414 movf POSTINC0, W 000358 6F00 00415 movwf USB_buffer_data+4, BANKED 00035A 50EE 00416 movf POSTINC0, W 00035C 6F00 00417 movwf USB_buffer_data+5, BANKED 00035E 50EE 00418 movf POSTINC0, W 000360 6F00 00419 movwf USB_buffer_data+6, BANKED 000362 50EE 00420 movf POSTINC0, W 000364 6F00 00421 movwf USB_buffer_data+7, BANKED 000366 0104 00422 banksel BD0OBC 000368 0E08 00423 movlw MAX_PACKET_SIZE 00036A 6F01 00424 movwf BD0OBC, BANKED ; reset the byte count 00036C 6F04 00425 movwf BD0IST, BANKED ; return the in buffer to us (dequeue any pending requests) 00036E 010? 00426 banksel USB_buffer_data+bmRequestType 00427 ifclr USB_buffer_data+bmRequestType, 7, BANKED 0000 M variable _ifclausestack0 = _ifclausecount 0003 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000370 M _if3_0 000370 BF00 M btfsc USB_buffer_data+0x00,7,BANKED MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 50 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000372 EF?? F??? M goto _if3_1 00000004 M _ifcount ++ 00000001 M _ifclausecount ++ 00428 ifl USB_buffer_data+wLength, !=, 0 0001 M variable _ifclausestack1 = _ifclausecount 0004 M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000376 M _if4_0 M if (1 != 1) && !(0 != 1) && !(1 != 0) ; See if relop is == M movf USB_buffer_data+0x06,W,BANKED M sublw 0 M btfss STATUS,Z,ACCESS M else M if (1 != 0) ; See if relop is !=, >, or >= M if (0 != 1) ; See if relop is != 000376 5100 M movf USB_buffer_data+0x06,W,BANKED 000378 0800 M sublw 0 00037A B4D8 M btfsc STATUS,Z,ACCESS M else M if (1 != 1) ; See if relop is >= M movlw 0 M subwf USB_buffer_data+0x06,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x06,W,BANKED M sublw 0 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 != 1) ; See if relop is < or < = M if (1 != 1) ; See if relop is <= M movf USB_buffer_data+0x06,W,BANKED M sublw 0 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0 M subwf USB_buffer_data+0x06,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 00037C EF?? F??? M goto _if4_1 00000005 M _ifcount ++ 00000001 M _ifclausecount ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 51 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00429 orif USB_buffer_data+wLengthHigh, !=, 0 000380 EF?? F??? M goto _ifbypass4_1 000384 M _if4_1 M if (1 != 1) && !(0 != 1) && !(1 != 0) ; See if relop is == M movf USB_buffer_data+0x07,W,BANKED M sublw 0 M btfss STATUS,Z,ACCESS M else M if (1 != 0) ; See if relop is !=, >, or >= M if (0 != 1) ; See if relop is != 000384 5100 M movf USB_buffer_data+0x07,W,BANKED 000386 0800 M sublw 0 000388 B4D8 M btfsc STATUS,Z,ACCESS M else M if (1 != 1) ; See if relop is >= M movlw 0 M subwf USB_buffer_data+0x07,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x07,W,BANKED M sublw 0 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 != 1) ; See if relop is < or < = M if (1 != 1) ; See if relop is <= M movf USB_buffer_data+0x07,W,BANKED M sublw 0 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0 M subwf USB_buffer_data+0x07,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in orif statement." M endif M endif M endif 00038A EF?? F??? M goto _if4_2 00038E M _ifbypass4_1 00000002 M _ifclausecount ++ 00038E 0EC8 00430 movlw 0xC8 00431 otherwise 000390 EF?? F??? M goto _endif4 000394 M _if4_2 00000003 M _ifclausecount ++ 000394 0E88 00432 movlw 0x88 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 52 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00433 endi 00000001 M _ifstackptr -- 000396 M _if4_3 000396 M _endif4 00000001 M _ifclausecount = _ifclausestack1 00434 otherwise 000396 EF?? F??? M goto _endif3 00039A M _if3_1 00000002 M _ifclausecount ++ 00039A 0E88 00435 movlw 0x88 00436 endi 00000000 M _ifstackptr -- 00039C M _if3_2 00039C M _endif3 00000000 M _ifclausecount = _ifclausestack0 00039C 0104 00437 banksel BD0OST 00039E 6F00 00438 movwf BD0OST, BANKED ; set EP0 OUT UO WN back to USB and DATA0/DATA1 packet according to request type 0003A0 986D 00439 bcf UCON, PKTDIS, ACCESS ; assuming there is nothing to dequeue, clear the packet disable bit 0003A2 010? 00440 banksel USB_dev_req 0003A4 0EFF 00441 movlw NO_REQUEST 0003A6 6F00 00442 movwf USB_dev_req, BANKED ; clear the devi ce request in process 0003A8 5100 00443 movf USB_buffer_data+bmRequestType, W, BANKED 0003AA 0B60 00444 andlw 0x60 ; extrac t request type bits 00445 select 0000 M variable _casestack0 = _casecount 0004 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 0003AC M _select4 0003AC EF?? F??? M goto _case4_0 00000005 M _selcount ++ 00446 case STANDARD 0003B0 EF?? F??? M goto _casebypass4_0 0003B4 M _case4_0 0003B4 0A00 M xorlw 0x00 << 5 0003B6 B4D8 M btfsc STATUS,Z,ACCESS 0003B8 EF?? F??? M goto _casematch4_0 0003BC 0A00 M xorlw 0x00 << 5 0003BE EF?? F??? M goto _case4_1 0003C2 M _casematch4_0 0003C2 0A00 M xorlw 0x00 << 5 0003C4 M _casebypass4_0 00000001 M _casecount ++ 0003C4 EC?? F??? 00447 call StandardRequests 00448 break 0003C8 EF?? F??? M goto _endselect4 00449 case CLASS 0003CC EF?? F??? M goto _casebypass4_1 0003D0 M _case4_1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 53 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0003D0 0A20 M xorlw 0x01 << 5 0003D2 B4D8 M btfsc STATUS,Z,ACCESS 0003D4 EF?? F??? M goto _casematch4_1 0003D8 0A20 M xorlw 0x01 << 5 0003DA EF?? F??? M goto _case4_2 0003DE M _casematch4_1 0003DE 0A20 M xorlw 0x01 << 5 0003E0 M _casebypass4_1 00000002 M _casecount ++ 0003E0 EC?? F??? 00450 call ClassRequests 00451 break 0003E4 EF?? F??? M goto _endselect4 00452 case VENDOR 0003E8 EF?? F??? M goto _casebypass4_2 0003EC M _case4_2 0003EC 0A40 M xorlw 0x02 << 5 0003EE B4D8 M btfsc STATUS,Z,ACCESS 0003F0 EF?? F??? M goto _casematch4_2 0003F4 0A40 M xorlw 0x02 << 5 0003F6 EF?? F??? M goto _case4_3 0003FA M _casematch4_2 0003FA 0A40 M xorlw 0x02 << 5 0003FC M _casebypass4_2 00000003 M _casecount ++ 0003FC EC?? F??? 00453 call VendorRequests 00454 break 000400 EF?? F??? M goto _endselect4 00455 default 000404 M _case4_3 00000004 M _casecount ++ 000404 8100 00456 bsf USB_error_flags, 0, BANKED ; set Re quest Error flag 00457 ends 00000000 M _selstackptr -- 000406 M _case4_4 000406 M _endselect4 00000000 M _casecount = _casestack0 000406 0012 00458 return 00459 000408 00460 StandardRequests 000408 5100 00461 movf USB_buffer_data+bRequest, W, BANKED 00462 select 0000 M variable _casestack0 = _casecount 0005 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 00040A M _select5 00040A EF?? F??? M goto _case5_0 00000006 M _selcount ++ 00463 case GET_STATUS 00040E EF?? F??? M goto _casebypass5_0 000412 M _case5_0 000412 0A00 M xorlw 0x00 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 54 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000414 B4D8 M btfsc STATUS,Z,ACCESS 000416 EF?? F??? M goto _casematch5_0 00041A 0A00 M xorlw 0x00 00041C EF?? F??? M goto _case5_1 000420 M _casematch5_0 000420 0A00 M xorlw 0x00 000422 M _casebypass5_0 00000001 M _casecount ++ 000422 5100 00464 movf USB_buffer_data+bmRequestType, W, BANKED 000424 0B1F 00465 andlw 0x1F ; extrac t request recipient bits 00466 select 0001 M variable _casestack1 = _casecount 0006 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000426 M _select6 000426 EF?? F??? M goto _case6_0 00000007 M _selcount ++ 00467 case RECIPIENT_DEVICE 00042A EF?? F??? M goto _casebypass6_0 00042E M _case6_0 00042E 0A00 M xorlw 0x00 000430 B4D8 M btfsc STATUS,Z,ACCESS 000432 EF?? F??? M goto _casematch6_0 000436 0A00 M xorlw 0x00 000438 EF?? F??? M goto _case6_1 00043C M _casematch6_0 00043C 0A00 M xorlw 0x00 00043E M _casebypass6_0 00000001 M _casecount ++ 00043E 0104 00468 banksel BD0IAH 000440 5107 00469 movf BD0IAH, W, BANKED 000442 6EEA 00470 movwf FSR0H, ACCESS 000444 5106 00471 movf BD0IAL, W, BANKED ; get buffer pointer 000446 6EE9 00472 movwf FSR0L, ACCESS 000448 010? 00473 banksel USB_device_status 00044A 5100 00474 movf USB_device_status, W, BANKED ; copy device status byte to EP0 buffer 00044C 6EEE 00475 movwf POSTINC0 00044E 6AEF 00476 clrf INDF0 000450 0104 00477 banksel BD0IBC 000452 0E02 00478 movlw 0x02 000454 6F05 00479 movwf BD0IBC, BANKED ; set byte count to 2 000456 0EC8 00480 movlw 0xC8 000458 6F04 00481 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00482 break 00045A EF?? F??? M goto _endselect6 00483 case RECIPIENT_INTERFACE 00045E EF?? F??? M goto _casebypass6_1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 55 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000462 M _case6_1 000462 0A01 M xorlw 0x01 000464 B4D8 M btfsc STATUS,Z,ACCESS 000466 EF?? F??? M goto _casematch6_1 00046A 0A01 M xorlw 0x01 00046C EF?? F??? M goto _case6_2 000470 M _casematch6_1 000470 0A01 M xorlw 0x01 000472 M _casebypass6_1 00000002 M _casecount ++ 000472 5100 00484 movf USB_USWSTAT, W, BANKED 00485 select 0002 M variable _casestack2 = _casecount 0007 M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 000474 M _select7 000474 EF?? F??? M goto _case7_0 00000008 M _selcount ++ 00486 case ADDRESS_STATE 000478 EF?? F??? M goto _casebypass7_0 00047C M _case7_0 00047C 0A02 M xorlw 0x02 00047E B4D8 M btfsc STATUS,Z,ACCESS 000480 EF?? F??? M goto _casematch7_0 000484 0A02 M xorlw 0x02 000486 EF?? F??? M goto _case7_1 00048A M _casematch7_0 00048A 0A02 M xorlw 0x02 00048C M _casebypass7_0 00000001 M _casecount ++ 00048C 8100 00487 bsf USB_erro r_flags, 0, BANKED ; set Request Error flag 00488 break 00048E EF?? F??? M goto _endselect7 00489 case CONFIG_STATE 000492 EF?? F??? M goto _casebypass7_1 000496 M _case7_1 000496 0A03 M xorlw 0x03 000498 B4D8 M btfsc STATUS,Z,ACCESS 00049A EF?? F??? M goto _casematch7_1 00049E 0A03 M xorlw 0x03 0004A0 EF?? F??? M goto _case7_2 0004A4 M _casematch7_1 0004A4 0A03 M xorlw 0x03 0004A6 M _casebypass7_1 00000002 M _casecount ++ 00490 ifl USB_buffer_data+wIndex, <, N UM_INTERFACES 0000 M variable _ifclausestack0 = _ifclausecount 0005 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 56 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0004A6 M _if5_0 M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movlw 1 M subwf USB_buffer_data+0x04,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,C,ACCESS M else ; Relop must be < 0004A6 0E01 M movlw 1 0004A8 5D00 M subwf USB_buffer_data+0x04,W,BANKED 0004AA B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 0004AC EF?? F??? M goto _if5_1 00000006 M _ifcount ++ 00000001 M _ifclausecount ++ 0004B0 0104 00491 banksel BD0IAH 0004B2 5107 00492 movf BD0IAH, W, BANKED 0004B4 6EEA 00493 movwf FSR0H, A CCESS 0004B6 5106 00494 movf BD0IAL, W, BANKED ; get buffer pointer 0004B8 6EE9 00495 movwf FSR0L, A MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 57 LOC OBJECT CODE LINE SOURCE TEXT VALUE CCESS 0004BA 6AEE 00496 clrf POSTINC0 0004BC 6AEF 00497 clrf INDF0 0004BE 0E02 00498 movlw 0x02 0004C0 6F05 00499 movwf BD0IBC, BANKED ; set byte count to 2 0004C2 0EC8 00500 movlw 0xC8 0004C4 6F04 00501 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00502 otherwise 0004C6 EF?? F??? M goto _endif5 0004CA M _if5_1 00000002 M _ifclausecount ++ 0004CA 8100 00503 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00504 endi 00000000 M _ifstackptr -- 0004CC M _if5_2 0004CC M _endif5 00000000 M _ifclausecount = _ifclausestack0 00505 break 0004CC EF?? F??? M goto _endselect7 00506 ends 00000002 M _selstackptr -- 0004D0 M _case7_2 0004D0 M _endselect7 00000002 M _casecount = _casestack2 00507 break 0004D0 EF?? F??? M goto _endselect6 00508 case RECIPIENT_ENDPOINT 0004D4 EF?? F??? M goto _casebypass6_2 0004D8 M _case6_2 0004D8 0A02 M xorlw 0x02 0004DA B4D8 M btfsc STATUS,Z,ACCESS 0004DC EF?? F??? M goto _casematch6_2 0004E0 0A02 M xorlw 0x02 0004E2 EF?? F??? M goto _case6_3 0004E6 M _casematch6_2 0004E6 0A02 M xorlw 0x02 0004E8 M _casebypass6_2 00000003 M _casecount ++ 0004E8 5100 00509 movf USB_USWSTAT, W, BANKED 00510 select 0003 M variable _casestack2 = _casecount 0008 M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 0004EA M _select8 0004EA EF?? F??? M goto _case8_0 00000009 M _selcount ++ 00511 case ADDRESS_STATE 0004EE EF?? F??? M goto _casebypass8_0 0004F2 M _case8_0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 58 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0004F2 0A02 M xorlw 0x02 0004F4 B4D8 M btfsc STATUS,Z,ACCESS 0004F6 EF?? F??? M goto _casematch8_0 0004FA 0A02 M xorlw 0x02 0004FC EF?? F??? M goto _case8_1 000500 M _casematch8_0 000500 0A02 M xorlw 0x02 000502 M _casebypass8_0 00000001 M _casecount ++ 000502 5100 00512 movf USB_buffer_data+ wIndex, W, BANKED ; get EP 000504 0B0F 00513 andlw 0x0F ; strip off direction bit 00514 ifset STATUS, Z, ACCESS ; see if it is EP0 0000 M variable _ifclausestack0 = _ifclausecount 0006 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000506 M _if6_0 000506 A4D8 M btfss STATUS,Z,ACCESS 000508 EF?? F??? M goto _if6_1 00000007 M _ifcount ++ 00000001 M _ifclausecount ++ 00050C 0104 00515 banksel BD0IAH 00050E 5107 00516 movf BD0IAH, W, BANKED ; put EP0 IN buffer pointer... 000510 6EEA 00517 movwf FSR0H, A CCESS 000512 5106 00518 movf BD0IAL, W, BANKED 000514 6EE9 00519 movwf FSR0L, A CCESS ; ...into FSR0 000516 010? 00520 banksel USB_buff er_data+wIndex 00521 ifset USB_buffer_data+wI ndex, 7, BANKED ; if the specified direction is IN... 0001 M variable _ifclausestack1 = _ifclausecount 0007 M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000518 M _if7_0 000518 AF00 M btfss USB_buffer_data+0x04,7,BANKED 00051A EF?? F??? M goto _if7_1 00000008 M _ifcount ++ 00000001 M _ifclausecount ++ 00051E 0104 00522 banksel BD0IST 000520 5104 00523 movf BD0IST, W, BANKED 00524 otherwise 000522 EF?? F??? M goto _endif7 000526 M _if7_1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 59 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000002 M _ifclausecount ++ 000526 0104 00525 banksel BD0OST 000528 5100 00526 movf BD0OST, W, BANKED 00527 endi 00000001 M _ifstackptr -- 00052A M _if7_2 00052A M _endif7 00000001 M _ifclausecount = _ifclausestack1 00052A 0B04 00528 andlw 0x04 ; extract the BSTALL bit 00052C 6EEF 00529 movwf INDF0 00052E 42EF 00530 rrncf INDF0, F 000530 42EF 00531 rrncf INDF0, F ; shift BSTALL bit into the lsb position 000532 6AEC 00532 clrf PREINC0 000534 0E02 00533 movlw 0x02 000536 6F05 00534 movwf BD0IBC, BANKED ; set byte count to 2 000538 0EC8 00535 movlw 0xC8 00053A 6F04 00536 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00537 otherwise 00053C EF?? F??? M goto _endif6 000540 M _if6_1 00000002 M _ifclausecount ++ 000540 8100 00538 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00539 endi 00000000 M _ifstackptr -- 000542 M _if6_2 000542 M _endif6 00000000 M _ifclausecount = _ifclausestack0 00540 break 000542 EF?? F??? M goto _endselect8 00541 case CONFIG_STATE 000546 EF?? F??? M goto _casebypass8_1 00054A M _case8_1 00054A 0A03 M xorlw 0x03 00054C B4D8 M btfsc STATUS,Z,ACCESS 00054E EF?? F??? M goto _casematch8_1 000552 0A03 M xorlw 0x03 000554 EF?? F??? M goto _case8_2 000558 M _casematch8_1 000558 0A03 M xorlw 0x03 00055A M _casebypass8_1 00000002 M _casecount ++ 00055A 0104 00542 banksel BD0IAH 00055C 5107 00543 movf BD0IAH, W, BANKE D ; put EP0 IN buffer pointer... 00055E 6EEA 00544 movwf FSR0H, ACCESS 000560 5106 00545 movf BD0IAL, W, BANKE MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 60 LOC OBJECT CODE LINE SOURCE TEXT VALUE D 000562 6EE9 00546 movwf FSR0L, ACCESS ; ...into FSR0 000564 0E0F 00547 movlw high UEP0 ; put UEP0 address... 000566 6EE2 00548 movwf FSR1H, ACCESS 000568 0E70 00549 movlw low UEP0 00056A 6EE1 00550 movwf FSR1L, ACCESS ; ...into FSR1 00056C 0E04 00551 movlw high BD0OST ; put BDndST address... 00056E 6EDA 00552 movwf FSR2H, ACCESS 000570 010? 00553 banksel USB_buffer_data+ wIndex 000572 5100 00554 movf USB_buffer_data+ wIndex, W, BANKED 000574 0B8F 00555 andlw 0x8F ; mask out all but the direction bit and EP numb 000576 6ED9 00556 movwf FSR2L, ACCESS 000578 46D9 00557 rlncf FSR2L, F, ACCESS 00057A 46D9 00558 rlncf FSR2L, F, ACCESS 00057C 46D9 00559 rlncf FSR2L, F, ACCESS ; FSR2L now contains the proper offset into the BD table 00057E 0E00 00560 movlw low BD0OST 000580 26D9 00561 addwf FSR2L, F, ACCESS ; ...into FSR2 00562 ifset STATUS, C, ACCESS 0000 M variable _ifclausestack0 = _ifclausecount 0008 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000582 M _if8_0 000582 A0D8 M btfss STATUS,C,ACCESS 000584 EF?? F??? M goto _if8_1 00000009 M _ifcount ++ 00000001 M _ifclausecount ++ 000588 2ADA 00563 incf FSR2H, F , ACCESS 00564 endi 00000000 M _ifstackptr -- 00058A M _if8_1 00058A M _endif8 00000000 M _ifclausecount = _ifclausestack0 00058A 5100 00565 movf USB_buffer_data+ wIndex, W, BANKED ; get EP and... 00058C 0B0F 00566 andlw 0x0F ; ...strip off direction bit 00567 ifset USB_buffer_data+wIndex, 7, BANKED ; if the specified EP direction is IN... 0000 M variable _ifclausestack0 = _ifclausecount 0009 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 61 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00058E M _if9_0 00058E AF00 M btfss USB_buffer_data+0x04,7,BANKED 000590 EF?? F??? M goto _if9_1 0000000A M _ifcount ++ 00000001 M _ifclausecount ++ 00568 andifclr PLUSW1, EPINEN, ACCESS ; ...and the specified EP is not enabled for IN transfers... 000594 B2E3 M btfsc PLUSW1,EPINEN,ACCESS 000596 EF?? F??? M goto _if9_1 00059A 8100 00569 bsf USB_error_flags, 0, BANKED ; ...set Request Error flag 00570 elsifclr USB_buffer_data+wIndex, 7, BANKED ; otherwise, if the specified EP direction is OUT... 00059C EF?? F??? M goto _endif9 0005A0 M _if9_1 0005A0 BF00 M btfsc USB_buffer_data+0x04,7,BANKED 0005A2 EF?? F??? M goto _if9_2 00000002 M _ifclausecount ++ 00571 andifclr PLUSW1, EPOUTEN, ACCESS ; ...and the specified EP is not enabled for OUT transfers... 0005A6 B4E3 M btfsc PLUSW1,EPOUTEN,ACCESS 0005A8 EF?? F??? M goto _if9_2 0005AC 8100 00572 bsf USB_error_flags, 0, BANKED ; ...set Request Error flag 00573 otherwise 0005AE EF?? F??? M goto _endif9 0005B2 M _if9_2 00000003 M _ifclausecount ++ 0005B2 50DF 00574 movf INDF2, W ; move the contents of the specified BDndST regi 0005B4 0B04 00575 andlw 0x04 ; extract the BSTALL bit 0005B6 6EEF 00576 movwf INDF0 0005B8 42EF 00577 rrncf INDF0, F 0005BA 42EF 00578 rrncf INDF0, F ; shift BSTALL bit into the lsb position 0005BC 6AEC 00579 clrf PREINC0 0005BE 0104 00580 banksel BD0IBC 0005C0 0E02 00581 movlw 0x02 0005C2 6F05 00582 movwf BD0IBC, BANKED ; set byte count to 2 0005C4 0EC8 00583 movlw 0xC8 0005C6 6F04 00584 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00585 endi 00000000 M _ifstackptr -- 0005C8 M _if9_3 0005C8 M _endif9 00000000 M _ifclausecount = _ifclausestack0 00586 break 0005C8 EF?? F??? M goto _endselect8 00587 default MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 62 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0005CC M _case8_2 00000003 M _casecount ++ 0005CC 8100 00588 bsf USB_erro r_flags, 0, BANKED ; set Request Error flag 00589 ends 00000002 M _selstackptr -- 0005CE M _case8_3 0005CE M _endselect8 00000003 M _casecount = _casestack2 00590 break 0005CE EF?? F??? M goto _endselect6 00591 default 0005D2 M _case6_3 00000004 M _casecount ++ 0005D2 8100 00592 bsf USB_error_flags, 0, BANK ED ; set Request Error flag 00593 ends 00000001 M _selstackptr -- 0005D4 M _case6_4 0005D4 M _endselect6 00000001 M _casecount = _casestack1 00594 break 0005D4 EF?? F??? M goto _endselect5 00595 case CLEAR_FEATURE 0005D8 EF?? F??? M goto _casebypass5_1 0005DC M _case5_1 0005DC 0A01 M xorlw 0x01 0005DE B4D8 M btfsc STATUS,Z,ACCESS 0005E0 EF?? F??? M goto _casematch5_1 0005E4 0A01 M xorlw 0x01 0005E6 EF?? F??? M goto _case5_2 0005EA M _casematch5_1 0005EA 0A01 M xorlw 0x01 0005EC M _casebypass5_1 00000002 M _casecount ++ 00596 case SET_FEATURE 0005EC EF?? F??? M goto _casebypass5_2 0005F0 M _case5_2 0005F0 0A03 M xorlw 0x03 0005F2 B4D8 M btfsc STATUS,Z,ACCESS 0005F4 EF?? F??? M goto _casematch5_2 0005F8 0A03 M xorlw 0x03 0005FA EF?? F??? M goto _case5_3 0005FE M _casematch5_2 0005FE 0A03 M xorlw 0x03 000600 M _casebypass5_2 00000003 M _casecount ++ 000600 5100 00597 movf USB_buffer_data+bmRequestType, W, BANKED 000602 0B1F 00598 andlw 0x1F ; extrac t request recipient bits 00599 select 0003 M variable _casestack1 = _casecount 0009 M variable _selstack1 = _selcount MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 63 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000604 M _select9 000604 EF?? F??? M goto _case9_0 0000000A M _selcount ++ 00600 case RECIPIENT_DEVICE 000608 EF?? F??? M goto _casebypass9_0 00060C M _case9_0 00060C 0A00 M xorlw 0x00 00060E B4D8 M btfsc STATUS,Z,ACCESS 000610 EF?? F??? M goto _casematch9_0 000614 0A00 M xorlw 0x00 000616 EF?? F??? M goto _case9_1 00061A M _casematch9_0 00061A 0A00 M xorlw 0x00 00061C M _casebypass9_0 00000001 M _casecount ++ 00061C 5100 00601 movf USB_buffer_data+wValue, W, BANKE D 00602 select 0001 M variable _casestack2 = _casecount 000A M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 00061E M _select10 00061E EF?? F??? M goto _case10_0 0000000B M _selcount ++ 00603 case DEVICE_REMOTE_WAKEUP 000622 EF?? F??? M goto _casebypass10_0 000626 M _case10_0 000626 0A01 M xorlw 0x01 000628 B4D8 M btfsc STATUS,Z,ACCESS 00062A EF?? F??? M goto _casematch10_0 00062E 0A01 M xorlw 0x01 000630 EF?? F??? M goto _case10_1 000634 M _casematch10_0 000634 0A01 M xorlw 0x01 000636 M _casebypass10_0 00000001 M _casecount ++ 00604 ifl USB_buffer_data+bRequest, == , CLEAR_FEATURE 0000 M variable _ifclausestack0 = _ifclausecount 000A M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000636 M _if10_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 000636 5100 M movf USB_buffer_data+0x01,W,BANKED 000638 0801 M sublw 0x01 00063A A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 64 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (0 == 1) ; See if relop is != M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,Z,ACCESS M else M if (1 == 1) ; See if relop is >= M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 00063C EF?? F??? M goto _if10_1 0000000B M _ifcount ++ 00000001 M _ifclausecount ++ 000640 9300 00605 bcf USB_device_status, 1, BANKED 00606 otherwise 000642 EF?? F??? M goto _endif10 000646 M _if10_1 00000002 M _ifclausecount ++ 000646 8300 00607 bsf USB_device_status, 1, BANKED 00608 endi 00000000 M _ifstackptr -- 000648 M _if10_2 000648 M _endif10 00000000 M _ifclausecount = _ifclausestack0 000648 0104 00609 banksel BD0IBC 00064A 6B05 00610 clrf BD0IBC, BANKED ; set byte count to 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 65 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00064C 0EC8 00611 movlw 0xC8 00064E 6F04 00612 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00613 break 000650 EF?? F??? M goto _endselect10 00614 default 000654 M _case10_1 00000002 M _casecount ++ 000654 8100 00615 bsf USB_erro r_flags, 0, BANKED ; set Request Error flag 00616 ends 00000002 M _selstackptr -- 000656 M _case10_2 000656 M _endselect10 00000001 M _casecount = _casestack2 00617 break 000656 EF?? F??? M goto _endselect9 00618 case RECIPIENT_ENDPOINT 00065A EF?? F??? M goto _casebypass9_1 00065E M _case9_1 00065E 0A02 M xorlw 0x02 000660 B4D8 M btfsc STATUS,Z,ACCESS 000662 EF?? F??? M goto _casematch9_1 000666 0A02 M xorlw 0x02 000668 EF?? F??? M goto _case9_2 00066C M _casematch9_1 00066C 0A02 M xorlw 0x02 00066E M _casebypass9_1 00000002 M _casecount ++ 00066E 5100 00619 movf USB_USWSTAT, W, BANKED 00620 select 0002 M variable _casestack2 = _casecount 000B M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 000670 M _select11 000670 EF?? F??? M goto _case11_0 0000000C M _selcount ++ 00621 case ADDRESS_STATE 000674 EF?? F??? M goto _casebypass11_0 000678 M _case11_0 000678 0A02 M xorlw 0x02 00067A B4D8 M btfsc STATUS,Z,ACCESS 00067C EF?? F??? M goto _casematch11_0 000680 0A02 M xorlw 0x02 000682 EF?? F??? M goto _case11_1 000686 M _casematch11_0 000686 0A02 M xorlw 0x02 000688 M _casebypass11_0 00000001 M _casecount ++ 000688 5100 00622 movf USB_buffer_data+ wIndex, W, BANKED ; get EP 00068A 0B0F 00623 andlw 0x0F MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 66 LOC OBJECT CODE LINE SOURCE TEXT VALUE ; strip off direction bit 00624 ifset STATUS, Z, ACCESS ; see if it is EP0 0000 M variable _ifclausestack0 = _ifclausecount 000B M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00068C M _if11_0 00068C A4D8 M btfss STATUS,Z,ACCESS 00068E EF?? F??? M goto _if11_1 0000000C M _ifcount ++ 00000001 M _ifclausecount ++ 000692 0104 00625 banksel BD0IBC 000694 6B05 00626 clrf BD0IBC, BANKED ; set byte count to 0 000696 0EC8 00627 movlw 0xC8 000698 6F04 00628 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00629 otherwise 00069A EF?? F??? M goto _endif11 00069E M _if11_1 00000002 M _ifclausecount ++ 00069E 8100 00630 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00631 endi 00000000 M _ifstackptr -- 0006A0 M _if11_2 0006A0 M _endif11 00000000 M _ifclausecount = _ifclausestack0 00632 break 0006A0 EF?? F??? M goto _endselect11 00633 case CONFIG_STATE 0006A4 EF?? F??? M goto _casebypass11_1 0006A8 M _case11_1 0006A8 0A03 M xorlw 0x03 0006AA B4D8 M btfsc STATUS,Z,ACCESS 0006AC EF?? F??? M goto _casematch11_1 0006B0 0A03 M xorlw 0x03 0006B2 EF?? F??? M goto _case11_2 0006B6 M _casematch11_1 0006B6 0A03 M xorlw 0x03 0006B8 M _casebypass11_1 00000002 M _casecount ++ 0006B8 0E0F 00634 movlw high UEP0 ; put UEP0 address... 0006BA 6EEA 00635 movwf FSR0H, ACCESS 0006BC 0E70 00636 movlw low UEP0 0006BE 6EE9 00637 movwf FSR0L, ACCESS ; ...into FSR0 0006C0 0E04 00638 movlw high BD0OST ; put BD0OST address... 0006C2 6EE2 00639 movwf FSR1H, ACCESS 0006C4 0E00 00640 movlw low BD0OST MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 67 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0006C6 6EE1 00641 movwf FSR1L, ACCESS ; ...into FSR1 0006C8 5100 00642 movf USB_buffer_data+ wIndex, W, BANKED ; get EP 0006CA 0B0F 00643 andlw 0x0F ; strip off direction bit 00644 ifclr STATUS, Z, ACCESS ; if it was not EP0... 0000 M variable _ifclausestack0 = _ifclausecount 000C M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0006CC M _if12_0 0006CC B4D8 M btfsc STATUS,Z,ACCESS 0006CE EF?? F??? M goto _if12_1 0000000D M _ifcount ++ 00000001 M _ifclausecount ++ 0006D2 26E9 00645 addwf FSR0L, F , ACCESS ; add EP number to FSR0 00646 ifset STATUS, C, ACCESS 0001 M variable _ifclausestack1 = _ifclausecount 000D M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0006D4 M _if13_0 0006D4 A0D8 M btfss STATUS,C,ACCESS 0006D6 EF?? F??? M goto _if13_1 0000000E M _ifcount ++ 00000001 M _ifclausecount ++ 0006DA 2AEA 00647 incf FSR0H, F, ACCESS 00648 endi 00000001 M _ifstackptr -- 0006DC M _if13_1 0006DC M _endif13 00000001 M _ifclausecount = _ifclausestack1 0006DC 4700 00649 rlncf USB_buff er_data+wIndex, F, BANKED 0006DE 4700 00650 rlncf USB_buff er_data+wIndex, F, BANKED 0006E0 4500 00651 rlncf USB_buff er_data+wIndex, W, BANKED ; WREG now contains the proper offset into the BD table for the 0006E2 0B7C 00652 andlw 0x7C ; mask out all but the direction bit and 0006E4 26E1 00653 addwf FSR1L, F , ACCESS ; add BD table offset to FSR1 00654 ifset STATUS, C, ACCESS 0001 M variable _ifclausestack1 = _ifclausecount 000E M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 68 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0006E6 M _if14_0 0006E6 A0D8 M btfss STATUS,C,ACCESS 0006E8 EF?? F??? M goto _if14_1 0000000F M _ifcount ++ 00000001 M _ifclausecount ++ 0006EC 2AE2 00655 incf FSR1H, F, ACCESS 00656 endi 00000001 M _ifstackptr -- 0006EE M _if14_1 0006EE M _endif14 00000001 M _ifclausecount = _ifclausestack1 00657 ifset USB_buffer_data+wI ndex, 1, BANKED ; if the specified EP direction (now bit 1) is IN... 0001 M variable _ifclausestack1 = _ifclausecount 000F M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0006EE M _if15_0 0006EE A300 M btfss USB_buffer_data+0x04,1,BANKED 0006F0 EF?? F??? M goto _if15_1 00000010 M _ifcount ++ 00000001 M _ifclausecount ++ 00658 ifset INDF0, EPI NEN, ACCESS ; if the specified EP is enabled for IN 0001 M variable _ifclausestack2 = _ifclausecount 0010 M variable _ifstack2 = _ifcount 00000003 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0006F4 M _if16_0 0006F4 A2EF M btfss INDF0,EPINEN,ACCESS 0006F6 EF?? F??? M goto _if16_1 00000011 M _ifcount ++ 00000001 M _ifclausecount ++ 00659 ifl USB_ buffer_data+bRequest, ==, CLEAR_FEATURE 0001 M variable _ifclausestack3 = _ifclausecount 0011 M variable _ifstack3 = _ifcount 00000004 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0006FA M _if17_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 0006FA 5100 M movf USB_buffer_data+0x01,W,BANKED 0006FC 0801 M sublw 0x01 0006FE A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,Z,ACCESS M else MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 69 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (1 == 1) ; See if relop is >= M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000700 EF?? F??? M goto _if17_1 00000012 M _ifcount ++ 00000001 M _ifclausecount ++ 000704 6AE7 00660 clrf INDF1 ; clear the stall on the specified EP 00661 otherwis e 000706 EF?? F??? M goto _endif17 00070A M _if17_1 00000002 M _ifclausecount ++ 00070A 0E84 00662 movlw 0x84 00070C 6EE7 00663 movwf INDF1 ; stall the specified EP 00664 endi 00000003 M _ifstackptr -- 00070E M _if17_2 00070E M _endif17 00000001 M _ifclausecount = _ifclausestack3 00665 otherwise 00070E EF?? F??? M goto _endif16 000712 M _if16_1 00000002 M _ifclausecount ++ 000712 8100 00666 bsf MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 70 LOC OBJECT CODE LINE SOURCE TEXT VALUE USB_error_flags, 0, BANKED ; set Request Error flag 00667 endi 00000002 M _ifstackptr -- 000714 M _if16_2 000714 M _endif16 00000001 M _ifclausecount = _ifclausestack2 00668 otherwise ; ...otherwise the specified EP 000714 EF?? F??? M goto _endif15 000718 M _if15_1 00000002 M _ifclausecount ++ 00669 ifset INDF0, EPO UTEN, ACCESS ; if the specified EP is enabled for OUT transfe 0002 M variable _ifclausestack2 = _ifclausecount 0012 M variable _ifstack2 = _ifcount 00000003 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000718 M _if18_0 000718 A4EF M btfss INDF0,EPOUTEN,ACCESS 00071A EF?? F??? M goto _if18_1 00000013 M _ifcount ++ 00000001 M _ifclausecount ++ 00670 ifl USB_ buffer_data+bRequest, ==, CLEAR_FEATURE 0001 M variable _ifclausestack3 = _ifclausecount 0013 M variable _ifstack3 = _ifcount 00000004 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00071E M _if19_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 00071E 5100 M movf USB_buffer_data+0x01,W,BANKED 000720 0801 M sublw 0x01 000722 A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,Z,ACCESS M else M if (1 == 1) ; See if relop is >= M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfsc STATUS,C,ACCESS M endif M endif M else MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 71 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+0x01,W,BANKED M sublw 0x01 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0x01 M subwf USB_buffer_data+0x01,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000724 EF?? F??? M goto _if19_1 00000014 M _ifcount ++ 00000001 M _ifclausecount ++ 000728 0E88 00671 movlw 0x88 00072A 6EE7 00672 movwf INDF1 ; clear the stall on the specified EP 00673 otherwis e 00072C EF?? F??? M goto _endif19 000730 M _if19_1 00000002 M _ifclausecount ++ 000730 0E84 00674 movlw 0x84 000732 6EE7 00675 movwf INDF1 ; stall the specified EP 00676 endi 00000003 M _ifstackptr -- 000734 M _if19_2 000734 M _endif19 00000001 M _ifclausecount = _ifclausestack3 00677 otherwise 000734 EF?? F??? M goto _endif18 000738 M _if18_1 00000002 M _ifclausecount ++ 000738 8100 00678 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00679 endi 00000002 M _ifstackptr -- 00073A M _if18_2 00073A M _endif18 00000002 M _ifclausecount = _ifclausestack2 00680 endi 00000001 M _ifstackptr -- 00073A M _if15_2 00073A M _endif15 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 72 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000001 M _ifclausecount = _ifclausestack1 00681 endi 00000000 M _ifstackptr -- 00073A M _if12_1 00073A M _endif12 00000000 M _ifclausecount = _ifclausestack0 00682 ifclr USB_error_flags, 0, BANKED ; if there was no Request Error... 0000 M variable _ifclausestack0 = _ifclausecount 0014 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00073A M _if20_0 00073A B100 M btfsc USB_error_flags,0,BANKED 00073C EF?? F??? M goto _if20_1 00000015 M _ifcount ++ 00000001 M _ifclausecount ++ 000740 0104 00683 banksel BD0IBC 000742 6B05 00684 clrf BD0IBC, BANKED ; set byte count to 0 000744 0EC8 00685 movlw 0xC8 000746 6F04 00686 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00687 endi 00000000 M _ifstackptr -- 000748 M _if20_1 000748 M _endif20 00000000 M _ifclausecount = _ifclausestack0 00688 break 000748 EF?? F??? M goto _endselect11 00689 default 00074C M _case11_2 00000003 M _casecount ++ 00074C 8100 00690 bsf USB_erro r_flags, 0, BANKED ; set Request Error flag 00691 ends 00000002 M _selstackptr -- 00074E M _case11_3 00074E M _endselect11 00000002 M _casecount = _casestack2 00692 break 00074E EF?? F??? M goto _endselect9 00693 default 000752 M _case9_2 00000003 M _casecount ++ 000752 8100 00694 bsf USB_error_flags, 0, BANK ED ; set Request Error flag 00695 ends 00000001 M _selstackptr -- 000754 M _case9_3 000754 M _endselect9 00000003 M _casecount = _casestack1 00696 break MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 73 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000754 EF?? F??? M goto _endselect5 00697 case SET_ADDRESS 000758 EF?? F??? M goto _casebypass5_3 00075C M _case5_3 00075C 0A05 M xorlw 0x05 00075E B4D8 M btfsc STATUS,Z,ACCESS 000760 EF?? F??? M goto _casematch5_3 000764 0A05 M xorlw 0x05 000766 EF?? F??? M goto _case5_4 00076A M _casematch5_3 00076A 0A05 M xorlw 0x05 00076C M _casebypass5_3 00000004 M _casecount ++ 00698 ifset USB_buffer_data+wValue, 7, BANKED ; if new device address is illegal, send Request Error 0000 M variable _ifclausestack0 = _ifclausecount 0015 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00076C M _if21_0 00076C AF00 M btfss USB_buffer_data+0x02,7,BANKED 00076E EF?? F??? M goto _if21_1 00000016 M _ifcount ++ 00000001 M _ifclausecount ++ 000772 8100 00699 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00700 otherwise 000774 EF?? F??? M goto _endif21 000778 M _if21_1 00000002 M _ifclausecount ++ 000778 0E05 00701 movlw SET_ADDRESS 00077A 6F00 00702 movwf USB_dev_req, BANKED ; processing a SET_ADDRESS request 00077C 5100 00703 movf USB_buffer_data+wValue, W, BANKED 00077E 6F00 00704 movwf USB_address_pending, BANKED ; save n ew address 000780 0104 00705 banksel BD0IBC 000782 6B05 00706 clrf BD0IBC, BANKED ; set byte count to 0 000784 0EC8 00707 movlw 0xC8 000786 6F04 00708 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00709 endi 00000000 M _ifstackptr -- 000788 M _if21_2 000788 M _endif21 00000000 M _ifclausecount = _ifclausestack0 00710 break 000788 EF?? F??? M goto _endselect5 00711 case GET_DESCRIPTOR 00078C EF?? F??? M goto _casebypass5_4 000790 M _case5_4 000790 0A06 M xorlw 0x06 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 74 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000792 B4D8 M btfsc STATUS,Z,ACCESS 000794 EF?? F??? M goto _casematch5_4 000798 0A06 M xorlw 0x06 00079A EF?? F??? M goto _case5_5 00079E M _casematch5_4 00079E 0A06 M xorlw 0x06 0007A0 M _casebypass5_4 00000005 M _casecount ++ 0007A0 6F00 00712 movwf USB_dev_req, BANKED ; processing a GET_DESCRIPTOR request 0007A2 5100 00713 movf USB_buffer_data+(wValue+1), W, BANKED 00714 select 0005 M variable _casestack1 = _casecount 000C M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 0007A4 M _select12 0007A4 EF?? F??? M goto _case12_0 0000000D M _selcount ++ 00715 case DEVICE 0007A8 EF?? F??? M goto _casebypass12_0 0007AC M _case12_0 0007AC 0A01 M xorlw 1 0007AE B4D8 M btfsc STATUS,Z,ACCESS 0007B0 EF?? F??? M goto _casematch12_0 0007B4 0A01 M xorlw 1 0007B6 EF?? F??? M goto _case12_1 0007BA M _casematch12_0 0007BA 0A01 M xorlw 1 0007BC M _casebypass12_0 00000001 M _casecount ++ 0007BC 0E00 00716 movlw low (Device-Descriptor_begin) 0007BE 6F00 00717 movwf USB_desc_ptr, BANKED 0007C0 EC?? F??? 00718 call Descriptor ; get descriptor length 0007C4 6F00 00719 movwf USB_bytes_left, BANKED 00720 ifl USB_buffer_data+(wLength+1), ==, 0 0000 M variable _ifclausestack0 = _ifclausecount 0016 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0007C6 M _if22_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 0007C6 5100 M movf USB_buffer_data+(0x06+1),W,BANKED 0007C8 0800 M sublw 0 0007CA A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,Z,ACCESS MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 75 LOC OBJECT CODE LINE SOURCE TEXT VALUE M else M if (1 == 1) ; See if relop is >= M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 0007CC EF?? F??? M goto _if22_1 00000017 M _ifcount ++ 00000001 M _ifclausecount ++ 00721 andiff USB_buffer_data+wLength, <, USB_bytes_lef t M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movf USB_bytes_left,W,BANKED M subwf USB_buffer_data+0x06,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 76 LOC OBJECT CODE LINE SOURCE TEXT VALUE M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be < 0007D0 5100 M movf USB_bytes_left,W,BANKED 0007D2 5D00 M subwf USB_buffer_data+0x06,W,BANKED 0007D4 B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in andiff statement." M endif M endif M endif 0007D6 EF?? F??? M goto _if22_1 0007DA 5100 00722 movf USB_buffer_data+wLength, W, BANKED 0007DC 6F00 00723 movwf USB_bytes_left, BANKED 00724 endi 00000000 M _ifstackptr -- 0007DE M _if22_1 0007DE M _endif22 00000000 M _ifclausecount = _ifclausestack0 0007DE EC?? F??? 00725 call SendDescriptorPacket 00726 break 0007E2 EF?? F??? M goto _endselect12 00727 case CONFIGURATION 0007E6 EF?? F??? M goto _casebypass12_1 0007EA M _case12_1 0007EA 0A02 M xorlw 2 0007EC B4D8 M btfsc STATUS,Z,ACCESS 0007EE EF?? F??? M goto _casematch12_1 0007F2 0A02 M xorlw 2 0007F4 EF?? F??? M goto _case12_2 0007F8 M _casematch12_1 0007F8 0A02 M xorlw 2 0007FA M _casebypass12_1 00000002 M _casecount ++ 0007FA 5100 00728 movf USB_buffer_data+wValue, W, BANKE D 00729 select 0002 M variable _casestack2 = _casecount 000D M variable _selstack2 = _selcount 00000003 M _selstackptr ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 77 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000000 M _casecount = 0 0007FC M _select13 0007FC EF?? F??? M goto _case13_0 0000000E M _selcount ++ 00730 case 0 000800 EF?? F??? M goto _casebypass13_0 000804 M _case13_0 000804 0A00 M xorlw 0 000806 B4D8 M btfsc STATUS,Z,ACCESS 000808 EF?? F??? M goto _casematch13_0 00080C 0A00 M xorlw 0 00080E EF?? F??? M goto _case13_1 000812 M _casematch13_0 000812 0A00 M xorlw 0 000814 M _casebypass13_0 00000001 M _casecount ++ 000814 0E12 00731 movlw low (Configurati on1-Descriptor_begin) 00732 break 000816 EF?? F??? M goto _endselect13 00733 default 00081A M _case13_1 00000002 M _casecount ++ 00081A 8100 00734 bsf USB_erro r_flags, 0, BANKED ; set Request Error flag 00735 ends 00000002 M _selstackptr -- 00081C M _case13_2 00081C M _endselect13 00000002 M _casecount = _casestack2 00736 ifclr USB_error_flags, 0, BANKED 0000 M variable _ifclausestack0 = _ifclausecount 0017 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00081C M _if23_0 00081C B100 M btfsc USB_error_flags,0,BANKED 00081E EF?? F??? M goto _if23_1 00000018 M _ifcount ++ 00000001 M _ifclausecount ++ 000822 0F02 00737 addlw 0x02 ; add offset for wTotalLength 000824 6F00 00738 movwf USB_desc_ptr, BANKED 000826 EC?? F??? 00739 call Descriptor ; get total descriptor length 00082A 6F00 00740 movwf USB_bytes_left, BANKED 00082C 0E02 00741 movlw 0x02 00082E 5F00 00742 subwf USB_desc_ptr, F, BANKED ; subtract offset for wTotalLength 00743 ifl USB_buffer_data+(wLength+1), ==, 0 0001 M variable _ifclausestack1 = _ifclausecount 0018 M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 78 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000000 M _ifclausecount = 0 000830 M _if24_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 000830 5100 M movf USB_buffer_data+(0x06+1),W,BANKED 000832 0800 M sublw 0 000834 A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,Z,ACCESS M else M if (1 == 1) ; See if relop is >= M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000836 EF?? F??? M goto _if24_1 00000019 M _ifcount ++ 00000001 M _ifclausecount ++ 00744 andiff USB_buffer_data+wLength, <, USB_b ytes_left M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,Z,ACCESS M else MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 79 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movf USB_bytes_left,W,BANKED M subwf USB_buffer_data+0x06,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be < 00083A 5100 M movf USB_bytes_left,W,BANKED 00083C 5D00 M subwf USB_buffer_data+0x06,W,BANKED 00083E B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in andiff statement." M endif M endif M endif 000840 EF?? F??? M goto _if24_1 000844 5100 00745 movf USB_buffer_data+ wLength, W, BANKED 000846 6F00 00746 movwf USB_bytes_left, BANKED 00747 endi 00000001 M _ifstackptr -- 000848 M _if24_1 000848 M _endif24 00000001 M _ifclausecount = _ifclausestack1 000848 EC?? F??? 00748 call SendDescriptorPacket 00749 endi 00000000 M _ifstackptr -- 00084C M _if23_1 00084C M _endif23 00000000 M _ifclausecount = _ifclausestack0 00750 break MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 80 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00084C EF?? F??? M goto _endselect12 00751 case STRING 000850 EF?? F??? M goto _casebypass12_2 000854 M _case12_2 000854 0A03 M xorlw 3 000856 B4D8 M btfsc STATUS,Z,ACCESS 000858 EF?? F??? M goto _casematch12_2 00085C 0A03 M xorlw 3 00085E EF?? F??? M goto _case12_3 000862 M _casematch12_2 000862 0A03 M xorlw 3 000864 M _casebypass12_2 00000003 M _casecount ++ 000864 5100 00752 movf USB_buffer_data+wValue, W, BANKE D 00753 select 0003 M variable _casestack2 = _casecount 000E M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 000866 M _select14 000866 EF?? F??? M goto _case14_0 0000000F M _selcount ++ 00754 case 0 00086A EF?? F??? M goto _casebypass14_0 00086E M _case14_0 00086E 0A00 M xorlw 0 000870 B4D8 M btfsc STATUS,Z,ACCESS 000872 EF?? F??? M goto _casematch14_0 000876 0A00 M xorlw 0 000878 EF?? F??? M goto _case14_1 00087C M _casematch14_0 00087C 0A00 M xorlw 0 00087E M _casebypass14_0 00000001 M _casecount ++ 00087E 0E3A 00755 movlw low (String0-Des criptor_begin) 00756 break 000880 EF?? F??? M goto _endselect14 00757 case 1 000884 EF?? F??? M goto _casebypass14_1 000888 M _case14_1 000888 0A01 M xorlw 1 00088A B4D8 M btfsc STATUS,Z,ACCESS 00088C EF?? F??? M goto _casematch14_1 000890 0A01 M xorlw 1 000892 EF?? F??? M goto _case14_2 000896 M _casematch14_1 000896 0A01 M xorlw 1 000898 M _casebypass14_1 00000002 M _casecount ++ 000898 0E3E 00758 movlw low (String1-Des criptor_begin) MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 81 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00759 break 00089A EF?? F??? M goto _endselect14 00760 case 2 00089E EF?? F??? M goto _casebypass14_2 0008A2 M _case14_2 0008A2 0A02 M xorlw 2 0008A4 B4D8 M btfsc STATUS,Z,ACCESS 0008A6 EF?? F??? M goto _casematch14_2 0008AA 0A02 M xorlw 2 0008AC EF?? F??? M goto _case14_3 0008B0 M _casematch14_2 0008B0 0A02 M xorlw 2 0008B2 M _casebypass14_2 00000003 M _casecount ++ 0008B2 0E74 00761 movlw low (String2-Des criptor_begin) 00762 break 0008B4 EF?? F??? M goto _endselect14 00763 default 0008B8 M _case14_3 00000004 M _casecount ++ 0008B8 8100 00764 bsf USB_erro r_flags, 0, BANKED ; Set Request Error flag 00765 ends 00000002 M _selstackptr -- 0008BA M _case14_4 0008BA M _endselect14 00000003 M _casecount = _casestack2 00766 ifclr USB_error_flags, 0, BANKED 0000 M variable _ifclausestack0 = _ifclausecount 0019 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0008BA M _if25_0 0008BA B100 M btfsc USB_error_flags,0,BANKED 0008BC EF?? F??? M goto _if25_1 0000001A M _ifcount ++ 00000001 M _ifclausecount ++ 0008C0 6F00 00767 movwf USB_desc_ptr, BANKED 0008C2 EC?? F??? 00768 call Descriptor ; get descriptor length 0008C6 6F00 00769 movwf USB_bytes_left, BANKED 00770 ifl USB_buffer_data+(wLength+1), ==, 0 0001 M variable _ifclausestack1 = _ifclausecount 001A M variable _ifstack1 = _ifcount 00000002 M _ifstackptr ++ 00000000 M _ifclausecount = 0 0008C8 M _if26_0 M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 0008C8 5100 M movf USB_buffer_data+(0x06+1),W,BANKED 0008CA 0800 M sublw 0 0008CC A4D8 M btfss STATUS,Z,ACCESS M else MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 82 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,Z,ACCESS M else M if (1 == 1) ; See if relop is >= M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_buffer_data+(0x06+1),W,BANKED M sublw 0 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0 M subwf USB_buffer_data+(0x06+1),W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 0008CE EF?? F??? M goto _if26_1 0000001B M _ifcount ++ 00000001 M _ifclausecount ++ 00771 andiff USB_buffer_data+wLength, <, USB_b ytes_left M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,Z,ACCESS M else MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 83 LOC OBJECT CODE LINE SOURCE TEXT VALUE M if (1 < 1) ; See if relop is >= M movf USB_bytes_left,W,BANKED M subwf USB_buffer_data+0x06,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x06,W,BANKED M subwf USB_bytes_left,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be < 0008D2 5100 M movf USB_bytes_left,W,BANKED 0008D4 5D00 M subwf USB_buffer_data+0x06,W,BANKED 0008D6 B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in andiff statement." M endif M endif M endif 0008D8 EF?? F??? M goto _if26_1 0008DC 5100 00772 movf USB_buffer_data+ wLength, W, BANKED 0008DE 6F00 00773 movwf USB_bytes_left, BANKED 00774 endi 00000001 M _ifstackptr -- 0008E0 M _if26_1 0008E0 M _endif26 00000001 M _ifclausecount = _ifclausestack1 0008E0 EC?? F??? 00775 call SendDescriptorPacket 00776 endi 00000000 M _ifstackptr -- 0008E4 M _if25_1 0008E4 M _endif25 00000000 M _ifclausecount = _ifclausestack0 00777 break 0008E4 EF?? F??? M goto _endselect12 00778 default 0008E8 M _case12_3 00000004 M _casecount ++ 0008E8 8100 00779 bsf USB_error_flags, 0, BANK ED ; set Request Error flag 00780 ends MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 84 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000001 M _selstackptr -- 0008EA M _case12_4 0008EA M _endselect12 00000005 M _casecount = _casestack1 00781 break 0008EA EF?? F??? M goto _endselect5 00782 case GET_CONFIGURATION 0008EE EF?? F??? M goto _casebypass5_5 0008F2 M _case5_5 0008F2 0A08 M xorlw 0x08 0008F4 B4D8 M btfsc STATUS,Z,ACCESS 0008F6 EF?? F??? M goto _casematch5_5 0008FA 0A08 M xorlw 0x08 0008FC EF?? F??? M goto _case5_6 000900 M _casematch5_5 000900 0A08 M xorlw 0x08 000902 M _casebypass5_5 00000006 M _casecount ++ 000902 0104 00783 banksel BD0IAH 000904 5107 00784 movf BD0IAH, W, BANKED 000906 6EEA 00785 movwf FSR0H, ACCESS 000908 5106 00786 movf BD0IAL, W, BANKED 00090A 6EE9 00787 movwf FSR0L, ACCESS 00090C 010? 00788 banksel USB_curr_config 00090E 5100 00789 movf USB_curr_config, W, BANKED 000910 6EEF 00790 movwf INDF0 ; copy c urrent device configuration to EP0 IN buffer 000912 0104 00791 banksel BD0IBC 000914 0E01 00792 movlw 0x01 000916 6F05 00793 movwf BD0IBC, BANKED ; set EP0 IN byt e count to 1 000918 0EC8 00794 movlw 0xC8 00091A 6F04 00795 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00796 break 00091C EF?? F??? M goto _endselect5 00797 case SET_CONFIGURATION 000920 EF?? F??? M goto _casebypass5_6 000924 M _case5_6 000924 0A09 M xorlw 0x09 000926 B4D8 M btfsc STATUS,Z,ACCESS 000928 EF?? F??? M goto _casematch5_6 00092C 0A09 M xorlw 0x09 00092E EF?? F??? M goto _case5_7 000932 M _casematch5_6 000932 0A09 M xorlw 0x09 000934 M _casebypass5_6 00000007 M _casecount ++ 00798 ifl USB_buffer_data+wValue, <=, NUM_CONFIGURATIONS 0000 M variable _ifclausestack0 = _ifclausecount 001B M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 85 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000934 M _if27_0 M if (1 <= 1) && !(0 <= 1) && !(1 <= 0) ; See if relop is == M movf USB_buffer_data+0x02,W,BANKED M sublw 1 M btfss STATUS,Z,ACCESS M else M if (1 <= 0) ; See if relop is !=, >, or >= M if (0 <= 1) ; See if relop is != M movf USB_buffer_data+0x02,W,BANKED M sublw 1 M btfsc STATUS,Z,ACCESS M else M if (1 <= 1) ; See if relop is >= M movlw 1 M subwf USB_buffer_data+0x02,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x02,W,BANKED M sublw 1 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 <= 1) ; See if relop is < or < = M if (1 <= 1) ; See if relop is <= 000934 5100 M movf USB_buffer_data+0x02,W,BANKED 000936 0801 M sublw 1 000938 A0D8 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 1 M subwf USB_buffer_data+0x02,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 00093A EF?? F??? M goto _if27_1 0000001C M _ifcount ++ 00000001 M _ifclausecount ++ 00093E 6A71 00799 clrf UEP1, ACCESS ; clear all EP c ontrol registers except for EP0 to disable EP1-EP15 prior to setting configuration 000940 6A72 00800 clrf UEP2, ACCESS 000942 6A73 00801 clrf UEP3, ACCESS 000944 6A74 00802 clrf UEP4, ACCESS 000946 6A75 00803 clrf UEP5, ACCESS 000948 6A76 00804 clrf UEP6, ACCESS 00094A 6A77 00805 clrf UEP7, ACCESS MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 86 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00094C 6A78 00806 clrf UEP8, ACCESS 00094E 6A79 00807 clrf UEP9, ACCESS 000950 6A7A 00808 clrf UEP10, ACCESS 000952 6A7B 00809 clrf UEP11, ACCESS 000954 6A7C 00810 clrf UEP12, ACCESS 000956 6A7D 00811 clrf UEP13, ACCESS 000958 6A7E 00812 clrf UEP14, ACCESS 00095A 6A7F 00813 clrf UEP15, ACCESS 00095C 5100 00814 movf USB_buffer_data+wValue, W, BANKED 00095E 6F00 00815 movwf USB_curr_config, BANKED 00816 select 0007 M variable _casestack1 = _casecount 000F M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000960 M _select15 000960 EF?? F??? M goto _case15_0 00000010 M _selcount ++ 00817 case 0 000964 EF?? F??? M goto _casebypass15_0 000968 M _case15_0 000968 0A00 M xorlw 0 00096A B4D8 M btfsc STATUS,Z,ACCESS 00096C EF?? F??? M goto _casematch15_0 000970 0A00 M xorlw 0 000972 EF?? F??? M goto _case15_1 000976 M _casematch15_0 000976 0A00 M xorlw 0 000978 M _casebypass15_0 00000001 M _casecount ++ 000978 0E02 00818 movlw ADDRESS_STATE 00097A 6F00 00819 movwf USB_USWSTAT, BANKED 00820 #ifdef SHOW_ENUM_STATUS 00097C 0EE0 00821 movlw 0xE0 00097E 1681 00822 andwf PORTB, F, ACCESS 000980 8481 00823 bsf PORTB, 2, ACCESS 00824 #endif 00825 break 000982 EF?? F??? M goto _endselect15 00826 default ; Place code to initialise the buffer descriptors of enpoints, 000986 M _case15_1 00000002 M _casecount ++ 000986 0E03 00827 movlw CONFIG_STATE ; that are defined with endpoints descriptors at the beginning 000988 6F00 00828 movwf USB_USWSTAT, BANKED 00829 00098A 0104 00830 banksel BD1OBC 00098C 0E08 00831 movlw 0x08 00098E 6F09 00832 movwf BD1OBC, BANKED ; Set EP1 OUT Byte Count register set to 8 000990 0E90 00833 movlw low (USB_Buffer+0x10) ; EP1 OUT gets a buffer...(the previous 16 bytes contain... MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 87 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000992 6F0A 00834 movwf BD1OAL, BANKED ;...EP0 OUT/IN Byte Count registers) 000994 0E04 00835 movlw high (USB_Buffer+0x10) 000996 6F0B 00836 movwf BD1OAH, BANKED ; ...set its address 000998 0EC8 00837 movlw 0xC8 00099A 6F08 00838 movwf BD1OST, BANKED ; set UOWN bit (USB can write EP1 OUT buffer) 00099C 0E08 00839 movlw 0x08 00099E 6F0D 00840 movwf BD1IBC, BANKED ; set EP1 IN byte count to 8 0009A0 0E98 00841 movlw low (USB_Buffer+0x18) ; EP1 IN gets a buffer... 0009A2 6F0E 00842 movwf BD1IAL, BANKED 0009A4 0E04 00843 movlw high (USB_Buffer+0x18) 0009A6 6F0F 00844 movwf BD1IAH, BANKED ; ...set its address 0009A8 0E48 00845 movlw 0x48 0009AA 6F0C 00846 movwf BD1IST, BANKED ; clear UOWN bit (PIC can write EP1 IN buffer) 0009AC 0E1E 00847 movlw ENDPT_NON_CONTROL 0009AE 6E71 00848 movwf UEP1, ACCESS ; Enable EP1 for for in and out tranfers 00849 0009B0 0E40 00850 movlw 0x40 0009B2 6F11 00851 movwf BD2OBC, BANKED ; set EP2 OUT byte count to 64 0009B4 0ED8 00852 movlw low (USB_Buffer+0x58) ; EP2 OUT gets a buffer... 0009B6 6F12 00853 movwf BD2OAL, BANKED 0009B8 0E04 00854 movlw high (USB_Buffer+0x58) 0009BA 6F13 00855 movwf BD2OAH, BANKED ; ...set its address 0009BC 0EC8 00856 movlw 0xC8 0009BE 6F10 00857 movwf BD2OST, BANKED ; clear UOWN bit (PIC can write EP1 IN buffer) 0009C0 0E14 00858 movlw ENDPT_OUT_ONLY 0009C2 6E72 00859 movwf UEP2, ACCESS ; Enable EP2 for for in and out tranfers 00860 00861 #ifdef SHOW_ENUM_STATUS 0009C4 0EE0 00862 movlw 0xE0 0009C6 1681 00863 andwf PORTB, F, ACCESS 0009C8 8681 00864 bsf PORTB, 3, ACCESS 00865 #endif 00866 ends 00000001 M _selstackptr -- 0009CA M _case15_2 0009CA M _endselect15 00000007 M _casecount = _casestack1 0009CA 0104 00867 banksel BD0IBC 0009CC 6B05 00868 clrf BD0IBC, BANKED ; set by te count to 0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 88 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0009CE 0EC8 00869 movlw 0xC8 0009D0 6F04 00870 movwf BD0IST, BANKED ; send p acket as DATA1, set UOWN bit 00871 otherwise 0009D2 EF?? F??? M goto _endif27 0009D6 M _if27_1 00000002 M _ifclausecount ++ 0009D6 8100 00872 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00873 endi 00000000 M _ifstackptr -- 0009D8 M _if27_2 0009D8 M _endif27 00000000 M _ifclausecount = _ifclausestack0 00874 break 0009D8 EF?? F??? M goto _endselect5 00875 case GET_INTERFACE 0009DC EF?? F??? M goto _casebypass5_7 0009E0 M _case5_7 0009E0 0A0A M xorlw 0x0A 0009E2 B4D8 M btfsc STATUS,Z,ACCESS 0009E4 EF?? F??? M goto _casematch5_7 0009E8 0A0A M xorlw 0x0A 0009EA EF?? F??? M goto _case5_8 0009EE M _casematch5_7 0009EE 0A0A M xorlw 0x0A 0009F0 M _casebypass5_7 00000008 M _casecount ++ 0009F0 5100 00876 movf USB_USWSTAT, W, BANKED 00877 select 0008 M variable _casestack1 = _casecount 0010 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 0009F2 M _select16 0009F2 EF?? F??? M goto _case16_0 00000011 M _selcount ++ 00878 case CONFIG_STATE 0009F6 EF?? F??? M goto _casebypass16_0 0009FA M _case16_0 0009FA 0A03 M xorlw 0x03 0009FC B4D8 M btfsc STATUS,Z,ACCESS 0009FE EF?? F??? M goto _casematch16_0 000A02 0A03 M xorlw 0x03 000A04 EF?? F??? M goto _case16_1 000A08 M _casematch16_0 000A08 0A03 M xorlw 0x03 000A0A M _casebypass16_0 00000001 M _casecount ++ 00879 ifl USB_buffer_data+wIndex, <, NUM_INTERFACES 0000 M variable _ifclausestack0 = _ifclausecount 001C M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 89 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000000 M _ifclausecount = 0 000A0A M _if28_0 M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movlw 1 M subwf USB_buffer_data+0x04,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,C,ACCESS M else ; Relop must be < 000A0A 0E01 M movlw 1 000A0C 5D00 M subwf USB_buffer_data+0x04,W,BANKED 000A0E B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000A10 EF?? F??? M goto _if28_1 0000001D M _ifcount ++ 00000001 M _ifclausecount ++ 000A14 0104 00880 banksel BD0IAH 000A16 5107 00881 movf BD0IAH, W, BANKED 000A18 6EEA 00882 movwf FSR0H, ACCESS 000A1A 5106 00883 movf BD0IAL, W, BANKED ; get buffer pointer 000A1C 6EE9 00884 movwf FSR0L, ACCESS 000A1E 6AEF 00885 clrf INDF0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 90 LOC OBJECT CODE LINE SOURCE TEXT VALUE ; always send back 0 for bAlternateSetting 000A20 0E01 00886 movlw 0x01 000A22 6F05 00887 movwf BD0IBC, BANKED ; set byte count to 1 000A24 0EC8 00888 movlw 0xC8 000A26 6F04 00889 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00890 otherwise 000A28 EF?? F??? M goto _endif28 000A2C M _if28_1 00000002 M _ifclausecount ++ 000A2C 8100 00891 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00892 endi 00000000 M _ifstackptr -- 000A2E M _if28_2 000A2E M _endif28 00000000 M _ifclausecount = _ifclausestack0 00893 break 000A2E EF?? F??? M goto _endselect16 00894 default 000A32 M _case16_1 00000002 M _casecount ++ 000A32 8100 00895 bsf USB_error_flags, 0, BANK ED ; set Request Error flag 00896 ends 00000001 M _selstackptr -- 000A34 M _case16_2 000A34 M _endselect16 00000008 M _casecount = _casestack1 00897 break 000A34 EF?? F??? M goto _endselect5 00898 case SET_INTERFACE 000A38 EF?? F??? M goto _casebypass5_8 000A3C M _case5_8 000A3C 0A0B M xorlw 0x0B 000A3E B4D8 M btfsc STATUS,Z,ACCESS 000A40 EF?? F??? M goto _casematch5_8 000A44 0A0B M xorlw 0x0B 000A46 EF?? F??? M goto _case5_9 000A4A M _casematch5_8 000A4A 0A0B M xorlw 0x0B 000A4C M _casebypass5_8 00000009 M _casecount ++ 000A4C 5100 00899 movf USB_USWSTAT, W, BANKED 00900 select 0009 M variable _casestack1 = _casecount 0011 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000A4E M _select17 000A4E EF?? F??? M goto _case17_0 00000012 M _selcount ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 91 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00901 case CONFIG_STATE 000A52 EF?? F??? M goto _casebypass17_0 000A56 M _case17_0 000A56 0A03 M xorlw 0x03 000A58 B4D8 M btfsc STATUS,Z,ACCESS 000A5A EF?? F??? M goto _casematch17_0 000A5E 0A03 M xorlw 0x03 000A60 EF?? F??? M goto _case17_1 000A64 M _casematch17_0 000A64 0A03 M xorlw 0x03 000A66 M _casebypass17_0 00000001 M _casecount ++ 00902 ifl USB_buffer_data+wIndex, <, NUM_INTERFACES 0000 M variable _ifclausestack0 = _ifclausecount 001D M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000A66 M _if29_0 M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movlw 1 M subwf USB_buffer_data+0x04,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_buffer_data+0x04,W,BANKED M sublw 1 M btfss STATUS,C,ACCESS M else ; Relop must be < 000A66 0E01 M movlw 1 000A68 5D00 M subwf USB_buffer_data+0x04,W,BANKED 000A6A B0D8 M btfsc STATUS,C,ACCESS MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 92 LOC OBJECT CODE LINE SOURCE TEXT VALUE M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000A6C EF?? F??? M goto _if29_1 0000001E M _ifcount ++ 00000001 M _ifclausecount ++ 000A70 5100 00903 movf USB_buffer_data+wValue, W, BANKED 00904 select 0001 M variable _casestack2 = _casecount 0012 M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 000A72 M _select18 000A72 EF?? F??? M goto _case18_0 00000013 M _selcount ++ 00905 case 0 ; currently support only bAlternateSetting of 0 000A76 EF?? F??? M goto _casebypass18_0 000A7A M _case18_0 000A7A 0A00 M xorlw 0 000A7C B4D8 M btfsc STATUS,Z,ACCESS 000A7E EF?? F??? M goto _casematch18_0 000A82 0A00 M xorlw 0 000A84 EF?? F??? M goto _case18_1 000A88 M _casematch18_0 000A88 0A00 M xorlw 0 000A8A M _casebypass18_0 00000001 M _casecount ++ 000A8A 0104 00906 banksel BD0IBC 000A8C 6B05 00907 clrf BD0IBC, BANKED ; set byte count to 0 000A8E 0EC8 00908 movlw 0xC8 000A90 6F04 00909 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00910 break 000A92 EF?? F??? M goto _endselect18 00911 default 000A96 M _case18_1 00000002 M _casecount ++ 000A96 8100 00912 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00913 ends 00000002 M _selstackptr -- 000A98 M _case18_2 000A98 M _endselect18 00000001 M _casecount = _casestack2 00914 otherwise 000A98 EF?? F??? M goto _endif29 000A9C M _if29_1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 93 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000002 M _ifclausecount ++ 000A9C 8100 00915 bsf USB_error_flags, 0, BANKED ; set Request Error flag 00916 endi 00000000 M _ifstackptr -- 000A9E M _if29_2 000A9E M _endif29 00000000 M _ifclausecount = _ifclausestack0 00917 break 000A9E EF?? F??? M goto _endselect17 00918 default 000AA2 M _case17_1 00000002 M _casecount ++ 000AA2 8100 00919 bsf USB_error_flags, 0, BANK ED ; set Request Error flag 00920 ends 00000001 M _selstackptr -- 000AA4 M _case17_2 000AA4 M _endselect17 00000009 M _casecount = _casestack1 00921 break 000AA4 EF?? F??? M goto _endselect5 00922 case SET_DESCRIPTOR 000AA8 EF?? F??? M goto _casebypass5_9 000AAC M _case5_9 000AAC 0A07 M xorlw 0x07 000AAE B4D8 M btfsc STATUS,Z,ACCESS 000AB0 EF?? F??? M goto _casematch5_9 000AB4 0A07 M xorlw 0x07 000AB6 EF?? F??? M goto _case5_10 000ABA M _casematch5_9 000ABA 0A07 M xorlw 0x07 000ABC M _casebypass5_9 0000000A M _casecount ++ 00923 case SYNCH_FRAME 000ABC EF?? F??? M goto _casebypass5_10 000AC0 M _case5_10 000AC0 0A0C M xorlw 0x0C 000AC2 B4D8 M btfsc STATUS,Z,ACCESS 000AC4 EF?? F??? M goto _casematch5_10 000AC8 0A0C M xorlw 0x0C 000ACA EF?? F??? M goto _case5_11 000ACE M _casematch5_10 000ACE 0A0C M xorlw 0x0C 000AD0 M _casebypass5_10 0000000B M _casecount ++ 00924 default 000AD0 M _case5_11 0000000C M _casecount ++ 000AD0 8100 00925 bsf USB_error_flags, 0, BANKED ; set Re quest Error flag 00926 break 000AD2 EF?? F??? M goto _endselect5 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 94 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00927 ends 00000000 M _selstackptr -- 000AD6 M _case5_12 000AD6 M _endselect5 00000000 M _casecount = _casestack0 000AD6 0012 00928 return 00929 000AD8 00930 ClassRequests 000AD8 5100 00931 movf USB_buffer_data+bRequest, W, BANKED 00932 select 0000 M variable _casestack0 = _casecount 0013 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 000ADA M _select19 000ADA EF?? F??? M goto _case19_0 00000014 M _selcount ++ 00933 default 000ADE M _case19_0 00000001 M _casecount ++ 000ADE 8100 00934 bsf USB_error_flags, 0, BANKED ; set Re quest Error flag 00935 ends 00000000 M _selstackptr -- 000AE0 M _case19_1 000AE0 M _endselect19 00000000 M _casecount = _casestack0 000AE0 0012 00936 return 00937 000AE2 00938 VendorRequests 000AE2 5100 00939 movf USB_buffer_data+bRequest, W, BANKED 00940 select 0000 M variable _casestack0 = _casecount 0014 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 000AE4 M _select20 000AE4 EF?? F??? M goto _case20_0 00000015 M _selcount ++ 00941 case SET_RA0 000AE8 EF?? F??? M goto _casebypass20_0 000AEC M _case20_0 000AEC 0A01 M xorlw 0x01 000AEE B4D8 M btfsc STATUS,Z,ACCESS 000AF0 EF?? F??? M goto _casematch20_0 000AF4 0A01 M xorlw 0x01 000AF6 EF?? F??? M goto _case20_1 000AFA M _casematch20_0 000AFA 0A01 M xorlw 0x01 000AFC M _casebypass20_0 00000001 M _casecount ++ 000AFC 8080 00942 bsf PORTA, 0, ACCESS ; set RA 0 high MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 95 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000AFE 0104 00943 banksel BD0IBC 000B00 6B05 00944 clrf BD0IBC, BANKED ; set byte count to 0 000B02 0EC8 00945 movlw 0xC8 000B04 6F04 00946 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00947 break 000B06 EF?? F??? M goto _endselect20 00948 case CLR_RA0 000B0A EF?? F??? M goto _casebypass20_1 000B0E M _case20_1 000B0E 0A02 M xorlw 0x02 000B10 B4D8 M btfsc STATUS,Z,ACCESS 000B12 EF?? F??? M goto _casematch20_1 000B16 0A02 M xorlw 0x02 000B18 EF?? F??? M goto _case20_2 000B1C M _casematch20_1 000B1C 0A02 M xorlw 0x02 000B1E M _casebypass20_1 00000002 M _casecount ++ 000B1E 9080 00949 bcf PORTA, 0, ACCESS ; set RA 0 low 000B20 0104 00950 banksel BD0IBC 000B22 6B05 00951 clrf BD0IBC, BANKED ; set byte count to 0 000B24 0EC8 00952 movlw 0xC8 000B26 6F04 00953 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 00954 break 000B28 EF?? F??? M goto _endselect20 00955 default 000B2C M _case20_2 00000003 M _casecount ++ 000B2C 8100 00956 bsf USB_error_flags, 0, BANKED ; set Re quest Error flag 00957 ends 00000000 M _selstackptr -- 000B2E M _case20_3 000B2E M _endselect20 00000000 M _casecount = _casestack0 000B2E 0012 00958 return 00959 000B30 00960 ProcessInToken 000B30 010? 00961 banksel USB_USTAT 000B32 5100 00962 movf USB_USTAT, W, BANKED 000B34 0B18 00963 andlw 0x18 ; extract the EP bits 00964 select 0000 M variable _casestack0 = _casecount 0015 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 000B36 M _select21 000B36 EF?? F??? M goto _case21_0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 96 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000016 M _selcount ++ 00965 case EP0 000B3A EF?? F??? M goto _casebypass21_0 000B3E M _case21_0 000B3E 0A00 M xorlw 0x00 << 3 000B40 B4D8 M btfsc STATUS,Z,ACCESS 000B42 EF?? F??? M goto _casematch21_0 000B46 0A00 M xorlw 0x00 << 3 000B48 EF?? F??? M goto _case21_1 000B4C M _casematch21_0 000B4C 0A00 M xorlw 0x00 << 3 000B4E M _casebypass21_0 00000001 M _casecount ++ 000B4E 5100 00966 movf USB_dev_req, W, BANKED 00967 select 0001 M variable _casestack1 = _casecount 0016 M variable _selstack1 = _selcount 00000002 M _selstackptr ++ 00000000 M _casecount = 0 000B50 M _select22 000B50 EF?? F??? M goto _case22_0 00000017 M _selcount ++ 00968 case SET_ADDRESS 000B54 EF?? F??? M goto _casebypass22_0 000B58 M _case22_0 000B58 0A05 M xorlw 0x05 000B5A B4D8 M btfsc STATUS,Z,ACCESS 000B5C EF?? F??? M goto _casematch22_0 000B60 0A05 M xorlw 0x05 000B62 EF?? F??? M goto _case22_1 000B66 M _casematch22_0 000B66 0A05 M xorlw 0x05 000B68 M _casebypass22_0 00000001 M _casecount ++ 000B68 5100 00969 movf USB_address_pending, W, BANKED 000B6A 6E6E 00970 movwf UADDR, ACCESS 00971 select 0001 M variable _casestack2 = _casecount 0017 M variable _selstack2 = _selcount 00000003 M _selstackptr ++ 00000000 M _casecount = 0 000B6C M _select23 000B6C EF?? F??? M goto _case23_0 00000018 M _selcount ++ 00972 case 0 000B70 EF?? F??? M goto _casebypass23_0 000B74 M _case23_0 000B74 0A00 M xorlw 0 000B76 B4D8 M btfsc STATUS,Z,ACCESS 000B78 EF?? F??? M goto _casematch23_0 000B7C 0A00 M xorlw 0 000B7E EF?? F??? M goto _case23_1 000B82 M _casematch23_0 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 97 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000B82 0A00 M xorlw 0 000B84 M _casebypass23_0 00000001 M _casecount ++ 000B84 0E01 00973 movlw DEFAULT_STATE 000B86 6F00 00974 movwf USB_USWSTAT, BAN KED 00975 #ifdef SHOW_ENUM_STATUS 000B88 0EE0 00976 movlw 0xE0 000B8A 1681 00977 andwf PORTB, F, ACCESS 000B8C 8281 00978 bsf PORTB, 1 , ACCESS 00979 #endif 00980 break 000B8E EF?? F??? M goto _endselect23 00981 default 000B92 M _case23_1 00000002 M _casecount ++ 000B92 0E02 00982 movlw ADDRESS_STATE 000B94 6F00 00983 movwf USB_USWSTAT, BAN KED 00984 #ifdef SHOW_ENUM_STATUS 000B96 0EE0 00985 movlw 0xE0 000B98 1681 00986 andwf PORTB, F, ACCESS 000B9A 8481 00987 bsf PORTB, 2 , ACCESS 00988 #endif 00989 ends 00000002 M _selstackptr -- 000B9C M _case23_2 000B9C M _endselect23 00000001 M _casecount = _casestack2 00990 break 000B9C EF?? F??? M goto _endselect22 00991 case GET_DESCRIPTOR 000BA0 EF?? F??? M goto _casebypass22_1 000BA4 M _case22_1 000BA4 0A06 M xorlw 0x06 000BA6 B4D8 M btfsc STATUS,Z,ACCESS 000BA8 EF?? F??? M goto _casematch22_1 000BAC 0A06 M xorlw 0x06 000BAE EF?? F??? M goto _case22_2 000BB2 M _casematch22_1 000BB2 0A06 M xorlw 0x06 000BB4 M _casebypass22_1 00000002 M _casecount ++ 000BB4 EC?? F??? 00992 call SendDescriptorPacket 00993 break 000BB8 EF?? F??? M goto _endselect22 00994 ends 00000001 M _selstackptr -- 000BBC M _case22_2 000BBC M _endselect22 00000001 M _casecount = _casestack1 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 98 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00995 break 000BBC EF?? F??? M goto _endselect21 00996 case EP1 000BC0 EF?? F??? M goto _casebypass21_1 000BC4 M _case21_1 000BC4 0A08 M xorlw 0x01 << 3 000BC6 B4D8 M btfsc STATUS,Z,ACCESS 000BC8 EF?? F??? M goto _casematch21_1 000BCC 0A08 M xorlw 0x01 << 3 000BCE EF?? F??? M goto _case21_2 000BD2 M _casematch21_1 000BD2 0A08 M xorlw 0x01 << 3 000BD4 M _casebypass21_1 00000002 M _casecount ++ 00997 break 000BD4 EF?? F??? M goto _endselect21 00998 case EP2 000BD8 EF?? F??? M goto _casebypass21_2 000BDC M _case21_2 000BDC 0A10 M xorlw 0x02 << 3 000BDE B4D8 M btfsc STATUS,Z,ACCESS 000BE0 EF?? F??? M goto _casematch21_2 000BE4 0A10 M xorlw 0x02 << 3 000BE6 EF?? F??? M goto _case21_3 000BEA M _casematch21_2 000BEA 0A10 M xorlw 0x02 << 3 000BEC M _casebypass21_2 00000003 M _casecount ++ 00999 break 000BEC EF?? F??? M goto _endselect21 01000 ends 00000000 M _selstackptr -- 000BF0 M _case21_3 000BF0 M _endselect21 00000000 M _casecount = _casestack0 000BF0 0012 01001 return 01002 000BF2 01003 ProcessOutToken 000BF2 010? 01004 banksel USB_USTAT 000BF4 5100 01005 movf USB_USTAT, W, BANKED 000BF6 0B18 01006 andlw 0x18 ; extract the EP bits 01007 select 0000 M variable _casestack0 = _casecount 0018 M variable _selstack0 = _selcount 00000001 M _selstackptr ++ 00000000 M _casecount = 0 000BF8 M _select24 000BF8 EF?? F??? M goto _case24_0 00000019 M _selcount ++ 01008 case EP0 000BFC EF?? F??? M goto _casebypass24_0 000C00 M _case24_0 000C00 0A00 M xorlw 0x00 << 3 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 99 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000C02 B4D8 M btfsc STATUS,Z,ACCESS 000C04 EF?? F??? M goto _casematch24_0 000C08 0A00 M xorlw 0x00 << 3 000C0A EF?? F??? M goto _case24_1 000C0E M _casematch24_0 000C0E 0A00 M xorlw 0x00 << 3 000C10 M _casebypass24_0 00000001 M _casecount ++ 000C10 0104 01009 banksel BD0OBC 000C12 0E08 01010 movlw MAX_PACKET_SIZE 000C14 6F01 01011 movwf BD0OBC, BANKED 000C16 0E88 01012 movlw 0x88 000C18 6F00 01013 movwf BD0OST, BANKED 000C1A 6B05 01014 clrf BD0IBC, BANKED ; set byte count to 0 000C1C 0EC8 01015 movlw 0xC8 000C1E 6F04 01016 movwf BD0IST, BANKED ; send packet as DATA1, set UOWN bit 01017 break 000C20 EF?? F??? M goto _endselect24 01018 case EP1 000C24 EF?? F??? M goto _casebypass24_1 000C28 M _case24_1 000C28 0A08 M xorlw 0x01 << 3 000C2A B4D8 M btfsc STATUS,Z,ACCESS 000C2C EF?? F??? M goto _casematch24_1 000C30 0A08 M xorlw 0x01 << 3 000C32 EF?? F??? M goto _case24_2 000C36 M _casematch24_1 000C36 0A08 M xorlw 0x01 << 3 000C38 M _casebypass24_1 00000002 M _casecount ++ 000C38 0EFF 01019 movlw NO_REQUEST 000C3A 6F00 01020 movwf USB_dev_req, BANKED ; clear device request 000C3C 7281 01021 BTG PORTB,1,ACCESS 000C3E 0104 01022 banksel BD1OBC 000C40 0E08 01023 movlw 0x08 000C42 6F09 01024 movwf BD1OBC, BANKED 000C44 0E88 01025 movlw 0x88 000C46 6F08 01026 movwf BD1OST, BANKED 000C48 6B05 01027 clrf BD0IBC,BANKED ; set byte count to 0 000C4A 0EC8 01028 movlw 0xc8 000C4C 6F04 01029 movwf BD0IST,BANKED ; set owns bit 01030 01031 break 000C4E EF?? F??? M goto _endselect24 01032 case EP2 000C52 EF?? F??? M goto _casebypass24_2 000C56 M _case24_2 000C56 0A10 M xorlw 0x02 << 3 000C58 B4D8 M btfsc STATUS,Z,ACCESS 000C5A EF?? F??? M goto _casematch24_2 000C5E 0A10 M xorlw 0x02 << 3 000C60 EF?? F??? M goto _case24_3 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 100 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000C64 M _casematch24_2 000C64 0A10 M xorlw 0x02 << 3 000C66 M _casebypass24_2 00000003 M _casecount ++ 01033 break 000C66 EF?? F??? M goto _endselect24 01034 ends 00000000 M _selstackptr -- 000C6A M _case24_3 000C6A M _endselect24 00000000 M _casecount = _casestack0 000C6A 0012 01035 return 01036 000C6C 01037 SendDescriptorPacket 000C6C 010? 01038 banksel USB_bytes_left 01039 ifl USB_bytes_left, <, MAX_PACKET_SIZE 0000 M variable _ifclausestack0 = _ifclausecount 001E M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000C6E M _if30_0 M if (1 < 1) && !(0 < 1) && !(1 < 0) ; See if relop is == M movf USB_bytes_left,W,BANKED M sublw 8 M btfss STATUS,Z,ACCESS M else M if (1 < 0) ; See if relop is !=, >, or >= M if (0 < 1) ; See if relop is != M movf USB_bytes_left,W,BANKED M sublw 8 M btfsc STATUS,Z,ACCESS M else M if (1 < 1) ; See if relop is >= M movlw 8 M subwf USB_bytes_left,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_bytes_left,W,BANKED M sublw 8 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 < 1) ; See if relop is < or < = M if (1 < 1) ; See if relop is <= M movf USB_bytes_left,W,BANKED M sublw 8 M btfss STATUS,C,ACCESS M else ; Relop must be < MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 101 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000C6E 0E08 M movlw 8 000C70 5D00 M subwf USB_bytes_left,W,BANKED 000C72 B0D8 M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in ifl statement." M endif M endif M endif 000C74 EF?? F??? M goto _if30_1 0000001F M _ifcount ++ 00000001 M _ifclausecount ++ 000C78 0EFF 01040 movlw NO_REQUEST 000C7A 6F00 01041 movwf USB_dev_req, BANKED ; sending a short packet , so clear device request 000C7C 5100 01042 movf USB_bytes_left, W, BANKED 01043 otherwise 000C7E EF?? F??? M goto _endif30 000C82 M _if30_1 00000002 M _ifclausecount ++ 000C82 0E08 01044 movlw MAX_PACKET_SIZE 01045 endi 00000000 M _ifstackptr -- 000C84 M _if30_2 000C84 M _endif30 00000000 M _ifclausecount = _ifclausestack0 000C84 5F00 01046 subwf USB_bytes_left, F, BANKED 000C86 6F00 01047 movwf USB_packet_length, BANKED 000C88 0104 01048 banksel BD0IBC 000C8A 6F05 01049 movwf BD0IBC, BANKED ; set EP0 IN byte count with pac ket size 000C8C 5107 01050 movf BD0IAH, W, BANKED ; put EP0 IN buffer pointer... 000C8E 6EEA 01051 movwf FSR0H, ACCESS 000C90 5106 01052 movf BD0IAL, W, BANKED 000C92 6EE9 01053 movwf FSR0L, ACCESS ; ...into FSR0 000C94 010? 01054 banksel USB_loop_index 01055 forlf USB_loop_index, 1, USB_packet_length 000C96 0E01 M movlw 1 000C98 6F00 M movwf USB_loop_index,BANKED 000C9A M _for0 000C9A 5100 M movf USB_loop_index,W,BANKED 000C9C 5D00 M subwf USB_packet_length,W,BANKED 000C9E A0D8 M btfss STATUS,C,ACCESS 000CA0 EF?? F??? M goto _next0 0000 M variable _forstack0 = _forcount 00000001 M _forstackptr ++ 00000001 M _forcount ++ 000CA4 EC?? F??? 01056 call Descriptor ; get next byte of descr iptor being sent 000CA8 6EEE 01057 movwf POSTINC0 ; copy to EP0 IN buffer, and increment FSR0 000CAA 2B00 01058 incf USB_desc_ptr, F, BANKED ; increment the descriptor point er MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 102 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01059 next USB_loop_index 00000000 M _forstackptr -- 000CAC 2B00 M incf USB_loop_index,F,BANKED 000CAE EF?? F??? M goto _for0 000CB2 M _next0 000CB2 0104 01060 banksel BD0IST 000CB4 0E40 01061 movlw 0x40 000CB6 1904 01062 xorwf BD0IST, W, BANKED ; toggle the DATA01 bit 000CB8 0B40 01063 andlw 0x40 ; clear the PIDs bits 000CBA 0988 01064 iorlw 0x88 ; set UOWN and DTS bits 000CBC 6F04 01065 movwf BD0IST, BANKED 000CBE 0012 01066 return 01067 01068 APPLICATION code 000000 01069 Main 000000 EC?? F??? 01070 call InitPorts 000004 EC?? F??? 01071 call InitUSB ; initialize the USB reg isters and serial interface engine 01072 000008 0E20 01073 movlw b'00100000' 00000A 6EA0 01074 movwf PIE2, ACCESS ; Enable USB interrupt 00000C 0E7F 01075 movlw b'01111111' 00000E 6E69 01076 movwf UIE ; Enable all USB interrupts 000010 0E9F 01077 movlw b'10011111' 000012 6E6B 01078 movwf UEIE ; Enable all USB error i nterrupts 000014 0EC0 01079 movlw b'11000000' 000016 6EF2 01080 movwf INTCON, ACCESS ; Enable all interrupts and all unmasked peripheral interrupts 01081 01082 repeat 000018 M _repeat1 0001 M variable _rptstack0 = _rptcount 00000001 M _rptstackptr ++ 00000002 M _rptcount ++ 000018 0000 01083 nop 00001A 010? 01084 banksel USB_USWSTAT 01085 until USB_USWSTAT, ==, CONFIG_STATE ; ...until the host configures t he peripheral 00000000 M _rptstackptr -- M if (1 == 1) && !(0 == 1) && !(1 == 0) ; See if relop is == 00001C 5100 M movf USB_USWSTAT,W,BANKED 00001E 0803 M sublw 0x03 000020 A4D8 M btfss STATUS,Z,ACCESS M else M if (1 == 0) ; See if relop is !=, >, or >= M if (0 == 1) ; See if relop is != M movf USB_USWSTAT,W,BANKED M sublw 0x03 M btfsc STATUS,Z,ACCESS MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 103 LOC OBJECT CODE LINE SOURCE TEXT VALUE M else M if (1 == 1) ; See if relop is >= M movlw 0x03 M subwf USB_USWSTAT,W,BANKED M btfss STATUS,C,ACCESS M else ; Relop must be > M movf USB_USWSTAT,W,BANKED M sublw 0x03 M btfsc STATUS,C,ACCESS M endif M endif M else M if (0 == 1) ; See if relop is < or < = M if (1 == 1) ; See if relop is <= M movf USB_USWSTAT,W,BANKED M sublw 0x03 M btfss STATUS,C,ACCESS M else ; Relop must be < M movlw 0x03 M subwf USB_USWSTAT,W,BANKED M btfsc STATUS,C,ACCESS M endif M else M error "Illegal relational operator in until statement." M endif M endif M endif 000022 EF?? F??? M goto _repeat1 000026 M _endrepeat1 01086 000026 8080 01087 bsf PORTA, 0, ACCESS ; set RA0 high 000028 010? 01088 banksel COUNTER_L 00002A 6B00 01089 clrf COUNTER_L, BANKED 00002C 6B00 01090 clrf COUNTER_H, BANKED 01091 repeat 00002E M _repeat2 0002 M variable _rptstack0 = _rptcount 00000001 M _rptstackptr ++ 00000003 M _rptcount ++ 00002E 010? 01092 banksel COUNTER_L 000030 2B00 01093 incf COUNTER_L, F, BANKED 01094 ifset STATUS, Z, ACCESS 0000 M variable _ifclausestack0 = _ifclausecount 001F M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 000032 M _if31_0 000032 A4D8 M btfss STATUS,Z,ACCESS 000034 EF?? F??? M goto _if31_1 00000020 M _ifcount ++ MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 104 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000001 M _ifclausecount ++ 000038 2B00 01095 incf COUNTER_H, F, BANKED 01096 endi 00000000 M _ifstackptr -- 00003A M _if31_1 00003A M _endif31 00000000 M _ifclausecount = _ifclausestack0 01097 ifset COUNTER_H, 7, BANKED 0000 M variable _ifclausestack0 = _ifclausecount 0020 M variable _ifstack0 = _ifcount 00000001 M _ifstackptr ++ 00000000 M _ifclausecount = 0 00003A M _if32_0 00003A AF00 M btfss COUNTER_H,7,BANKED 00003C EF?? F??? M goto _if32_1 00000021 M _ifcount ++ 00000001 M _ifclausecount ++ 000040 9280 01098 bcf PORTA, 1, ACCESS 000042 9283 01099 bcf PORTD, 1, ACCESS 01100 otherwise 000044 EF?? F??? M goto _endif32 000048 M _if32_1 00000002 M _ifclausecount ++ 000048 8280 01101 bsf PORTA, 1, ACCESS 00004A 8283 01102 bsf PORTD, 1, ACCESS 01103 endi 00000000 M _ifstackptr -- 00004C M _if32_2 00004C M _endif32 00000000 M _ifclausecount = _ifclausestack0 00004C 0000 01104 nop 01105 forever 00000000 M _rptstackptr -- 00004E EF?? F??? M goto _repeat2 000052 M _endrepeat2 01106 000052 01107 InitPorts 000052 6A80 01108 clrf PORTA, ACCESS ; ACCESS:Access Bank mode is sel ected 000054 6A83 01109 clrf PORTD, ACCESS 000056 0E0F 01110 movlw 0x0F 000058 6EC1 01111 movwf ADCON1, ACCESS ; set up PORTA to be digital I/O s 00005A 6A92 01112 clrf TRISA, ACCESS ; set up all PORTA pins to be di gital outputs 00005C 6A95 01113 clrf TRISD, ACCESS 00005E 0012 01114 return 01115 01116 01117 end MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 105 SYMBOL TABLE LABEL VALUE A 00000000 ABDEN 00000000 ABDOVF 00000007 ACCESS 00000000 ACKDT 00000005 ACKEN 00000004 ACKSTAT 00000006 ACQT0 00000003 ACQT1 00000004 ACQT2 00000005 ACTVIE 00000002 ACTVIF 00000002 ADCON0 00000FC2 ADCON1 00000FC1 ADCON2 00000FC0 ADCS0 00000000 ADCS1 00000001 ADCS2 00000002 ADDEN 00000003 ADDR0 00000000 ADDR1 00000001 ADDR2 00000002 ADDR3 00000003 ADDR4 00000004 ADDR5 00000005 ADDR6 00000006 ADDRESSH 0x03 ADDRESSL 0x02 ADDRESS_STATE 0x02 ADEN 00000003 ADFM 00000007 ADIE 00000006 ADIF 00000006 ADIP 00000006 ADON 00000000 ADRES 00000FC3 ADRESH 00000FC4 ADRESL 00000FC3 AN0 00000000 AN1 00000001 AN2 00000002 AN3 00000003 AN4 00000005 BANKED 00000001 BAUDCON 00000FB8 BCLIE 00000003 BCLIF 00000003 BCLIP 00000003 BD0IAH 0x0407 BD0IAL 0x0406 BD0IBC 0x0405 BD0IST 0x0404 BD0OAH 0x0403 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 106 SYMBOL TABLE LABEL VALUE BD0OAL 0x0402 BD0OBC 0x0401 BD0OST 0x0400 BD10IAH 0x0457 BD10IAL 0x0456 BD10IBC 0x0455 BD10IST 0x0454 BD10OAH 0x0453 BD10OAL 0x0452 BD10OBC 0x0451 BD10OST 0x0450 BD11IAH 0x045F BD11IAL 0x045E BD11IBC 0x045D BD11IST 0x045C BD11OAH 0x045B BD11OAL 0x045A BD11OBC 0x0459 BD11OST 0x0458 BD12IAH 0x0467 BD12IAL 0x0466 BD12IBC 0x0465 BD12IST 0x0464 BD12OAH 0x0463 BD12OAL 0x0462 BD12OBC 0x0461 BD12OST 0x0460 BD13IAH 0x046F BD13IAL 0x046E BD13IBC 0x046D BD13IST 0x046C BD13OAH 0x046B BD13OAL 0x046A BD13OBC 0x0469 BD13OST 0x0468 BD14IAH 0x0477 BD14IAL 0x0476 BD14IBC 0x0475 BD14IST 0x0474 BD14OAH 0x0473 BD14OAL 0x0472 BD14OBC 0x0471 BD14OST 0x0470 BD15IAH 0x047F BD15IAL 0x047E BD15IBC 0x047D BD15IST 0x047C BD15OAH 0x047B BD15OAL 0x047A BD15OBC 0x0479 BD15OST 0x0478 BD1IAH 0x040F BD1IAL 0x040E MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 107 SYMBOL TABLE LABEL VALUE BD1IBC 0x040D BD1IST 0x040C BD1OAH 0x040B BD1OAL 0x040A BD1OBC 0x0409 BD1OST 0x0408 BD2IAH 0x0417 BD2IAL 0x0416 BD2IBC 0x0415 BD2IST 0x0414 BD2OAH 0x0413 BD2OAL 0x0412 BD2OBC 0x0411 BD2OST 0x0410 BD3IAH 0x041F BD3IAL 0x041E BD3IBC 0x041D BD3IST 0x041C BD3OAH 0x041B BD3OAL 0x041A BD3OBC 0x0419 BD3OST 0x0418 BD4IAH 0x0427 BD4IAL 0x0426 BD4IBC 0x0425 BD4IST 0x0424 BD4OAH 0x0423 BD4OAL 0x0422 BD4OBC 0x0421 BD4OST 0x0420 BD5IAH 0x042F BD5IAL 0x042E BD5IBC 0x042D BD5IST 0x042C BD5OAH 0x042B BD5OAL 0x042A BD5OBC 0x0429 BD5OST 0x0428 BD6IAH 0x0437 BD6IAL 0x0436 BD6IBC 0x0435 BD6IST 0x0434 BD6OAH 0x0433 BD6OAL 0x0432 BD6OBC 0x0431 BD6OST 0x0430 BD7IAH 0x043F BD7IAL 0x043E BD7IBC 0x043D BD7IST 0x043C BD7OAH 0x043B BD7OAL 0x043A BD7OBC 0x0439 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 108 SYMBOL TABLE LABEL VALUE BD7OST 0x0438 BD8IAH 0x0447 BD8IAL 0x0446 BD8IBC 0x0445 BD8IST 0x0444 BD8OAH 0x0443 BD8OAL 0x0442 BD8OBC 0x0441 BD8OST 0x0440 BD9IAH 0x044F BD9IAL 0x044E BD9IBC 0x044D BD9IST 0x044C BD9OAH 0x044B BD9OAL 0x044A BD9OBC 0x0449 BD9OST 0x0448 BF 00000000 BGST 00000005 BOR 00000000 BRG16 00000003 BRGH 00000002 BSR 00000FE0 BTOEE 00000004 BTOEF 00000004 BTSEE 00000007 BTSEF 00000007 BULK 0x02 BYTECOUNT 0x01 C 00000000 C1INV 00000004 C1OUT 00000006 C2INV 00000005 C2OUT 00000007 CCP1 00000002 CCP1AS 00000FB6 CCP1CON 00000FBD CCP1DEL 00000FB7 CCP1IE 00000002 CCP1IF 00000002 CCP1IP 00000002 CCP1M0 00000000 CCP1M1 00000001 CCP1M2 00000002 CCP1M3 00000003 CCP2CON 00000FBA CCP2IE 00000000 CCP2IF 00000000 CCP2IP 00000000 CCP2M0 00000000 CCP2M1 00000001 CCP2M2 00000002 CCP2M3 00000003 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 109 SYMBOL TABLE LABEL VALUE CCPR1 00000FBE CCPR1H 00000FBF CCPR1L 00000FBE CCPR2 00000FBB CCPR2H 00000FBC CCPR2L 00000FBB CFGS 00000006 CHS0 00000002 CHS1 00000003 CHS2 00000004 CHS3 00000005 CIS 00000003 CK 00000006 CK1SPP 00000000 CK2SPP 00000001 CKE 00000006 CKP 00000004 CLASS 0x01 << 5 CLEARFEATURE 0x0B << 2 CLEAR_FEATURE 0x01 CLK1EN 00000004 CLKCFG0 00000006 CLKCFG1 00000007 CLR_RA0 0x02 CM0 00000000 CM1 00000001 CM2 00000002 CMCON 00000FB4 CMIE 00000006 CMIF 00000006 CMIP 00000006 CONFIGURATION 2 CONFIG_STATE 0x03 CONTROL 0x00 COPYDESC2EP0 0x15 << 2 COPYSTRINGDESC2EP0 0x16 << 2 COUNTER_H 00000018 COUNTER_L 00000017 CRC16EE 00000002 CRC16EF 00000002 CRC5EE 00000001 CRC5EF 00000001 CREN 00000004 CSEN 00000005 CSRC 00000007 CVR0 00000000 CVR1 00000001 CVR2 00000002 CVR3 00000003 CVRCON 00000FB5 CVREF 00000004 CVREN 00000007 CVROE 00000006 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 110 SYMBOL TABLE LABEL VALUE CVRR 00000005 CVRSS 00000004 ClassRequests 00000AD8 Configuration1 00000038 D 00000005 DATA_ADDRESS 00000005 DC 00000001 DC1B0 00000004 DC1B1 00000005 DC2B0 00000004 DC2B1 00000005 DDRA TRISA DDRB TRISB DDRC TRISC DDRD TRISD DDRE TRISE DEFAULT_STATE 0x01 DEVICE 1 DEVICE_REMOTE_WAKEUP 0x01 DFN8EE 00000003 DFN8EF 00000003 DIR 00000002 DONE 00000001 D_A 00000005 Descriptor 00000000 Descriptor_begin 00000026 Descriptor_end 000000D4 Device 00000026 ECCP1AS 00000FB6 ECCP1CON 00000FBD ECCP1DEL 00000FB7 ECCPAS0 00000004 ECCPAS1 00000005 ECCPAS2 00000006 ECCPASE 00000007 EEADR 00000FA9 EECON1 00000FA6 EECON2 00000FA7 EEDATA 00000FA8 EEIE 00000004 EEIF 00000004 EEIP 00000004 EEPGD 00000007 ENDP0 00000003 ENDP1 00000004 ENDP1IN 00000052 ENDP1OUT 0000004A ENDP2 00000005 ENDP2OUT 00000058 ENDP3 00000006 ENDPOINT 5 ENDPOINT_HALT 0x00 ENDPT_CONTROL 0x16 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 111 SYMBOL TABLE LABEL VALUE ENDPT_DISABLED 0x00 ENDPT_IN_ONLY 0x12 ENDPT_NON_CONTROL 0x1E ENDPT_OUT_ONLY 0x14 EP0 0x00 << 3 EP01_IN 0x81 EP01_OUT 0x01 EP02_IN 0x82 EP02_OUT 0x02 EP03_IN 0x83 EP03_OUT 0x03 EP04_IN 0x84 EP04_OUT 0x04 EP05_IN 0x85 EP05_OUT 0x05 EP06_IN 0x86 EP06_OUT 0x06 EP07_IN 0x87 EP07_OUT 0x07 EP08_IN 0x88 EP08_OUT 0x08 EP09_IN 0x89 EP09_OUT 0x09 EP1 0x01 << 3 EP10_IN 0x8A EP10_OUT 0x0A EP11_IN 0x8B EP11_OUT 0x0B EP12_IN 0x8C EP12_OUT 0x0C EP13_IN 0x8D EP13_OUT 0x0D EP14_IN 0x8E EP14_OUT 0x0E EP15_IN 0x8F EP15_OUT 0x0F EP2 0x02 << 3 EPCONDIS 00000003 EPHSHK 00000004 EPINEN 00000001 EPOUTEN 00000002 EPSTALL 00000000 EP_DISABLED_STATE 0xff EP_IDLE_STATE 0x00 EP_SETUP_STATE 0x01 FAST 00000001 FERR 00000002 FINISHSETADDRESS 0x14 << 2 FLTS 00000002 FREE 00000004 FRM0 00000000 FRM1 00000001 FRM10 00000002 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 112 SYMBOL TABLE LABEL VALUE FRM2 00000002 FRM3 00000003 FRM4 00000004 FRM5 00000005 FRM6 00000006 FRM7 00000007 FRM8 00000000 FRM9 00000001 FSEN 00000002 FSR0 00000000 FSR0H 00000FEA FSR0L 00000FE9 FSR1 00000001 FSR1H 00000FE2 FSR1L 00000FE1 FSR2 00000002 FSR2H 00000FDA FSR2L 00000FD9 GCEN 00000007 GETCONFIG 0x0C << 2 GETDESCRIPTOR 0x0D << 2 GETINTERFACE 0x0E << 2 GETSTATUS 0x0F << 2 GET_CONFIGURATION 0x08 GET_DESCRIPTOR 0x06 GET_IDLE 0x02 GET_INTERFACE 0x0A GET_PROTOCOL 0x03 GET_REPORT 0x01 GET_STATUS 0x00 GET_STRING_DESCRIPTOR 0x66 GIE 00000007 GIEH 00000007 GIEL 00000006 GO 00000001 GO_DONE 00000001 HID 0x21 HID_SET_REPORT 0x21 HLVDCON 00000FD2 HLVDEN 00000004 HLVDIE 00000002 HLVDIF 00000002 HLVDIN 00000005 HLVDIP 00000002 HLVDL0 00000000 HLVDL1 00000001 HLVDL2 00000002 HLVDL3 00000003 I2C_DAT 00000005 I2C_READ 00000002 I2C_START 00000003 I2C_STOP 00000004 IDLEIE 00000004 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 113 SYMBOL TABLE LABEL VALUE IDLEIF 00000004 IDLEN 00000007 INDF0 00000FEF INDF1 00000FE7 INDF2 00000FDF INT0 00000000 INT0E 00000004 INT0F 00000001 INT0IE 00000004 INT0IF 00000001 INT1 00000001 INT1E 00000003 INT1F 00000000 INT1IE 00000003 INT1IF 00000000 INT1IP 00000006 INT1P 00000006 INT2 00000002 INT2E 00000004 INT2F 00000001 INT2IE 00000004 INT2IF 00000001 INT2IP 00000007 INT2P 00000007 INTCON 00000FF2 INTCON2 00000FF1 INTCON3 00000FF0 INTEDG0 00000006 INTEDG1 00000005 INTEDG2 00000004 INTERFACE 4 INTERRUPT 0x03 INTSRC 00000007 INT_STAT_MASK_ERROR 0x02 INT_STAT_MASK_RESET 0x01 INT_STAT_MASK_SLEEP 0x08 INT_STAT_MASK_STALL 0x10 INT_STAT_MASK_TOKEN_DONE 0x04 IOFS 00000002 IPEN 00000007 IPR1 00000F9F IPR2 00000FA2 IRCF0 00000004 IRCF1 00000005 IRCF2 00000006 IRVST 00000005 ISOCHRONOUS 0x01 IVRST 00000005 InitPorts 00000052 InitUSB 000000D4 LATA 00000F89 LATA0 00000000 LATA1 00000001 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 114 SYMBOL TABLE LABEL VALUE LATA2 00000002 LATA3 00000003 LATA4 00000004 LATA5 00000005 LATA6 00000006 LATB 00000F8A LATB0 00000000 LATB1 00000001 LATB2 00000002 LATB3 00000003 LATB4 00000004 LATB5 00000005 LATB6 00000006 LATB7 00000007 LATC 00000F8B LATC0 00000000 LATC1 00000001 LATC2 00000002 LATC6 00000006 LATC7 00000007 LATD 00000F8C LATD0 00000000 LATD1 00000001 LATD2 00000002 LATD3 00000003 LATD4 00000004 LATD5 00000005 LATD6 00000006 LATD7 00000007 LATE 00000F8D LATE0 00000000 LATE1 00000001 LATE2 00000002 LVDCON 00000FD2 LVDEN 00000004 LVDIE 00000002 LVDIF 00000002 LVDIN 00000005 LVDIP 00000002 LVDL0 00000000 LVDL1 00000001 LVDL2 00000002 LVDL3 00000003 LVV0 00000000 LVV1 00000001 LVV2 00000002 LVV3 00000003 MAX_PACKET_SIZE 8 Main 00000000 N 00000004 NOT_A 00000005 NOT_ADDRESS 00000005 NOT_BOR 00000000 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 115 SYMBOL TABLE LABEL VALUE NOT_DONE 00000001 NOT_IPEN 00000007 NOT_PD 00000002 NOT_POR 00000001 NOT_RBPU 00000007 NOT_RI 00000004 NOT_T1SYNC 00000002 NOT_T3SYNC 00000002 NOT_TO 00000003 NOT_W 00000002 NOT_WRITE 00000002 NO_REQUEST 0xFF NUM_CONFIGURATIONS 1 NUM_ENDPOINTS 3 NUM_INTERFACES 1 NUM_STRINGS 2 OERR 00000001 OESPP 00000002 OSC2 00000006 OSCCON 00000FD3 OSCFIE 00000007 OSCFIF 00000007 OSCFIP 00000007 OSCTUNE 00000F9B OSTS 00000003 OV 00000003 P 00000004 P1A 00000002 P1M0 00000006 P1M1 00000007 PC 00000FF9 PCFG0 00000000 PCFG1 00000001 PCFG2 00000002 PCFG3 00000003 PCL 00000FF9 PCLATH 00000FFA PCLATU 00000FFB PD 00000002 PDC0 00000000 PDC1 00000001 PDC2 00000002 PDC3 00000003 PDC4 00000004 PDC5 00000005 PDC6 00000006 PEIE 00000006 PEN 00000002 PGC 00000006 PGD 00000007 PGM 00000005 PHYSICAL 0x23 PIDEE 00000000 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 116 SYMBOL TABLE LABEL VALUE PIDEF 00000000 PIE1 00000F9D PIE2 00000FA0 PIR1 00000F9E PIR2 00000FA1 PKTDIS 00000004 PLUSW0 00000FEB PLUSW1 00000FE3 PLUSW2 00000FDB POR 00000001 PORTA 00000F80 PORTB 00000F81 PORTC 00000F82 PORTD 00000F83 PORTE 00000F84 POSTDEC0 00000FED POSTDEC1 00000FE5 POSTDEC2 00000FDD POSTINC0 00000FEE POSTINC1 00000FE6 POSTINC2 00000FDE POWERED_STATE 0x00 PPB0 00000000 PPB1 00000001 PPBI 00000001 PPBRST 00000006 PR2 00000FCB PREINC0 00000FEC PREINC1 00000FE4 PREINC2 00000FDC PROD 00000FF3 PRODH 00000FF4 PRODL 00000FF3 PRSEN 00000007 PSA 00000003 PSSAC0 00000002 PSSAC1 00000003 PSSBD0 00000000 PSSBD1 00000001 ProcessInToken 00000B30 ProcessOutToken 00000BF2 ProcessSetupToken 0000033C R 00000002 RA0 00000000 RA1 00000001 RA2 00000002 RA3 00000003 RA4 00000004 RA5 00000005 RA6 00000006 RB0 00000000 RB1 00000001 RB2 00000002 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 117 SYMBOL TABLE LABEL VALUE RB3 00000003 RB4 00000004 RB5 00000005 RB6 00000006 RB7 00000007 RBIE 00000003 RBIF 00000000 RBIP 00000000 RBPU 00000007 RC0 00000000 RC1 00000001 RC2 00000002 RC4 00000004 RC5 00000005 RC6 00000006 RC7 00000007 RCEN 00000003 RCIDL 00000006 RCIE 00000005 RCIF 00000005 RCIP 00000005 RCMT 00000006 RCON 00000FD0 RCREG 00000FAE RCSTA 00000FAB RD 00000000 RD0 00000000 RD1 00000001 RD16 00000007 RD2 00000002 RD3 00000003 RD4 00000004 RD5 00000005 RD6 00000006 RD7 00000007 RDPU 00000007 RDSPP 00000007 RE0 00000000 RE1 00000001 RE2 00000002 RE3 00000003 READ_WRITE 00000002 RECIPIENT_DEVICE 0x00 RECIPIENT_ENDPOINT 0x02 RECIPIENT_INTERFACE 0x01 REPORT 0x22 RESUME 00000002 RI 00000004 RSEN 00000001 RX 00000007 RX9 00000006 RX9D 00000000 R_W 00000002 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 118 SYMBOL TABLE LABEL VALUE S 00000003 SBOREN 00000006 SCKP 00000004 SCS0 00000000 SCS1 00000001 SE0 00000005 SEN 00000000 SENDB 00000003 SETADDRESS 0x10 << 2 SETCONFIG 0x11 << 2 SETFEATURE 0x12 << 2 SETINTERFACE 0x13 << 2 SET_ADDRESS 0x05 SET_CONFIGURATION 0x09 SET_DESCRIPTOR 0x07 SET_FEATURE 0x03 SET_IDLE 0x0A SET_INTERFACE 0x0B SET_PROTOCOL 0x0B SET_RA0 0x01 SET_REPORT 0x09 SHOW_ENUM_STATUS SMP 00000007 SOFIE 00000006 SOFIF 00000006 SPBRG 00000FAF SPBRGH 00000FB0 SPEN 00000007 SPP0 00000000 SPP1 00000001 SPP2 00000002 SPP3 00000003 SPP4 00000004 SPP5 00000005 SPP6 00000006 SPP7 00000007 SPPBUSY 00000004 SPPCFG 00000F63 SPPCON 00000F65 SPPDATA 00000F62 SPPEN 00000000 SPPEPS 00000F64 SPPIE 00000007 SPPIF 00000007 SPPIP 00000007 SPPOWN 00000001 SREN 00000005 SSPADD 00000FC8 SSPBUF 00000FC9 SSPCON1 00000FC6 SSPCON2 00000FC5 SSPEN 00000005 SSPIE 00000003 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 119 SYMBOL TABLE LABEL VALUE SSPIF 00000003 SSPIP 00000003 SSPM0 00000000 SSPM1 00000001 SSPM2 00000002 SSPM3 00000003 SSPOV 00000006 SSPSTAT 00000FC7 STALLIE 00000005 STALLIF 00000005 STANDARD 0x00 << 5 STATUS 00000FD8 STKFUL 00000007 STKPTR 00000FFC STKPTR0 00000000 STKPTR1 00000001 STKPTR2 00000002 STKPTR3 00000003 STKPTR4 00000004 STKUNF 00000006 STRING 3 SUSPND 00000001 SVCACTIVITY 0x07 << 2 SVCERROR 0x06 << 2 SVCRESET 0x03 << 2 SVCSLEEP 0x04 << 2 SVCSTALL 0x05 << 2 SVCTOKENDONE 0x02 << 2 SVCUSBINT 0x01 << 2 SWDTE 00000000 SWDTEN 00000000 SYNC 00000004 SYNCH_FRAME 0x0C SendDescriptorPacket 00000C6C ServiceUSB 000000FC StandardRequests 00000408 String0 00000060 String1 00000064 String2 0000009A T08BIT 00000006 T0CKI 00000004 T0CON 00000FD5 T0CS 00000005 T0IE 00000005 T0IF 00000002 T0IP 00000002 T0PS0 00000000 T0PS1 00000001 T0PS2 00000002 T0SE 00000004 T13CKI 00000000 T1CKPS0 00000004 T1CKPS1 00000005 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 120 SYMBOL TABLE LABEL VALUE T1CON 00000FCD T1OSCEN 00000003 T1OSI 00000001 T1OSO 00000000 T1RUN 00000006 T1SYNC 00000002 T2CKPS0 00000000 T2CKPS1 00000001 T2CON 00000FCA T2OUTPS0 00000003 T2OUTPS1 00000004 T2OUTPS2 00000005 T2OUTPS3 00000006 T3CCP1 00000003 T3CCP2 00000006 T3CKPS0 00000004 T3CKPS1 00000005 T3CON 00000FB1 T3NSYNC 00000002 T3SYNC 00000002 TABLAT 00000FF5 TBLPTR 00000FF6 TBLPTRH 00000FF7 TBLPTRL 00000FF6 TBLPTRU 00000FF8 TMR0H 00000FD7 TMR0IE 00000005 TMR0IF 00000002 TMR0IP 00000002 TMR0L 00000FD6 TMR0ON 00000007 TMR1CS 00000001 TMR1H 00000FCF TMR1IE 00000000 TMR1IF 00000000 TMR1IP 00000000 TMR1L 00000FCE TMR1ON 00000000 TMR2 00000FCC TMR2IE 00000001 TMR2IF 00000001 TMR2IP 00000001 TMR2ON 00000002 TMR3CS 00000001 TMR3H 00000FB3 TMR3IE 00000001 TMR3IF 00000001 TMR3IP 00000001 TMR3L 00000FB2 TMR3ON 00000000 TO 00000003 TOKENIN 0x09 << 2 TOKENOUT 0x08 << 2 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 121 SYMBOL TABLE LABEL VALUE TOKENSETUP 0x0A << 2 TOKEN_ACK (0x02<<2) TOKEN_IN (0x09<<2) TOKEN_OUT (0x01<<2) TOKEN_SETUP (0x0D<<2) TOS 00000FFD TOSH 00000FFE TOSL 00000FFD TOSU 00000FFF TRISA 00000F92 TRISA0 00000000 TRISA1 00000001 TRISA2 00000002 TRISA3 00000003 TRISA4 00000004 TRISA5 00000005 TRISA6 00000006 TRISB 00000F93 TRISB0 00000000 TRISB1 00000001 TRISB2 00000002 TRISB3 00000003 TRISB4 00000004 TRISB5 00000005 TRISB6 00000006 TRISB7 00000007 TRISC 00000F94 TRISC0 00000000 TRISC1 00000001 TRISC2 00000002 TRISC6 00000006 TRISC7 00000007 TRISD 00000F95 TRISD0 00000000 TRISD1 00000001 TRISD2 00000002 TRISD3 00000003 TRISD4 00000004 TRISD5 00000005 TRISD6 00000006 TRISD7 00000007 TRISE 00000F96 TRISE0 00000000 TRISE1 00000001 TRISE2 00000002 TRMT 00000001 TRNIE 00000003 TRNIF 00000003 TUN0 00000000 TUN1 00000001 TUN2 00000002 TUN3 00000003 TUN4 00000004 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 122 SYMBOL TABLE LABEL VALUE TX 00000006 TX9 00000006 TX9D 00000000 TXEN 00000005 TXIE 00000004 TXIF 00000004 TXIP 00000004 TXREG 00000FAD TXSTA 00000FAC UA 00000001 UADDR 00000F6E UCFG 00000F6F UCON 00000F6D UEIE 00000F6B UEIR 00000F6A UEP0 00000F70 UEP1 00000F71 UEP10 00000F7A UEP11 00000F7B UEP12 00000F7C UEP13 00000F7D UEP14 00000F7E UEP15 00000F7F UEP2 00000F72 UEP3 00000F73 UEP4 00000F74 UEP5 00000F75 UEP6 00000F76 UEP7 00000F77 UEP8 00000F78 UEP9 00000F79 UERRIE 00000001 UERRIF 00000001 UFRM 00000F66 UFRMH 00000F67 UFRML 00000F66 UIE 00000F69 UIR 00000F68 UOEMON 00000006 UOWN 0x07 UPUEN 00000004 URSTIE 00000000 URSTIF 00000000 USBEN 00000003 USBIE 00000005 USBIF 00000005 USBIP 00000005 USB_Buffer 0x0480 USB_USTAT 00000015 USB_USWSTAT 00000016 USB_address_pending 00000010 USB_buffer_data 00000004 USB_buffer_desc 00000000 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 123 SYMBOL TABLE LABEL VALUE USB_bytes_left 00000012 USB_curr_config 0000000D USB_desc_ptr 00000011 USB_dev_req 0000000F USB_device_status 0000000E USB_error_flags 0000000C USB_loop_index 00000013 USB_packet_length 00000014 USTAT 00000F6C UTEYE 00000007 UTRDIS 00000003 VCFG0 00000004 VCFG1 00000005 VDIRMAG 00000007 VENDOR 0x02 << 5 VEND_SET_MEMORY 0x80 VREFM 00000002 VREFP 00000003 VendorRequests 00000AE2 W 00000000 WCOL 00000007 WDTCON 00000FD1 WR 00000001 WREG 00000FE8 WREN 00000002 WRERR 00000003 WRSPP 00000006 WS0 00000000 WS1 00000001 WS2 00000002 WS3 00000003 WUE 00000001 Z 00000002 ZEROLENPACKET 0x17 << 2 _BORV_0_2L 000000E7 _BORV_1_2L 000000EF _BORV_2_2L 000000F7 _BORV_3_2L 000000FF _BOR_OFF_2L 000000F9 _BOR_ON_2L 000000FF _BOR_ON_ACTIVE_2L 000000FD _BOR_SOFT_2L 000000FB _CCP2MX_OFF_3H 000000FE _CCP2MX_ON_3H 000000FF _CONFIG1H 00300001 _CONFIG1L 00300000 _CONFIG2H 00300003 _CONFIG2L 00300002 _CONFIG3H 00300005 _CONFIG4L 00300006 _CONFIG5H 00300009 _CONFIG5L 00300008 _CONFIG6H 0030000B MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 124 SYMBOL TABLE LABEL VALUE _CONFIG6L 0030000A _CONFIG7H 0030000D _CONFIG7L 0030000C _CP0_OFF_5L 000000FF _CP0_ON_5L 000000FE _CP1_OFF_5L 000000FF _CP1_ON_5L 000000FD _CP2_OFF_5L 000000FF _CP2_ON_5L 000000FB _CP3_OFF_5L 000000FF _CP3_ON_5L 000000F7 _CPB_OFF_5H 000000FF _CPB_ON_5H 000000BF _CPD_OFF_5H 000000FF _CPD_ON_5H 0000007F _CPUDIV_OSC1_PLL2_1L 000000E7 _CPUDIV_OSC2_PLL3_1L 000000EF _CPUDIV_OSC3_PLL4_1L 000000F7 _CPUDIV_OSC4_PLL6_1L 000000FF _DEBUG_OFF_4L 000000FF _DEBUG_ON_4L 0000007F _DEVID1 003FFFFE _DEVID2 003FFFFF _EBTR0_OFF_7L 000000FF _EBTR0_ON_7L 000000FE _EBTR1_OFF_7L 000000FF _EBTR1_ON_7L 000000FD _EBTR2_OFF_7L 000000FF _EBTR2_ON_7L 000000FB _EBTR3_OFF_7L 000000FF _EBTR3_ON_7L 000000F7 _EBTRB_OFF_7H 000000FF _EBTRB_ON_7H 000000BF _FCMEM_OFF_1H 000000BF _FCMEM_ON_1H 000000FF _FOSC_ECIO_EC_1H 000000F4 _FOSC_ECPLLIO_EC_1H 000000F6 _FOSC_ECPLL_EC_1H 000000F7 _FOSC_EC_EC_1H 000000F5 _FOSC_HSPLL_HS_1H 000000FE _FOSC_HS_1H 000000FC _FOSC_INTOSCIO_EC_1H 000000F8 _FOSC_INTOSC_EC_1H 000000F9 _FOSC_INTOSC_HS_1H 000000FB _FOSC_INTOSC_XT_1H 000000FA _FOSC_XTPLL_XT_1H 000000F2 _FOSC_XT_XT_1H 000000F0 _ICPRT_OFF_4L 000000DF _ICPRT_ON_4L 000000FF _IDLOC0 00200000 _IDLOC1 00200001 _IDLOC2 00200002 _IDLOC3 00200003 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 125 SYMBOL TABLE LABEL VALUE _IDLOC4 00200004 _IDLOC5 00200005 _IDLOC6 00200006 _IDLOC7 00200007 _IESO_OFF_1H 0000007F _IESO_ON_1H 000000FF _LPT1OSC_OFF_3H 000000FB _LPT1OSC_ON_3H 000000FF _LVP_OFF_4L 000000FB _LVP_ON_4L 000000FF _MCLRE_OFF_3H 0000007F _MCLRE_ON_3H 000000FF _PBADEN_OFF_3H 000000FD _PBADEN_ON_3H 000000FF _PLLDIV_10_1L 000000FE _PLLDIV_12_1L 000000FF _PLLDIV_1_1L 000000F8 _PLLDIV_2_1L 000000F9 _PLLDIV_3_1L 000000FA _PLLDIV_4_1L 000000FB _PLLDIV_5_1L 000000FC _PLLDIV_6_1L 000000FD _PWRT_OFF_2L 000000FF _PWRT_ON_2L 000000FE _STARTUP_001A 0000001A _STVREN_OFF_4L 000000FE _STVREN_ON_4L 000000FF _USBDIV_1_1L 000000DF _USBDIV_2_1L 000000FF _VREGEN_OFF_2L 000000DF _VREGEN_ON_2L 000000FF _WDTPS_1024_2H 000000F5 _WDTPS_128_2H 000000EF _WDTPS_16384_2H 000000FD _WDTPS_16_2H 000000E9 _WDTPS_1_2H 000000E1 _WDTPS_2048_2H 000000F7 _WDTPS_256_2H 000000F1 _WDTPS_2_2H 000000E3 _WDTPS_32768_2H 000000FF _WDTPS_32_2H 000000EB _WDTPS_4096_2H 000000F9 _WDTPS_4_2H 000000E5 _WDTPS_512_2H 000000F3 _WDTPS_64_2H 000000ED _WDTPS_8192_2H 000000FB _WDTPS_8_2H 000000E7 _WDT_OFF_2H 000000FE _WDT_ON_2H 000000FF _WRT0_OFF_6L 000000FF _WRT0_ON_6L 000000FE _WRT1_OFF_6L 000000FF _WRT1_ON_6L 000000FD MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 126 SYMBOL TABLE LABEL VALUE _WRT2_OFF_6L 000000FF _WRT2_ON_6L 000000FB _WRT3_OFF_6L 000000FF _WRT3_ON_6L 000000F7 _WRTB_OFF_6H 000000FF _WRTB_ON_6H 000000BF _WRTC_OFF_6H 000000FF _WRTC_ON_6H 000000DF _WRTD_OFF_6H 000000FF _WRTD_ON_6H 0000007F _XINST_OFF_4L 000000BF _XINST_ON_4L 000000FF __18F4550 00000001 _case0_0 00000106 _case0_1 00000116 _case0_2 00000126 _case0_3 0000013E _case0_4 000001C2 _case0_5 000001D2 _case0_6 00000246 _case0_7 0000033A _case10_0 00000626 _case10_1 00000654 _case10_2 00000656 _case11_0 00000678 _case11_1 000006A8 _case11_2 0000074C _case11_3 0000074E _case12_0 000007AC _case12_1 000007EA _case12_2 00000854 _case12_3 000008E8 _case12_4 000008EA _case13_0 00000804 _case13_1 0000081A _case13_2 0000081C _case14_0 0000086E _case14_1 00000888 _case14_2 000008A2 _case14_3 000008B8 _case14_4 000008BA _case15_0 00000968 _case15_1 00000986 _case15_2 000009CA _case16_0 000009FA _case16_1 00000A32 _case16_2 00000A34 _case17_0 00000A56 _case17_1 00000AA2 _case17_2 00000AA4 _case18_0 00000A7A _case18_1 00000A96 _case18_2 00000A98 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 127 SYMBOL TABLE LABEL VALUE _case19_0 00000ADE _case19_1 00000AE0 _case1_0 00000158 _case1_1 00000172 _case1_2 0000018C _case1_3 000001A6 _case1_4 000001B8 _case20_0 00000AEC _case20_1 00000B0E _case20_2 00000B2C _case20_3 00000B2E _case21_0 00000B3E _case21_1 00000BC4 _case21_2 00000BDC _case21_3 00000BF0 _case22_0 00000B58 _case22_1 00000BA4 _case22_2 00000BBC _case23_0 00000B74 _case23_1 00000B92 _case23_2 00000B9C _case24_0 00000C00 _case24_1 00000C28 _case24_2 00000C56 _case24_3 00000C6A _case2_0 00000278 _case2_1 00000292 _case2_2 000002AC _case2_3 000002C2 _case3_0 000002D2 _case3_1 000002EE _case3_2 0000030A _case3_3 00000322 _case4_0 000003B4 _case4_1 000003D0 _case4_2 000003EC _case4_3 00000404 _case4_4 00000406 _case5_0 00000412 _case5_1 000005DC _case5_10 00000AC0 _case5_11 00000AD0 _case5_12 00000AD6 _case5_2 000005F0 _case5_3 0000075C _case5_4 00000790 _case5_5 000008F2 _case5_6 00000924 _case5_7 000009E0 _case5_8 00000A3C _case5_9 00000AAC _case6_0 0000042E _case6_1 00000462 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 128 SYMBOL TABLE LABEL VALUE _case6_2 000004D8 _case6_3 000005D2 _case6_4 000005D4 _case7_0 0000047C _case7_1 00000496 _case7_2 000004D0 _case8_0 000004F2 _case8_1 0000054A _case8_2 000005CC _case8_3 000005CE _case9_0 0000060C _case9_1 0000065E _case9_2 00000752 _case9_3 00000754 _casebypass0_0 0000010C _casebypass0_1 0000011C _casebypass0_2 0000012C _casebypass0_3 00000144 _casebypass0_4 000001C8 _casebypass0_5 000001D8 _casebypass0_6 0000024C _casebypass10_0 00000636 _casebypass11_0 00000688 _casebypass11_1 000006B8 _casebypass12_0 000007BC _casebypass12_1 000007FA _casebypass12_2 00000864 _casebypass13_0 00000814 _casebypass14_0 0000087E _casebypass14_1 00000898 _casebypass14_2 000008B2 _casebypass15_0 00000978 _casebypass16_0 00000A0A _casebypass17_0 00000A66 _casebypass18_0 00000A8A _casebypass1_0 00000168 _casebypass1_1 00000182 _casebypass1_2 0000019C _casebypass1_3 000001B6 _casebypass20_0 00000AFC _casebypass20_1 00000B1E _casebypass21_0 00000B4E _casebypass21_1 00000BD4 _casebypass21_2 00000BEC _casebypass22_0 00000B68 _casebypass22_1 00000BB4 _casebypass23_0 00000B84 _casebypass24_0 00000C10 _casebypass24_1 00000C38 _casebypass24_2 00000C66 _casebypass2_0 00000288 _casebypass2_1 000002A2 _casebypass2_2 000002BC MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 129 SYMBOL TABLE LABEL VALUE _casebypass3_0 000002E2 _casebypass3_1 000002FE _casebypass3_2 0000031A _casebypass4_0 000003C4 _casebypass4_1 000003E0 _casebypass4_2 000003FC _casebypass5_0 00000422 _casebypass5_1 000005EC _casebypass5_10 00000AD0 _casebypass5_2 00000600 _casebypass5_3 0000076C _casebypass5_4 000007A0 _casebypass5_5 00000902 _casebypass5_6 00000934 _casebypass5_7 000009F0 _casebypass5_8 00000A4C _casebypass5_9 00000ABC _casebypass6_0 0000043E _casebypass6_1 00000472 _casebypass6_2 000004E8 _casebypass7_0 0000048C _casebypass7_1 000004A6 _casebypass8_0 00000502 _casebypass8_1 0000055A _casebypass9_0 0000061C _casebypass9_1 0000066E _casecount 00000000 _casematch10_0 00000634 _casematch11_0 00000686 _casematch11_1 000006B6 _casematch12_0 000007BA _casematch12_1 000007F8 _casematch12_2 00000862 _casematch13_0 00000812 _casematch14_0 0000087C _casematch14_1 00000896 _casematch14_2 000008B0 _casematch15_0 00000976 _casematch16_0 00000A08 _casematch17_0 00000A64 _casematch18_0 00000A88 _casematch1_0 00000166 _casematch1_1 00000180 _casematch1_2 0000019A _casematch1_3 000001B4 _casematch20_0 00000AFA _casematch20_1 00000B1C _casematch21_0 00000B4C _casematch21_1 00000BD2 _casematch21_2 00000BEA _casematch22_0 00000B66 _casematch22_1 00000BB2 _casematch23_0 00000B82 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 130 SYMBOL TABLE LABEL VALUE _casematch24_0 00000C0E _casematch24_1 00000C36 _casematch24_2 00000C64 _casematch2_0 00000286 _casematch2_1 000002A0 _casematch2_2 000002BA _casematch3_0 000002E0 _casematch3_1 000002FC _casematch3_2 00000318 _casematch4_0 000003C2 _casematch4_1 000003DE _casematch4_2 000003FA _casematch5_0 00000420 _casematch5_1 000005EA _casematch5_10 00000ACE _casematch5_2 000005FE _casematch5_3 0000076A _casematch5_4 0000079E _casematch5_5 00000900 _casematch5_6 00000932 _casematch5_7 000009EE _casematch5_8 00000A4A _casematch5_9 00000ABA _casematch6_0 0000043C _casematch6_1 00000470 _casematch6_2 000004E6 _casematch7_0 0000048A _casematch7_1 000004A4 _casematch8_0 00000500 _casematch8_1 00000558 _casematch9_0 0000061A _casematch9_1 0000066C _casestack0 00000000 _casestack1 00000001 _casestack2 00000001 _endif0 0000001E _endif1 0000001E _endif10 00000648 _endif11 000006A0 _endif12 0000073A _endif13 000006DC _endif14 000006EE _endif15 0000073A _endif16 00000714 _endif17 0000070E _endif18 0000073A _endif19 00000734 _endif2 00000336 _endif20 00000748 _endif21 00000788 _endif22 000007DE _endif23 0000084C _endif24 00000848 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 131 SYMBOL TABLE LABEL VALUE _endif25 000008E4 _endif26 000008E0 _endif27 000009D8 _endif28 00000A2E _endif29 00000A9E _endif3 0000039C _endif30 00000C84 _endif31 0000003A _endif32 0000004C _endif4 00000396 _endif5 000004CC _endif6 00000542 _endif7 0000052A _endif8 0000058A _endif9 000005C8 _endrepeat0 000000FA _endrepeat1 00000026 _endrepeat2 00000052 _endselect0 0000033A _endselect1 000001B8 _endselect10 00000656 _endselect11 0000074E _endselect12 000008EA _endselect13 0000081C _endselect14 000008BA _endselect15 000009CA _endselect16 00000A34 _endselect17 00000AA4 _endselect18 00000A98 _endselect19 00000AE0 _endselect2 000002C2 _endselect20 00000B2E _endselect21 00000BF0 _endselect22 00000BBC _endselect23 00000B9C _endselect24 00000C6A _endselect3 00000322 _endselect4 00000406 _endselect5 00000AD6 _endselect6 000005D4 _endselect7 000004D0 _endselect8 000005CE _endselect9 00000754 _for0 00000C9A _forcount 00000001 _forstack0 00000000 _forstackptr 00000000 _if0_0 0000000E _if0_1 0000001E _if10_0 00000636 _if10_1 00000646 _if10_2 00000648 _if11_0 0000068C MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 132 SYMBOL TABLE LABEL VALUE _if11_1 0000069E _if11_2 000006A0 _if12_0 000006CC _if12_1 0000073A _if13_0 000006D4 _if13_1 000006DC _if14_0 000006E6 _if14_1 000006EE _if15_0 000006EE _if15_1 00000718 _if15_2 0000073A _if16_0 000006F4 _if16_1 00000712 _if16_2 00000714 _if17_0 000006FA _if17_1 0000070A _if17_2 0000070E _if18_0 00000718 _if18_1 00000738 _if18_2 0000073A _if19_0 0000071E _if19_1 00000730 _if19_2 00000734 _if1_0 00000016 _if1_1 0000001E _if20_0 0000073A _if20_1 00000748 _if21_0 0000076C _if21_1 00000778 _if21_2 00000788 _if22_0 000007C6 _if22_1 000007DE _if23_0 0000081C _if23_1 0000084C _if24_0 00000830 _if24_1 00000848 _if25_0 000008BA _if25_1 000008E4 _if26_0 000008C8 _if26_1 000008E0 _if27_0 00000934 _if27_1 000009D6 _if27_2 000009D8 _if28_0 00000A0A _if28_1 00000A2C _if28_2 00000A2E _if29_0 00000A66 _if29_1 00000A9C _if29_2 00000A9E _if2_0 00000324 _if2_1 00000336 _if30_0 00000C6E _if30_1 00000C82 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 133 SYMBOL TABLE LABEL VALUE _if30_2 00000C84 _if31_0 00000032 _if31_1 0000003A _if32_0 0000003A _if32_1 00000048 _if32_2 0000004C _if3_0 00000370 _if3_1 0000039A _if3_2 0000039C _if4_0 00000376 _if4_1 00000384 _if4_2 00000394 _if4_3 00000396 _if5_0 000004A6 _if5_1 000004CA _if5_2 000004CC _if6_0 00000506 _if6_1 00000540 _if6_2 00000542 _if7_0 00000518 _if7_1 00000526 _if7_2 0000052A _if8_0 00000582 _if8_1 0000058A _if9_0 0000058E _if9_1 000005A0 _if9_2 000005B2 _if9_3 000005C8 _ifbypass4_1 0000038E _ifclausecount 00000000 _ifclausestack0 00000000 _ifclausestack1 00000001 _ifclausestack2 00000002 _ifclausestack3 00000001 _ifcount 00000021 _ifstack0 00000020 _ifstack1 0000001A _ifstack2 00000012 _ifstack3 00000013 _ifstackptr 00000000 _next0 00000CB2 _repeat0 000000F4 _repeat1 00000018 _repeat2 0000002E _rptcount 00000003 _rptstack0 00000002 _rptstackptr 00000000 _selcount 00000019 _select0 000000FE _select1 00000150 _select10 0000061E _select11 00000670 _select12 000007A4 MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 134 SYMBOL TABLE LABEL VALUE _select13 000007FC _select14 00000866 _select15 00000960 _select16 000009F2 _select17 00000A4E _select18 00000A72 _select19 00000ADA _select2 00000270 _select20 00000AE4 _select21 00000B36 _select22 00000B50 _select23 00000B6C _select24 00000BF8 _select3 000002CA _select4 000003AC _select5 0000040A _select6 00000426 _select7 00000474 _select8 000004EA _select9 00000604 _selstack0 00000018 _selstack1 00000016 _selstack2 00000017 _selstackptr 00000000 andif andifclr andiff andifset bRequest 0x01 bmRequestType 0x00 break case caseclr casef caseset default elsif elsifclr elsiff elsifset endi ends escfor escrepeat exitfor exitrepeat for forever forf forfl forlf ifclr iff MPASM 5.01 MAIN.ASM 4-22-2006 22:43:04 PAGE 135 SYMBOL TABLE LABEL VALUE ifl ifset next nextf nextl orif orifclr oriff orifset otherwise repeat select selectf until untilclr untilf untilset wIndex 0x04 wIndexHigh 0x05 wLength 0x06 wLengthHigh 0x07 wValue 0x02 wValueHigh 0x03 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 0 reported, 0 suppressed