MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ; kMouse.asm 00002 ; (c) 2017 David Hunter 00003 ; Implements a variation of Mouse for the Hackaday 1kB challenge 2017 00004 ; The commands are based on the Mouse programming language first developed 00005 ; by Peter Grogono ~ 1975. I first read about it from Byte Magazine July 1979. 00006 ; The major difference is the use of hexadecimal for all values rather than 00007 ; decimal. The command set has been reduced down to something similar to 00008 ; Tiny BASIC also from ~ 1975. Some changes to the original command set were 00009 ; made to better accomodate the small space and PIC18. 00010 ; The one item to note is that access to the registers of the PIC18 is 00011 ; possible using byte read (peek) and write (poke) commands. 00012 ; 00013 ; Tested on a PIC18LF2620. The internal oscillator is used and the PLL 00014 ; enabled, so the internal clock is at 32MHz. 00015 ; 00016 ; User I/O is via a serial port: 57600,8N1 00017 ; (an FTDI cable was used for development) 00018 ; 00019 ; 00020 ; All 16 bit variables use a "Big Endian" format 00021 ; addr = high byte, addr+1 = low byte 00022 ; 00023 ; The stacks are conventional and go from high to low memory 00024 ; the stack pointer points to the next unused value on the stack 00025 ; (calstk) calculation stack is a 16 bit stack 00026 ; (envstk) environment stack is a 16 bit stack holding the character position 00027 ; for a macro call 00028 ; 00029 ; The DEBUG definition is to enable debugging tools used in developing and 00030 ; testing kMouse. They are not used in normal operation. 00031 00032 00033 #include "p18F2620.inc" 00001 LIST 00002 00003 ;========================================================================== 00004 ; Build date : Oct 14 2014 00005 ; MPASM PIC18F2620 processor include 00006 ; 00007 ; (c) Copyright 1999-2014 Microchip Technology, All rights reserved 00008 ;========================================================================== 00009 01312 LIST 00034 00035 ;*************** 00036 ; CONSTANTS 00037 ; 0000000D 00038 CR equ '\r' 0000000A 00039 LF equ '\n' 00000008 00040 BS equ 0x08 ; backspace 00000003 00041 CAN equ 0x03 ; 00000020 00042 SPC equ ' ' 0000002E 00043 PROMPT equ '.' ; use a period as a prompt MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000000FF 00044 EOF equ 0xFF ; end of file character 00045 00000020 00046 STKSIZ equ .32 ; calculation stack size (16 words) 00000008 00047 MAXLVL equ 8 ; maximum number of nested macros 00000008 00048 ENVSIZ equ MAXLVL ; environment stack size 00000034 00049 MACSIZ equ .26*2 ; macro definitions size 00000034 00050 VARSIZ equ .26*2 ; variable data space 00051 00052 ;*************** 00053 ; Macros and defines 00054 #define GETNEXT movff POSTINC0,ch ; get next program character 00055 #define UNGET movf POSTDEC0,W ; back up program counter 00056 00057 ;#define DEBUG ; for debugging of the interpreter 00058 00059 ; PIC18F2620 Configuration Bit Settings 00060 00061 ; CONFIG1H 00062 CONFIG OSC = INTIO67 ; Oscillator Selection bits (Internal oscillator block, port function on RA6 and RA7) 00063 CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled) 00064 CONFIG IESO = OFF ; Internal/External Oscillator Switchover bit (Oscillator Switchover mod e disabled) 00065 00066 ; CONFIG2L 00067 CONFIG PWRT = OFF ; Power-up Timer Enable bit (PWRT disabled) 00068 CONFIG BOREN = SBORDIS ; Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled)) 00069 CONFIG BORV = 3 ; Brown Out Reset Voltage bits (Minimum setting) 00070 00071 ; CONFIG2H 00072 CONFIG WDT = OFF ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDT EN bit)) 00073 CONFIG WDTPS = 32768 ; Watchdog Timer Postscale Select bits (1:32768) 00074 00075 ; CONFIG3H 00076 CONFIG CCP2MX = PORTC ; CCP2 MUX bit (CCP2 input/output is multiplexed with RC1) 00077 CONFIG PBADEN = OFF ; PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset) 00078 CONFIG LPT1OSC = OFF ; Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher p ower operation) 00079 CONFIG MCLRE = ON ; MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled) 00080 00081 ; CONFIG4L 00082 CONFIG STVREN = ON ; Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset) 00083 CONFIG LVP = OFF ; Single-Supply ICSP Enable bit (Single-Supply ICSP disabled) 00084 CONFIG XINST = OFF ; Extended Instruction Set Enable bit (Instruction set extension and Ind exed Addressing mode disabled (Legacy mode)) 00085 00086 ; CONFIG5L 00087 CONFIG CP0 = OFF ; Code Protection bit (Block 0 (000800-003FFFh) not code-protected) 00088 CONFIG CP1 = OFF ; Code Protection bit (Block 1 (004000-007FFFh) not code-protected) MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00089 CONFIG CP2 = OFF ; Code Protection bit (Block 2 (008000-00BFFFh) not code-protected) 00090 CONFIG CP3 = OFF ; Code Protection bit (Block 3 (00C000-00FFFFh) not code-protected) 00091 00092 ; CONFIG5H 00093 CONFIG CPB = OFF ; Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-p rotected) 00094 CONFIG CPD = OFF ; Data EEPROM Code Protection bit (Data EEPROM not code-protected) 00095 00096 ; CONFIG6L 00097 CONFIG WRT0 = OFF ; Write Protection bit (Block 0 (000800-003FFFh) not write-protected) 00098 CONFIG WRT1 = OFF ; Write Protection bit (Block 1 (004000-007FFFh) not write-protected) 00099 CONFIG WRT2 = OFF ; Write Protection bit (Block 2 (008000-00BFFFh) not write-protected) 00100 CONFIG WRT3 = OFF ; Write Protection bit (Block 3 (00C000-00FFFFh) not write-protected) 00101 00102 ; CONFIG6H 00103 CONFIG WRTC = OFF ; Configuration Register Write Protection bit (Configuration registers ( 300000-3000FFh) not write-protected) 00104 CONFIG WRTB = OFF ; Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write -protected) 00105 CONFIG WRTD = OFF ; Data EEPROM Write Protection bit (Data EEPROM not write-protected) 00106 00107 ; CONFIG7L 00108 CONFIG EBTR0 = OFF ; Table Read Protection bit (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks) 00109 CONFIG EBTR1 = OFF ; Table Read Protection bit (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks) 00110 CONFIG EBTR2 = OFF ; Table Read Protection bit (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks) 00111 CONFIG EBTR3 = OFF ; Table Read Protection bit (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks) 00112 00113 ; CONFIG7H 00114 CONFIG EBTRB = OFF ; Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks) 00115 00116 ; variables 00117 cblock 0 00000000 00118 temp:2 ; temporary 16 bit variable 00000002 00119 x:2 ; temporary 16 bit number (word) 00000004 00120 y:2 ; temporary 16 bit number (word) 00000006 00121 ch ; character 00000007 00122 i ; temporary counters 00000008 00123 j 00000009 00124 skipcnt ; character skip count 00125 ; variables for range check 0000000A 00126 lolim ; low limit 0000000B 00127 hilim ; high limit 00128 ; constants stored in registers 0000000C 00129 reg_spc ; ASCII space 0000000D 00130 reg_cr ; ASCII '\r' 00131 endc 00132 00133 ; stacks (in FSR memory space) MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 4 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00134 cblock 0x80 00000080 00135 globvar:VARSIZ ; global variable table (a-z) 000000B4 00136 macdef:MACSIZ ; macro / label definition table (A-Z) 000000E8 00137 calstp:STKSIZ-1 00000107 00138 calstk ; calculation stack 00000108 00139 envstp:ENVSIZ-1 0000010F 00140 envstk ; environment stack 00000110 00141 pgmstart ; start of program space 00142 endc 00143 00144 ; Reset vector 00145 org 0 000000 D??? 00146 bra start 00147 00148 ; High priority interrupts 00149 org 0x0008 00150 00151 ; Low priority interrupts 00152 org 0x0018 00153 00154 ; SETUP 00155 org 0x0020 000020 00156 start: 000020 0E70 00157 movlw 0x70 000022 6ED3 00158 movwf OSCCON ; set internal oscillator to 8MHz 000024 8C9B 00159 bsf OSCTUNE,6 ; set PLL on 00160 000026 0E24 00161 movlw 0x24 000028 6EAC 00162 movwf TXSTA ; set asynchronous, BRGH, enable TX 00163 00002A 0E90 00164 movlw 0x90 00002C 6EAB 00165 movwf RCSTA ; set asynchronous, enable RX 00166 00002E 86B8 00167 bsf BAUDCON,3 ; set 16-bit BRG 000030 0E8A 00168 movlw .138 000032 6EAF 00169 movwf SPBRG 000034 6AB0 00170 clrf SPBRGH ; set baud rate counter for ~57600 00171 00172 ; set ASCII registers 000036 0E20 00173 movlw SPC 000038 6E0C 00174 movwf reg_spc 00175 00003A 0E0D 00176 movlw CR 00003C 6E0D 00177 movwf reg_cr 00178 00003E 6B10 00179 clrf pgmstart ; clear first byte 00180 00181 00182 ;************************************************* 00183 ; MAIN LOOP 000040 00184 main: 00185 ; send user prompt 000040 D??? 00186 rcall crlf MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 5 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000042 0E2E 00187 movlw PROMPT 000044 D??? 00188 rcall putc 00189 000046 D??? 00190 rcall getce ; get command and echo 000048 0E5F 00191 movlw 0x5F ; convert to upper case 00004A 1606 00192 andwf ch,f 00193 00194 ; parse command 00004C 0E4C 00195 movlw 'L' ; load? 00004E 1806 00196 xorwf ch,W 000050 E0?? 00197 bz loader 00198 000052 0E47 00199 movlw 'G' ; go (run)? 000054 1806 00200 xorwf ch,W 000056 B4D8 00201 btfsc STATUS,Z 000058 D??? 00202 bra interp ; too far for BZ instruction 00203 00204 ifdef DEBUG 00205 movlw 'D' ; dump program (debug) 00206 xorwf ch,W 00207 btfsc STATUS,Z 00208 bra dumpp 00209 00210 movlw 'T' ; dump macro table (debug) 00211 xorwf ch,W 00212 btfsc STATUS,Z 00213 bra dumpt 00214 endif 00215 00005A 00216 invCmd: 00005A D??? 00217 rcall perror ; otherwise an error 00005C D??? 00218 bra main 00219 00220 ;************************************************* 00221 ; load a program from the serial port into memory 00222 ; eliminating whitespace 00005E 00223 loader: 00005E EE10 F0E7 00224 lfsr 1,macdef + MACSIZ - 1 ; FSR1 -> macro definitions table end 000062 0E34 00225 movlw MACSIZ 000064 6E07 00226 movwf i 000066 00227 clrmac: ; clear macro definitions 000066 6AE5 00228 clrf POSTDEC1 000068 2E07 00229 decfsz i,f 00006A D??? 00230 bra clrmac 00231 00006C 50E6 00232 movf POSTINC1,W ; undo the last decrement 00233 ; at this point, FSR1 -> macro definitions table start 00234 00006E 0E3A 00235 movlw ':' ; indicate ready to receive program file 000070 D??? 00236 rcall putc 00237 000072 EE01 F010 00238 lfsr 0,pgmstart ; FSR0 -> program space 00239 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 6 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00240 ; read program loop 000076 00241 ldloop: 000076 D??? 00242 rcall getc ; get a character 000078 0E2A 00243 movlw '*' 00007A D??? 00244 rcall putc ; show progress 00007C 5C0C 00245 subwf reg_spc,W ; W = - ch 00007E E1?? 00246 bnz tstctl ; not blank, try next test 000080 C006 FFEE 00247 movff ch,POSTINC0 ; yes, save first blank 00248 000084 00249 skipbl: 000084 D??? 00250 rcall getc 000086 5C0C 00251 subwf reg_spc,W ; another blank? 000088 E0?? 00252 bz skipbl ; yes, skip remaining blanks 00253 00008A 00254 tstctl: ; flag set by subtraction with SPC 00255 ; control char? (SPC - ch > 0) 00008A E6?? 00256 bn testch 00008C C00C FFEE 00257 movff reg_spc,POSTINC0 ; yes, save as blank 000090 D??? 00258 bra ldloop ; and get the next character 00259 000092 00260 testch: 000092 0E7E 00261 movlw '~' ; comment? 000094 1806 00262 xorwf ch,W 000096 E1?? 00263 bnz testch1 ; no, try next test 00264 000098 00265 skipeol: ; yes, skip until end of line 000098 EC?? F??? 00266 call getc 00009C 620D 00267 cpfseq reg_cr ; CR? 00009E D??? 00268 bra skipeol ; no, keep going 0000A0 D??? 00269 bra ldloop ; yes, end of comment 00270 0000A2 00271 testch1: 0000A2 0E22 00272 movlw '"' ; string? 0000A4 1806 00273 xorwf ch,W 0000A6 E1?? 00274 bnz testch2 ; no, try next test 00275 0000A8 C006 F000 00276 movff ch,temp ; save quote for comparison 0000AC C006 FFEE 00277 movff ch,POSTINC0 ; save quote 00278 0000B0 00279 savestr: 0000B0 D??? 00280 rcall getc 0000B2 6EEE 00281 movwf POSTINC0 ; save character 0000B4 6200 00282 cpfseq temp ; end quote? 0000B6 D??? 00283 bra savestr ; no, keep going 00284 0000B8 D??? 00285 bra ldloop ; yes, end of string 00286 0000BA 00287 testch2: 0000BA 0E24 00288 movlw '$' ; macro def / label or end? 0000BC 1806 00289 xorwf ch,W 0000BE E1?? 00290 bnz savech ; no, just save it 00291 0000C0 D??? 00292 rcall getc ; yes, get next character and echo MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 7 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0000C2 0E41 00293 movlw 'A' 0000C4 6E0A 00294 movwf lolim 0000C6 0E5A 00295 movlw 'Z' 0000C8 6E0B 00296 movwf hilim 0000CA D??? 00297 rcall range ; upper case letter? 0000CC E2?? 00298 bc endload ; no, end of file 00299 0000CE D??? 00300 rcall calcOffset ; get table offset 0000D0 CFEA FFE3 00301 movff FSR0H,PLUSW1 ; save upper byte of program counter 0000D4 0F01 00302 addlw 1 ; point to next byte in def table 0000D6 CFE9 FFE3 00303 movff FSR0L,PLUSW1 ; save lower byte of program counter 0000DA D??? 00304 bra ldloop 00305 0000DC 00306 savech: 0000DC C006 FFEE 00307 movff ch,POSTINC0 ; save any other character 0000E0 0E0F 00308 movlw 0x0F 0000E2 62EA 00309 cpfseq FSR0H ; check if at end of memory 0000E4 D??? 00310 bra ldloop ; no, keep going 00311 0000E6 D??? 00312 rcall perror ; yes, show end of file error 00313 0000E8 00314 endload: 0000E8 0EFF 00315 movlw EOF 0000EA 6EEE 00316 movwf POSTINC0 ; save end of file 0000EC 00317 done: 0000EC D??? 00318 bra main ; and exit 00319 00320 00321 ;************************************************* 00322 ; interpret the program in memory 0000EE 00323 interp: 00324 ; initialize 0000EE EE01 F010 00325 lfsr 0,pgmstart ; FSR0 = program counter 0000F2 EE11 F007 00326 lfsr 1,calstk ; FSR1 = calculation stack 0000F6 EE21 F00F 00327 lfsr 2,envstk ; FSR2 = environment stack 00328 0000FA 50EF 00329 movf INDF0,W ; check first program byte 0000FC B4D8 00330 btfsc STATUS,Z 0000FE D??? 00331 bra invCmd ; no program loaded, exit with error 00332 000100 D??? 00333 rcall crlf ; start a new line after command 00334 00335 ;*** interpreter loop 000102 00336 iloop: 000102 AA9E 00337 btfss PIR1,5 ; check for ^C to stop 000104 D??? 00338 bra iloop0 ; no character, continue 00339 000106 50AE 00340 movf RCREG,W ; get character 000108 0A03 00341 xorlw CAN 00010A E0?? 00342 bz done ; exit to command line if ^C 00343 ; or ignore 00010C 00344 iloop0: 00345 ; trace the execution for debugging interpreter MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 8 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00346 ifdef DEBUG 00347 rcall trace 00348 endif 00349 00010C CFEE F006 00350 GETNEXT ; get character in ch 00351 00352 ; end of file? 000110 00353 tstend: 000110 0E25 00354 movlw '%' ; exit program? 000112 6206 00355 cpfseq ch 000114 D??? 00356 bra tstLower 000116 D??? 00357 bra main 00358 00359 ; lower case letter? 00360 ; ch = lower case letter (global Variable) 000118 00361 tstLower: 000118 D??? 00362 rcall isLower 00011A E2?? 00363 bc tstOp ; no, try next test 00364 00011C 0E61 00365 movlw 'a' 00011E 5C06 00366 subwf ch,W ; calculate table offset 000120 90D8 00367 bcf STATUS,C 000122 34E8 00368 rlcf WREG,W 000124 6E01 00369 movwf temp + 1 000126 6A00 00370 clrf temp 00371 000128 0E80 00372 movlw LOW globvar 00012A 2601 00373 addwf temp + 1,f 00012C 0E00 00374 movlw HIGH globvar 00012E 2200 00375 addwfc temp,f ; temp = global variable + offset 000130 D??? 00376 bra pushCal ; and push address on stack 00377 00378 ; no, it must be an operator 00379 ; ch = operator 000132 00380 tstOp: 000132 0E20 00381 movlw SPC 00382 ; op = -> no action 000134 1806 00383 xorwf ch,W 000136 E0?? 00384 bz iloop ; ignore blanks 00385 000138 00386 op0: 000138 0E26 00387 movlw '&' 00013A 6206 00388 cpfseq ch 00013C D??? 00389 bra op1 00390 ; op = & put hex number on stack 00391 00013E D??? 00392 rcall clrtemp 000140 00393 op0a: 000140 CFEE F006 00394 GETNEXT ; get digit 000144 D??? 00395 rcall isHex ; convert to upper case, check if hex digit 000146 E2?? 00396 bc pushnum ; no, save the number 000148 D??? 00397 rcall mult16 ; make room for new digit 00014A D??? 00398 rcall ASCIItoBIN ; yes, convert to binary, add to temp MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 9 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00014C D??? 00399 bra op0a 00400 00014E 00401 pushnum: 00014E 50ED 00402 UNGET ; back up pointer because last char was not a digit 000150 D??? 00403 bra pushCal ; save number on stack 00404 000152 00405 op1: 000152 0E21 00406 movlw '!' 000154 6206 00407 cpfseq ch 000156 D??? 00408 bra op2 00409 ; op = ! -> print top of stack 00410 ; op = !' -> print ASCII value from top of stack 000158 D??? 00411 rcall popCal ; get value into temp 00015A CFEE F006 00412 GETNEXT ; get next character 00015E 0E27 00413 movlw '\'' ; display ASCII character instead? 000160 1806 00414 xorwf ch,W 000162 E1?? 00415 bnz op1a 00416 000164 5001 00417 movf temp + 1,W 000166 D??? 00418 rcall putc 000168 D??? 00419 bra iloop ; done 00420 00016A 00421 op1a: 00016A 50ED 00422 UNGET ; back up 00423 00424 ; print hexadecimal number 00016C 00425 putHex: 00016C 0E04 00426 movlw 4 00016E 6E07 00427 movwf i ; 4 digits in temp 00428 000170 00429 putHex0: 000170 3800 00430 swapf temp,W ; get upper nibble 000172 0B0F 00431 andlw 0x0F 00432 ; Hex Nibble to ASCII (Myke Predko) 000174 0F36 00433 addlw 0x36 ; add '0' + 6 to value 000176 B2D8 00434 btfsc STATUS,DC ; if digit carry set, then 'A' - 'F' 000178 0F07 00435 addlw 7 ; add difference between '9' and 'A' 00017A 0FFA 00436 addlw 0-6 00437 00017C D??? 00438 rcall putc 00017E D??? 00439 rcall mult16 ; shift over 4 bits 000180 2E07 00440 decfsz i,f 000182 D??? 00441 bra putHex0 00442 000184 D??? 00443 bra iloop ; done 00444 00445 000186 00446 op2: 000186 0E3F 00447 movlw '?' 000188 6206 00448 cpfseq ch 00018A D??? 00449 bra op3 00450 ; op = ? -> get number and put on stack 00451 ; op = ?' -> get ASCII character and put value on stack MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 10 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00018C D??? 00452 rcall clrtemp 00018E CFEE F006 00453 GETNEXT ; get next character 000192 0E27 00454 movlw '\'' ; looking for ASCII character? 000194 1806 00455 xorwf ch,W 000196 E1?? 00456 bnz op2a 00457 000198 D??? 00458 rcall getce ; get char and echo 00019A 6E01 00459 movwf temp + 1 ; and save 00019C D??? 00460 bra pushCal 00461 00019E 00462 op2a: 00019E 50ED 00463 UNGET ; back up 00464 0001A0 00465 op2b: 0001A0 D??? 00466 rcall getce ; get char and echo 0001A2 D??? 00467 rcall isHex ; convert to upper case, check if hex digit 0001A4 E2?? 00468 bc op2c ; not valid digit, exit loop 0001A6 D??? 00469 rcall mult16 ; make room for new digit 0001A8 D??? 00470 rcall ASCIItoBIN ; yes, convert to binary, add to temp 0001AA D??? 00471 bra op2b 00472 0001AC 00473 op2c: 0001AC D??? 00474 bra pushCal 00475 0001AE 00476 op3: 0001AE 0E27 00477 movlw '\'' 0001B0 6206 00478 cpfseq ch 0001B2 D??? 00479 bra op4 00480 ; op = ' -> put ASCII value of char on top of stack 0001B4 CFEE F006 00481 GETNEXT 0001B8 C006 F001 00482 movff ch,temp + 1 0001BC 6A00 00483 clrf temp 0001BE D??? 00484 bra pushCal 00485 0001C0 00486 op4: 0001C0 0E3A 00487 movlw ':' 0001C2 6206 00488 cpfseq ch 0001C4 D??? 00489 bra op5 00490 ; op = : -> store data in a variable 0001C6 D??? 00491 rcall popCal2 0001C8 D??? 00492 rcall saveFSR2 ; set x -> FSR2 0001CA C000 FFDE 00493 movff temp,POSTINC2 0001CE C001 FFDF 00494 movff temp + 1,INDF2 0001D2 D??? 00495 rcall restoreFSR2 0001D4 D??? 00496 bra iloop 00497 0001D6 00498 op5: 0001D6 0E7C 00499 movlw '|' 0001D8 6206 00500 cpfseq ch 0001DA D??? 00501 bra op6 00502 ; op = | -> store data in a register 0001DC D??? 00503 rcall popCal2 0001DE D??? 00504 rcall saveFSR2 ; set x MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 11 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0001E0 C001 FFDF 00505 movff temp + 1,INDF2 ; write byte 0001E4 D??? 00506 rcall restoreFSR2 0001E6 D??? 00507 bra iloop 00508 0001E8 00509 op6: 0001E8 0E2B 00510 movlw '+' 0001EA 6206 00511 cpfseq ch 0001EC D??? 00512 bra op7 00513 ; op = + (n1 n2 -- sum) (sum = n1 + n2) 0001EE D??? 00514 rcall popCal2 0001F0 5003 00515 movf x + 1,W 0001F2 2601 00516 addwf temp + 1,f 0001F4 5002 00517 movf x,W 0001F6 2200 00518 addwfc temp,f 0001F8 D??? 00519 bra pushCal 00520 0001FA 00521 op7: 0001FA 0E2D 00522 movlw '-' 0001FC 6206 00523 cpfseq ch 0001FE D??? 00524 bra op8 00525 ; op = - (n1 n2 -- diff) (diff = n1 - n2) 000200 D??? 00526 rcall sub16 ; pop 2 values and subtract 000202 D??? 00527 bra pushCal 00528 000204 00529 op8: 000204 0E3C 00530 movlw '<' 000206 6206 00531 cpfseq ch 000208 D??? 00532 bra op9 00533 ; op = < (n1 n2 -- f) (f = TRUE if n1 < n2) 00020A D??? 00534 rcall sub16 ; pop 2 values and subtract 00020C 6AE8 00535 clrf WREG ; false flag 00020E BE00 00536 btfsc temp,7 ; skip if >= 0 000210 0F01 00537 addlw 1 ; true flag 000212 D??? 00538 bra pushFlag 00539 000214 00540 op9: 000214 0E3D 00541 movlw '=' 000216 6206 00542 cpfseq ch 000218 D??? 00543 bra op10 00544 ; op = = (n1 n2 -- f) (f = TRUE if n1 = n2) 00021A D??? 00545 rcall sub16 ; pop 2 values and subtract 00021C 5000 00546 movf temp,W 00021E 1001 00547 iorwf temp + 1,W 000220 A4D8 00548 btfss STATUS,Z ; subtract = 0? 000222 68E8 00549 setf WREG ; no, clear flag (inverted on next instruction) 000224 1EE8 00550 comf WREG ; yes, set flag 000226 D??? 00551 bra pushFlag 00552 000228 00553 op10: 000228 0E3E 00554 movlw '>' 00022A 6206 00555 cpfseq ch 00022C D??? 00556 bra op11 00557 ; op = > (n1 n2 -- f) (f = TRUE if n1 > n2) MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 12 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00022E D??? 00558 rcall sub16 ; pop 2 values and subtract 000230 5000 00559 movf temp,W 000232 1001 00560 iorwf temp + 1,W ; subtract = 0? 000234 E0?? 00561 bz op10a ; yes, push false 000236 BE00 00562 btfsc temp,7 ; temp positive? (W != 0) 000238 6AE8 00563 clrf WREG ; no, push false 00564 00023A 00565 op10a: 00023A D??? 00566 bra pushFlag 00567 00023C 00568 op11: 00023C 0E2E 00569 movlw '.' 00023E 6206 00570 cpfseq ch 000240 D??? 00571 bra op12 00572 ; op = . -> get data from address on stack and push 000242 D??? 00573 rcall popAddr 000244 D??? 00574 rcall saveFSR2 ; set x -> FSR2 000246 CFDE F000 00575 movff POSTINC2,temp ; read word 00024A CFDF F001 00576 movff INDF2,temp + 1 00024E D??? 00577 rcall restoreFSR2 000250 D??? 00578 bra pushCal 00579 000252 00580 op12: 000252 0E2C 00581 movlw ',' 000254 6206 00582 cpfseq ch 000256 D??? 00583 bra op13 00584 ; op = , -> get byte from address on stack and push 000258 D??? 00585 rcall popAddr 00025A D??? 00586 rcall saveFSR2 ; set x -> FSR2 00025C CFDF F001 00587 movff INDF2,temp + 1 ; read byte 000260 6A00 00588 clrf temp ; clear upper byte 000262 D??? 00589 rcall restoreFSR2 000264 D??? 00590 bra pushCal 00591 000266 00592 op13: 000266 0E22 00593 movlw '"' 000268 6206 00594 cpfseq ch 00026A D??? 00595 bra op14 00596 ; op = " -> print string 00026C 00597 op13a: 00026C CFEE F006 00598 GETNEXT 000270 0E22 00599 movlw '"' 000272 1806 00600 xorwf ch,W ; end of string 000274 E0?? 00601 bz op14a ; yes, exit 00602 000276 0E21 00603 movlw '!' 000278 1806 00604 xorwf ch,W ; new line? 00027A E1?? 00605 bnz op13b ; no, just send the character 00027C D??? 00606 rcall crlf ; yes, send newline 00027E D??? 00607 bra op13a 00608 000280 00609 op13b: 000280 5006 00610 movf ch,W MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 13 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000282 D??? 00611 rcall putc 000284 D??? 00612 bra op13a 00613 000286 00614 op14: 000286 0E5B 00615 movlw '[' 000288 6206 00616 cpfseq ch 00028A D??? 00617 bra op15 00618 ; op = [ conditional if flag <= 0, skip until ']' 00028C D??? 00619 rcall popCal ; get flag 00028E BE00 00620 btfsc temp,7 ; negative? 000290 D??? 00621 bra skipCond ; yes, skip conditional 00622 000292 5000 00623 movf temp,W 000294 1801 00624 xorwf temp + 1,W ; zero? 000296 E1?? 00625 bnz op14a ; no, continue 00626 000298 00627 skipCond: ; yes, skip conditional 00628 ; skip a character from '[' to ']' 00629 ; handle nesting by using skipcnt 000298 0E01 00630 movlw 1 00029A 6E09 00631 movwf skipcnt 00632 00029C 00633 skiploop: 00029C CFEE F006 00634 GETNEXT ; do{ 0002A0 0E22 00635 movlw '"' ; quote? 0002A2 1806 00636 xorwf ch,W 0002A4 E1?? 00637 bnz skip2 ; no, try another test 0002A6 00638 skipstr: ; yes, skip until end quote found, ch = '"' 0002A6 CFEE F006 00639 GETNEXT 0002AA 0E22 00640 movlw '"' ; quote? 0002AC 1806 00641 xorwf ch,W 0002AE E1?? 00642 bnz skipstr 00643 0002B0 00644 skip2: 0002B0 0E5B 00645 movlw '[' ; test if [ 0002B2 1806 00646 xorwf ch,W 0002B4 B4D8 00647 btfsc STATUS,Z 0002B6 2A09 00648 incf skipcnt,f ; if matches left character, inc count 00649 0002B8 0E5D 00650 movlw ']' ; test if ] 0002BA 1806 00651 xorwf ch,W 0002BC B4D8 00652 btfsc STATUS,Z 0002BE 0609 00653 decf skipcnt,f ; if matches right character, dec count 00654 0002C0 0E01 00655 movlw 1 0002C2 6009 00656 cpfslt skipcnt ; }while (skipcnt > 0) 0002C4 D??? 00657 bra skiploop 00658 0002C6 00659 op14a: 0002C6 D??? 00660 bra iloop 00661 0002C8 00662 op15: 0002C8 0E40 00663 movlw '@' MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 14 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0002CA 6206 00664 cpfseq ch 0002CC D??? 00665 bra op16 00666 ; op = @ return from macro 00667 0002CE CFE4 FFEA 00668 movff PREINC1,FSR0H ; pop the previous character position 0002D2 CFE4 FFE9 00669 movff PREINC1,FSR0L 0002D6 D??? 00670 bra iloop 00671 0002D8 00672 op16: 0002D8 0E23 00673 movlw '#' 0002DA 6206 00674 cpfseq ch 0002DC D??? 00675 bra op17 00676 ; op = # call macro 00677 0002DE D??? 00678 rcall getMacro ; new position in temp 0002E0 E0?? 00679 bz undefined ; undefined, error 00680 0002E2 CFE9 FFE5 00681 movff FSR0L,POSTDEC1 0002E6 CFEA FFE5 00682 movff FSR0H,POSTDEC1 ; save current character position on stack 00683 0002EA 00684 newpos: 0002EA C000 FFEA 00685 movff temp,FSR0H ; go to new character position 0002EE C001 FFE9 00686 movff temp + 1,FSR0L 0002F2 D??? 00687 bra iloop 00688 0002F4 00689 op17: 0002F4 0E7D 00690 movlw '}' 0002F6 6206 00691 cpfseq ch 0002F8 D??? 00692 bra op18 00693 ; op = } go to label 00694 0002FA D??? 00695 rcall getMacro ; new position in temp 0002FC E1?? 00696 bnz newpos ; go to new position 00697 ; bra undefined ; undefined, error 00698 ; fall into undefined error 0002FE 00699 undefined: 0002FE D??? 00700 rcall perror 00701 000300 00702 op18: 000300 D??? 00703 bra iloop ; ignore any other character 00704 00705 00706 ;** branch locations for common operations 00707 00708 ; push a flag on stack (0 or 1) if W is 0 or not 0 000302 00709 pushFlag: 000302 A4D8 00710 btfss STATUS,Z ; if W = 0, save 000304 0E01 00711 movlw 1 ; else, save "TRUE" 000306 6E01 00712 movwf temp + 1 000308 6A00 00713 clrf temp 00714 ; drop into pushCal 00715 00716 ; push data from temp on to the calculation stack MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 15 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00717 ; FSR = 1 00030A 00718 pushCal: 00030A C001 FFE5 00719 movff temp + 1,POSTDEC1 00030E C000 FFE5 00720 movff temp,POSTDEC1 000312 D??? 00721 bra iloop 00722 00723 ; calculate offset into macro table from ch 000314 00724 calcOffset: 000314 0E41 00725 movlw 'A' 000316 5C06 00726 subwf ch,W ; get macro table offset 000318 90D8 00727 bcf STATUS,C ; clear carry 00031A 34E8 00728 rlcf WREG,W ; multiply by 2 for index, leave in w 00031C 0012 00729 return 00730 00731 ; calculate a macro/label address and place in temp 00732 ; set zero flag if address is undefined (= 0000) 00031E 00733 getMacro: 00031E 0E00 00734 movlw HIGH macdef 000320 6E02 00735 movwf x 000322 0EB4 00736 movlw LOW macdef 000324 6E03 00737 movwf x + 1 ; x = table start 000326 D??? 00738 rcall saveFSR2 ; save FSR2, x->FSR2 000328 CFEE F006 00739 GETNEXT ; get macro name 00032C D??? 00740 rcall calcOffset ; determine the offset into the table 00741 00032E 26D9 00742 addwf FSR2L,f ; FSR2 = macdef + offset 000330 6AE8 00743 clrf WREG 000332 22DA 00744 addwfc FSR2H,f 00745 000334 CFDE F000 00746 movff POSTINC2,temp ; read address from table into temp 000338 CFDF F001 00747 movff INDF2,temp + 1 00033C D??? 00748 rcall restoreFSR2 00749 00033E 5000 00750 movf temp,W 000340 1001 00751 iorwf temp + 1,W ; defined? (macro position != 0) 000342 0012 00752 return 00753 00754 ;**** end of interpreter loop 00755 00756 00757 ; signal an error condition 000344 00758 perror: 000344 0E21 00759 movlw '!' 000346 D??? 00760 bra putc 00761 00762 ;-- utility subroutines 00763 00764 ; save FSR2 in y, set FSR2 to x 000348 00765 saveFSR2: 000348 CFDA F004 00766 movff FSR2H,y 00034C CFD9 F005 00767 movff FSR2L,y + 1 ; save FSR2 000350 C002 FFDA 00768 movff x,FSR2H 000354 C003 FFD9 00769 movff x + 1,FSR2L ; point to address MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 16 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000358 0012 00770 return 00771 00772 ; restore FSR2 from y 00035A 00773 restoreFSR2: 00035A C004 FFDA 00774 movff y,FSR2H 00035E C005 FFD9 00775 movff y + 1,FSR2L ; restore FSR2 from y 000362 0012 00776 return 00777 00778 ; pop an address value from the stack into x 00779 ; FSR = 1 000364 00780 popAddr: 000364 CFE4 F002 00781 movff PREINC1,x 000368 CFE4 F003 00782 movff PREINC1,x + 1 00036C 0012 00783 return 00784 00785 ; FSR = 1 00786 ; get two values from the stack into x and temp 00036E 00787 popCal2: 00036E D??? 00788 rcall popAddr 00789 ; drop into popCal 00790 00791 ; pop data from the calculation stack into temp 00792 ; FSR = 1 000370 00793 popCal: 000370 CFE4 F000 00794 movff PREINC1,temp 000374 CFE4 F001 00795 movff PREINC1,temp + 1 000378 0012 00796 return 00797 00798 00799 ; get a character and echo 00037A 00800 getce: 00037A D??? 00801 rcall getc 00037C D??? 00802 bra putc 00803 00804 ; wait for a character from the serial port, return in W and store in 'ch' 00037E 00805 getc: 00037E AA9E 00806 btfss PIR1,5 ; check if character received 000380 D??? 00807 bra getc 000382 50AE 00808 movf RCREG,W ; get character 000384 6E06 00809 movwf ch ; save 000386 0012 00810 return 00811 00812 ; send a CR-LF pair to the serial port 000388 00813 crlf: 000388 0E0D 00814 movlw CR 00038A D??? 00815 rcall putc 00038C 0E0A 00816 movlw LF 00817 ; drop into putc 00818 00819 00820 ; send a character in W to the serial port 00038E 00821 putc: 00038E A89E 00822 btfss PIR1,4 ; check if transmit buffer empty MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 17 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000390 D??? 00823 bra putc 000392 6EAD 00824 movwf TXREG ; send character 000394 0012 00825 return 00826 00827 ; ASCII char to Hex Nibble (Myke Predko) 00828 ; and store in temp + 1 000396 00829 ASCIItoBIN: 000396 5006 00830 movf ch,W 000398 0FC0 00831 addlw 0xC0 ; if "A" to "F", set the carry flag 00039A A0D8 00832 btfss STATUS,C ; if carry set, then 'A' - 'F' 00039C 0F07 00833 addlw 7 ; add difference between '9' and 'A' 00039E 0F09 00834 addlw 9 0003A0 1201 00835 iorwf temp + 1,f ; add digit to temp 0003A2 0012 00836 return 00837 00838 ; subtract temp = temp - x 0003A4 00839 sub16: 0003A4 D??? 00840 rcall popCal2 0003A6 5003 00841 movf x + 1,W 0003A8 5E01 00842 subwf temp + 1,f 0003AA 5002 00843 movf x,W 0003AC 5A00 00844 subwfb temp,f 0003AE 0012 00845 return 00846 00847 00848 ; multiply temp by 16 0003B0 00849 mult16: 0003B0 0E04 00850 movlw 4 ; multiply temp by 16 0003B2 6E08 00851 movwf j ; 4 digits in temp 0003B4 00852 shift4: 0003B4 90D8 00853 bcf STATUS,C ; clear carry to shift in 0 0003B6 3601 00854 rlcf temp + 1,f 0003B8 3600 00855 rlcf temp,f ; temp << 1 0003BA 2E08 00856 decfsz j,f 0003BC D??? 00857 bra shift4 0003BE 0012 00858 return 00859 00860 00861 ; range checking functions 00862 ; return carry clear = valid letter, carry set = invalid letter 00863 ; check if valid hex digit 0003C0 00864 isHex: 0003C0 0E30 00865 movlw '0' ; check if ch is a digit '0' - '9' 0003C2 6E0A 00866 movwf lolim 0003C4 0E39 00867 movlw '9' 0003C6 6E0B 00868 movwf hilim 0003C8 D??? 00869 rcall range 0003CA A0D8 00870 btfss STATUS,C ; 0-9? 0003CC 0012 00871 return ; yes, return 00872 0003CE 0E5F 00873 movlw 0x5F 0003D0 1606 00874 andwf ch,f ; no, convert to upper case 0003D2 0E41 00875 movlw 'A' MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 18 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0003D4 6E0A 00876 movwf lolim 0003D6 0E46 00877 movlw 'F' 0003D8 6E0B 00878 movwf hilim 0003DA D??? 00879 bra range ; A-F? 00880 00881 ; check if ch is a lower case letter 'a' - 'z' 0003DC 00882 isLower: 0003DC 0E61 00883 movlw 'a' 0003DE 6E0A 00884 movwf lolim 0003E0 0E7A 00885 movlw 'z' 0003E2 6E0B 00886 movwf hilim 00887 ; drop into range 00888 ; check if ch is within a range defined by lolim and hilim 0003E4 00889 range: 0003E4 80D8 00890 bsf STATUS,C ; indicate invalid 0003E6 500A 00891 movf lolim,W 0003E8 6006 00892 cpfslt ch ; skip if ch < low limit 0003EA D??? 00893 bra rangeHi ; valid, check high limit 0003EC D??? 00894 bra invRange ; invalid 00895 0003EE 00896 rangeHi: 0003EE 500B 00897 movf hilim,W 0003F0 6406 00898 cpfsgt ch ; skip if ch > high limit 0003F2 90D8 00899 bcf STATUS,C ; ch <= high limit 00900 0003F4 00901 invRange: 0003F4 0012 00902 return 00903 00904 ; clear 16 bit temp register 0003F6 00905 clrtemp: 0003F6 6A00 00906 clrf temp 0003F8 6A01 00907 clrf temp + 1 0003FA 0012 00908 return 00909 00910 00911 ;-- debugging routines 00912 ;-- only enabled for interpreter debugging 00913 00914 ifdef DEBUG 00915 00916 ; display the current character address and command 00917 ; format: aaaa:c~ 00918 trace: 00919 rcall crlf 00920 movff FSR0H,temp ; get upper byte 00921 movff FSR0L,temp + 1 ; get lower byte 00922 rcall outTemp 00923 movlw ':' 00924 rcall putc 00925 00926 movlw SPC 00927 cpfslt INDF0 ; ctrl char? 00928 bra notCtl MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 19 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00929 00930 movlw '^' ; yes, display control character as ^ 00931 rcall putc 00932 movf INDF0,W 00933 addlw 0x40 00934 bra continue 00935 notCtl: 00936 movf INDF0,W ; no, display as standard character 00937 continue: 00938 rcall putc 00939 movlw '~' 00940 rcall putc 00941 return 00942 00943 ; dump program memory (after loader) 00944 dumpp: 00945 rcall crlf 00946 lfsr 0,pgmstart 00947 movlw EOF 00948 movwf temp 00949 dump0: 00950 movf POSTINC0,W ; get character 00951 call putc 00952 cpfseq temp ; go until end of file 00953 bra dump0 00954 movlw '\\' 00955 rcall putc ; indicate end of file reached 00956 00957 bra main ; done 00958 00959 ; dump macro table (after loader) 00960 dumpt: 00961 lfsr 0,macdef 00962 movlw MACSIZ/2 00963 movwf i 00964 movlw 'A' 00965 movwf ch ; ch = variable name 00966 00967 dumpt0: ; print : hhhh\n 00968 rcall crlf 00969 movf ch,W 00970 rcall putc ; print name 00971 movlw ':' 00972 rcall putc ; print ':' 00973 00974 movff POSTINC0,temp ; get upper byte 00975 movff POSTINC0,temp + 1 ; get lower byte 00976 rcall outTemp 00977 00978 incf ch,f 00979 00980 decfsz i,f 00981 bra dumpt0 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 20 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00982 00983 bra main 00984 00985 outTemp: 00986 swapf temp,W 00987 andlw 0x0F 00988 rcall outHex 00989 00990 movf temp,W 00991 andlw 0x0F 00992 rcall outHex 00993 00994 swapf temp + 1,W 00995 andlw 0x0F 00996 rcall outHex 00997 00998 movf temp + 1,W 00999 andlw 0x0F 01000 rcall outHex 01001 01002 movlw ' ' 01003 rcall putc 01004 return 01005 01006 ; Hex Nibble to ASCII (Myke Predko) 01007 outHex: 01008 addlw 0x36 ; add '0' + 6 to value 01009 btfsc STATUS,DC ; if digit carry set, then 'A' - 'F' 01010 addlw 7 ; add difference between '9' and 'A' 01011 addlw 0-6 01012 bra putc 01013 01014 endif 01015 01016 01017 END MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 21 SYMBOL TABLE LABEL VALUE A 00000000 ABDEN 00000000 ABDOVF 00000007 ACCESS 00000000 ACKDT 00000005 ACKEN 00000004 ACKSTAT 00000006 ACQT0 00000003 ACQT1 00000004 ACQT2 00000005 ADCON0 00000FC2 ADCON1 00000FC1 ADCON2 00000FC0 ADCS0 00000000 ADCS1 00000001 ADCS2 00000002 ADDEN 00000003 ADEN 00000003 ADFM 00000007 ADIE 00000006 ADIF 00000006 ADIP 00000006 ADON 00000000 ADRES 00000FC3 ADRESH 00000FC4 ADRESL 00000FC3 AN10 00000001 AN11 00000004 AN12 00000000 AN4 00000005 AN8 00000002 AN9 00000003 ASCIItoBIN 00000396 BANKED 00000001 BAUDCON 00000FB8 BAUDCTL 00000FB8 BCLIE 00000003 BCLIF 00000003 BCLIP 00000003 BF 00000000 BGST 00000005 BOR 00000000 BRG16 00000003 BRGH 00000002 BS 00000008 BSR 00000FE0 C 00000000 C1INV 00000004 C1OUT 00000006 C2INV 00000005 C2OUT 00000007 CAN 00000003 CCP1 00000002 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 22 SYMBOL TABLE LABEL VALUE CCP1CON 00000FBD CCP1IE 00000002 CCP1IF 00000002 CCP1IP 00000002 CCP1M0 00000000 CCP1M1 00000001 CCP1M2 00000002 CCP1M3 00000003 CCP1X 00000005 CCP1Y 00000004 CCP2CON 00000FBA CCP2IE 00000000 CCP2IF 00000000 CCP2IP 00000000 CCP2M0 00000000 CCP2M1 00000001 CCP2M2 00000002 CCP2M3 00000003 CCP2X 00000005 CCP2Y 00000004 CCP2_PORTB 00000003 CCP2_PORTC 00000001 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 CKE 00000006 CKP 00000004 CM0 00000000 CM1 00000001 CM2 00000002 CMCON 00000FB4 CMIE 00000006 CMIF 00000006 CMIP 00000006 CR 0000000D CREN 00000004 CSRC 00000007 CVR0 00000000 CVR1 00000001 CVR2 00000002 CVR3 00000003 CVRCON 00000FB5 CVREN 00000007 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 23 SYMBOL TABLE LABEL VALUE CVROE 00000006 CVRR 00000005 CVRSS 00000004 D 00000005 DC 00000001 DC1B0 00000004 DC1B1 00000005 DC2B0 00000004 DC2B1 00000005 DDRA TRISA DDRB TRISB DDRC TRISC DDRD TRISD DDRE TRISE DONE 00000001 D_A 00000005 D_NOT_A 00000005 ECCP1AS 00000FB6 ECCP1DEL 00000FB7 ECCPAS 00000FB6 ECCPAS0 00000004 ECCPAS1 00000005 ECCPAS2 00000006 ECCPASE 00000007 EEADR 00000FA9 EEADRH 00000FAA EECON1 00000FA6 EECON2 00000FA7 EEDATA 00000FA8 EEIE 00000004 EEIF 00000004 EEIP 00000004 EEPGD 00000007 ENVSIZ 00000008 EOF 000000FF FAST 00000001 FERR 00000002 FREE 00000004 FSR0 00000000 FSR0H 00000FEA FSR0L 00000FE9 FSR1 00000001 FSR1H 00000FE2 FSR1L 00000FE1 FSR2 00000002 FSR2H 00000FDA FSR2L 00000FD9 GCEN 00000007 GETNEXT movff POSTINC0,ch GIE 00000007 GIEH 00000007 GIEL 00000006 GIE_GIEH 00000007 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 24 SYMBOL TABLE LABEL VALUE GO 00000001 GO_DONE 00000001 GO_NOT_DONE 00000001 HLVDCON 00000FD2 HLVDEN 00000004 HLVDIE 00000002 HLVDIF 00000002 HLVDIN 00000005 HLVDIP 00000002 HLVDL0 00000000 HLVDL1 00000001 HLVDL2 00000002 HLVDL3 00000003 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 INTSRC 00000007 IOFS 00000002 IPEN 00000007 IPR1 00000F9F IPR2 00000FA2 IRCF0 00000004 IRCF1 00000005 IRCF2 00000006 IRVST 00000005 IVRST 00000005 KBI0 00000004 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 25 SYMBOL TABLE LABEL VALUE KBI1 00000005 KBI2 00000006 KBI3 00000007 LATA 00000F89 LATA0 00000000 LATA1 00000001 LATA2 00000002 LATA3 00000003 LATA4 00000004 LATA5 00000005 LATA6 00000006 LATA7 00000007 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 LATC3 00000003 LATC4 00000004 LATC5 00000005 LATC6 00000006 LATC7 00000007 LF 0000000A 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 MACSIZ 00000034 MAXLVL 00000008 MCLR 00000003 N 00000004 NOT_A 00000005 NOT_ADDRESS 00000005 NOT_BOR 00000000 NOT_DONE 00000001 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 26 SYMBOL TABLE LABEL VALUE NOT_MCLR 00000003 NOT_PD 00000002 NOT_POR 00000001 NOT_RBPU 00000007 NOT_RI 00000004 NOT_SS 00000005 NOT_T1SYNC 00000002 NOT_T3SYNC 00000002 NOT_TO 00000003 NOT_W 00000002 NOT_WRITE 00000002 OERR 00000001 OSCCON 00000FD3 OSCFIE 00000007 OSCFIF 00000007 OSCFIP 00000007 OSCTUNE 00000F9B OSTS 00000003 OV 00000003 P 00000004 PC 00000FF9 PCFG0 00000000 PCFG1 00000001 PCFG2 00000002 PCFG3 00000003 PCL 00000FF9 PCLATH 00000FFA PCLATU 00000FFB PD 00000002 PEIE 00000006 PEIE_GIEL 00000006 PEN 00000002 PGC 00000006 PGD 00000007 PGM 00000005 PIE1 00000F9D PIE2 00000FA0 PIR1 00000F9E PIR2 00000FA1 PLLEN 00000006 PLUSW0 00000FEB PLUSW1 00000FE3 PLUSW2 00000FDB POR 00000001 PORTA 00000F80 PORTB 00000F81 PORTC 00000F82 PORTE 00000F84 POSTDEC0 00000FED POSTDEC1 00000FE5 POSTDEC2 00000FDD POSTINC0 00000FEE POSTINC1 00000FE6 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 27 SYMBOL TABLE LABEL VALUE POSTINC2 00000FDE PR2 00000FCB PREINC0 00000FEC PREINC1 00000FE4 PREINC2 00000FDC PROD 00000FF3 PRODH 00000FF4 PRODL 00000FF3 PROMPT 0000002E PRSEN 00000007 PSA 00000003 PSSAC0 00000002 PSSAC1 00000003 PWM1CON 00000FB7 R 00000002 RA0 00000000 RA1 00000001 RA2 00000002 RA3 00000003 RA4 00000004 RA5 00000005 RA6 00000006 RA7 00000007 RB0 00000000 RB1 00000001 RB2 00000002 RB3 00000003 RB4 00000004 RB5 00000005 RB6 00000006 RB7 00000007 RBIE 00000003 RBIF 00000000 RBIP 00000000 RBPU 00000007 RC0 00000000 RC1 00000001 RC2 00000002 RC3 00000003 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 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 28 SYMBOL TABLE LABEL VALUE RD16 00000007 RE3 00000003 RI 00000004 RSEN 00000001 RX 00000007 RX9 00000006 RX9D 00000000 RXCKP 00000005 RXDTP 00000005 R_NOT_W 00000002 R_W 00000002 S 00000003 SBOREN 00000006 SCK 00000003 SCKP 00000004 SCL 00000003 SCS0 00000000 SCS1 00000001 SDA 00000004 SDI 00000004 SDO 00000005 SEN 00000000 SENDB 00000003 SMP 00000007 SP0 00000000 SP1 00000001 SP2 00000002 SP3 00000003 SP4 00000004 SPBRG 00000FAF SPBRGH 00000FB0 SPC 00000020 SPEN 00000007 SREN 00000005 SS 00000005 SSPADD 00000FC8 SSPBUF 00000FC9 SSPCON1 00000FC6 SSPCON2 00000FC5 SSPEN 00000005 SSPIE 00000003 SSPIF 00000003 SSPIP 00000003 SSPM0 00000000 SSPM1 00000001 SSPM2 00000002 SSPM3 00000003 SSPOV 00000006 SSPSTAT 00000FC7 STATUS 00000FD8 STKFUL 00000007 STKOVF 00000007 STKPTR 00000FFC MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 29 SYMBOL TABLE LABEL VALUE STKPTR0 00000000 STKPTR1 00000001 STKPTR2 00000002 STKPTR3 00000003 STKPTR4 00000004 STKSIZ 00000020 STKUNF 00000006 SWDTE 00000000 SWDTEN 00000000 SYNC 00000004 T016BIT 00000006 T08BIT 00000006 T0CKI 00000004 T0CON 00000FD5 T0CS 00000005 T0IE 00000005 T0IF 00000002 T0PS0 00000000 T0PS1 00000001 T0PS2 00000002 T0SE 00000004 T13CKI 00000000 T1CKI 00000000 T1CKPS0 00000004 T1CKPS1 00000005 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 T3SYNC 00000002 TABLAT 00000FF5 TBLPTR 00000FF6 TBLPTRH 00000FF7 TBLPTRL 00000FF6 TBLPTRU 00000FF8 TMR0 00000FD6 TMR0H 00000FD7 TMR0IE 00000005 TMR0IF 00000002 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 30 SYMBOL TABLE LABEL VALUE TMR0IP 00000002 TMR0L 00000FD6 TMR0ON 00000007 TMR1 00000FCE TMR1CS 00000001 TMR1H 00000FCF TMR1IE 00000000 TMR1IF 00000000 TMR1IP 00000000 TMR1L 00000FCE TMR1ON 00000000 TMR2 00000FCC TMR2IE 00000001 TMR2IF 00000001 TMR2IP 00000001 TMR2ON 00000002 TMR3 00000FB2 TMR3CS 00000001 TMR3H 00000FB3 TMR3IE 00000001 TMR3IF 00000001 TMR3IP 00000001 TMR3L 00000FB2 TMR3ON 00000000 TO 00000003 TOS 00000FFD TOSH 00000FFE TOSL 00000FFD TOSU 00000FFF TRISA 00000F92 TRISA0 00000000 TRISA1 00000001 TRISA2 00000002 TRISA3 00000003 TRISA4 00000004 TRISA5 00000005 TRISA6 00000006 TRISA7 00000007 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 TRISC3 00000003 TRISC4 00000004 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 31 SYMBOL TABLE LABEL VALUE TRISC5 00000005 TRISC6 00000006 TRISC7 00000007 TRMT 00000001 TUN0 00000000 TUN1 00000001 TUN2 00000002 TUN3 00000003 TUN4 00000004 TX 00000006 TX9 00000006 TX9D 00000000 TXCKP 00000004 TXEN 00000005 TXIE 00000004 TXIF 00000004 TXIP 00000004 TXREG 00000FAD TXSTA 00000FAC UA 00000001 UNGET movf POSTDEC0,W VARSIZ 00000034 VCFG0 00000004 VCFG1 00000005 VDIRMAG 00000007 VPP 00000003 W 00000000 WCOL 00000007 WDTCON 00000FD1 WR 00000001 WREG 00000FE8 WREN 00000002 WRERR 00000003 WUE 00000001 Z 00000002 _BOREN_NOSLP_2L 000000FD _BOREN_OFF_2L 000000F9 _BOREN_ON_2L 000000FB _BOREN_SBORDIS_2L 000000FF _BORV_0_2L 000000E7 _BORV_1_2L 000000EF _BORV_2_2L 000000F7 _BORV_3_2L 000000FF _CCP2MX_PORTBE_3H 000000FE _CCP2MX_PORTC_3H 000000FF _CONFIG1H 00300001 _CONFIG2H 00300003 _CONFIG2L 00300002 _CONFIG3H 00300005 _CONFIG4L 00300006 _CONFIG5H 00300009 _CONFIG5L 00300008 _CONFIG6H 0030000B MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 32 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 _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 _FCMEN_OFF_1H 000000BF _FCMEN_ON_1H 000000FF _IDLOC0 00200000 _IDLOC1 00200001 _IDLOC2 00200002 _IDLOC3 00200003 _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 _OSC_ECIO6_1H 000000F5 _OSC_EC_1H 000000F4 _OSC_HSPLL_1H 000000F6 _OSC_HS_1H 000000F2 _OSC_INTIO67_1H 000000F8 _OSC_INTIO7_1H 000000F9 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 33 SYMBOL TABLE LABEL VALUE _OSC_LP_1H 000000F0 _OSC_RCIO6_1H 000000F7 _OSC_RC_1H 000000F3 _OSC_XT_1H 000000F1 _PBADEN_OFF_3H 000000FD _PBADEN_ON_3H 000000FF _PWRT_OFF_2L 000000FF _PWRT_ON_2L 000000FE _STVREN_OFF_4L 000000FE _STVREN_ON_4L 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 _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 __18F2620 00000001 calcOffset 00000314 calstk 00000107 calstp 000000E8 ch 00000006 clrmac 00000066 clrtemp 000003F6 crlf 00000388 done 000000EC MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 34 SYMBOL TABLE LABEL VALUE endload 000000E8 envstk 0000010F envstp 00000108 getMacro 0000031E getc 0000037E getce 0000037A globvar 00000080 hilim 0000000B i 00000007 iloop 00000102 iloop0 0000010C interp 000000EE invCmd 0000005A invRange 000003F4 isHex 000003C0 isLower 000003DC j 00000008 ldloop 00000076 loader 0000005E lolim 0000000A macdef 000000B4 main 00000040 mult16 000003B0 newpos 000002EA op0 00000138 op0a 00000140 op1 00000152 op10 00000228 op10a 0000023A op11 0000023C op12 00000252 op13 00000266 op13a 0000026C op13b 00000280 op14 00000286 op14a 000002C6 op15 000002C8 op16 000002D8 op17 000002F4 op18 00000300 op1a 0000016A op2 00000186 op2a 0000019E op2b 000001A0 op2c 000001AC op3 000001AE op4 000001C0 op5 000001D6 op6 000001E8 op7 000001FA op8 00000204 op9 00000214 perror 00000344 MPASM 5.59 KMOUSE.ASM 1-2-2017 22:36:05 PAGE 35 SYMBOL TABLE LABEL VALUE pgmstart 00000110 popAddr 00000364 popCal 00000370 popCal2 0000036E pushCal 0000030A pushFlag 00000302 pushnum 0000014E putHex 0000016C putHex0 00000170 putc 0000038E range 000003E4 rangeHi 000003EE reg_cr 0000000D reg_spc 0000000C restoreFSR2 0000035A saveFSR2 00000348 savech 000000DC savestr 000000B0 shift4 000003B4 skip2 000002B0 skipCond 00000298 skipbl 00000084 skipcnt 00000009 skipeol 00000098 skiploop 0000029C skipstr 000002A6 start 00000020 sub16 000003A4 temp 00000000 testch 00000092 testch1 000000A2 testch2 000000BA tstLower 00000118 tstOp 00000132 tstctl 0000008A tstend 00000110 undefined 000002FE x 00000002 y 00000004 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 0 reported, 0 suppressed