1 radix dec 2 0020 global__variables__bank0 equ 32 3 00e0 global__variables__bank1 equ 224 4 0042 global__bit__variables__bank0 equ 66 5 00e0 global__bit__variables__bank1 equ 224 6 0000 indf___register equ 0 7 0002 pcl___register equ 2 8 0003 c___byte equ 3 9 0000 c___bit equ 0 10 0003 z___byte equ 3 11 0002 z___bit equ 2 12 0003 rp0___byte equ 3 13 0005 rp0___bit equ 5 14 0003 rp1___byte equ 3 15 0006 rp1___bit equ 6 16 0003 irp___byte equ 3 17 0007 irp___bit equ 7 18 0085 trisa___register equ 0x85 19 0086 trisb___register equ 0x86 20 0004 fsr___register equ 4 21 000a pclath___register equ 10 22 org 0 23 start: 24 000 0000 nop 25 001 0000 nop 26 002 0000 nop 27 003 2805 goto skip___interrupt 28 interrupt___vector: 29 004 0009 retfie 30 skip___interrupt: 31 ; Use oscillator calibration stored in high memory 32 005 23ff call 1023 33 ; Switch from register bank 0 to register bank 1 (which contains 144) 34 006 1683 bsf rp0___byte,rp0___bit 35 ; Register bank is now 1 36 007 0090 movwf 144 37 ; Initialize A/D system to allow digital I/O 38 008 0191 clrf 145 39 009 3007 movlw 7 40 ; Switch from register bank 1 to register bank 0 (which contains 25) 41 00a 1283 bcf rp0___byte,rp0___bit 42 ; Register bank is now 0 43 00b 0099 movwf 25 44 00c 019f clrf 31 45 ; Initialize TRIS registers 46 00d 30e8 movlw 232 47 00e 0065 tris 5 48 00f 30f1 movlw 241 49 010 0067 tris 7 50 011 018a clrf pclath___register 51 012 297a goto main 52 ; comment ############################################################################# 53 ; comment {} 54 ; comment {Copyright < c > 2000 - 2003 by Wayne C . Gramlich & William T . Benson .} 55 ; comment {All rights reserved .} 56 ; comment {} 57 ; comment {Permission to use , copy , modify , distribute , and sell this software} 58 ; comment {for any purpose is hereby granted without fee provided that the above} 59 ; comment {copyright notice and this permission are retained . The author makes} 60 ; comment {no representations about the suitability of this software for any purpose .} 61 ; comment {It is provided { as is } without express or implied warranty .} 62 ; comment {} 63 ; comment {This is the code that implements the Motor2 RoboBrick . Basically} 64 ; comment {it just waits for commands that come in at 2400 baud and responds} 65 ; comment {to them . See :} 66 ; comment {} 67 ; comment {http : / / gramlich . net / projects / robobricks / motor2 / index . html} 68 ; comment {} 69 ; comment {for more details .} 70 ; comment {} 71 ; comment ############################################################################# 72 ; processor pic16f676 bg = bg00 cpd = off cp = off boden = off mclre = off pwrte = off wdte = off fosc = intrc 73 ; 404=0x194 8199=0x2007 74 __config 404 75 2007 configuration___address equ 8199 76 ; comment {Define processor constants :} 77 ; constant clock_rate 4000000 78 3d0900 clock_rate equ 4000000 79 ; constant clocks_per_instruction 4 80 0004 clocks_per_instruction equ 4 81 ; constant instruction_rate clock_rate / clocks_per_instruction 82 f4240 instruction_rate equ 1000000 83 ; comment {Define serial communication control constants :} 84 ; constant baud_rate 2400 85 0960 baud_rate equ 2400 86 ; constant instructions_per_bit instruction_rate / baud_rate 87 01a0 instructions_per_bit equ 416 88 ; constant delays_per_bit 3 89 0003 delays_per_bit equ 3 90 ; constant instructions_per_delay instructions_per_bit / delays_per_bit 91 008a instructions_per_delay equ 138 92 ; constant extra_instructions_per_bit 9 93 0009 extra_instructions_per_bit equ 9 94 ; constant extra_instructions_per_delay extra_instructions_per_bit / delays_per_bit 95 0003 extra_instructions_per_delay equ 3 96 ; constant delay_instructions instructions_per_delay - extra_instructions_per_delay 97 0087 delay_instructions equ 135 98 ; comment {Register definitions :} 99 ; comment {TMR0 register :} 100 0001 tmr0 equ 1 101 ; comment {STATUS register :} 102 0003 status equ 3 103 ; bind c status @ 0 104 0003 c equ status+0 105 0003 c__byte equ status+0 106 0000 c__bit equ 0 107 ; bind z status @ 2 108 0003 z equ status+0 109 0003 z__byte equ status+0 110 0002 z__bit equ 2 111 ; comment {OSCCAL register :} 112 0090 osccal equ 144 113 ; constant osccal_unit 4 114 0004 osccal_unit equ 4 115 ; comment {On the 630 / 676 , the OPTION register has the following bits :} 116 0081 option equ 129 117 ; constant rapu_bit 7 118 0007 rapu_bit equ 7 119 ; constant intedg_bit 6 120 0006 intedg_bit equ 6 121 ; constant t0cs_bit 5 122 0005 t0cs_bit equ 5 123 ; constant t0se_bit 4 124 0004 t0se_bit equ 4 125 ; constant psa_bit 3 126 0003 psa_bit equ 3 127 ; constant ps2_bit 2 128 0002 ps2_bit equ 2 129 ; constant ps1_bit 1 130 0001 ps1_bit equ 1 131 ; constant ps0_bit 0 132 0000 ps0_bit equ 0 133 ; constant rapu_mask {{ 1 << rapu_bit }} 134 0080 rapu_mask equ 128 135 ; constant intedg_mask {{ 1 << intedg_bit }} 136 0040 intedg_mask equ 64 137 ; constant t0cs_mask {{ 1 << t0cs_bit }} 138 0020 t0cs_mask equ 32 139 ; constant t0se_mask {{ 1 << t0se_bit }} 140 0010 t0se_mask equ 16 141 ; constant psa_mask {{ 1 << psa_bit }} 142 0008 psa_mask equ 8 143 ; comment {Disable Wake - up and pull - ups {;} set timer to internal {;} edge_source to raising :} 144 ; constant option_mask rapu_mask 145 0080 option_mask equ 128 146 ; comment {INTCON :} 147 000b intcon equ 11 148 ; constant gie_bit 0 149 0000 gie_bit equ 0 150 ; constant peie_bit 0 151 0000 peie_bit equ 0 152 ; constant t0ie_bit 0 153 0000 t0ie_bit equ 0 154 ; constant inte_bit 0 155 0000 inte_bit equ 0 156 ; constant raie_bit 0 157 0000 raie_bit equ 0 158 ; constant t0if_bit 0 159 0000 t0if_bit equ 0 160 ; constant intf_bit 0 161 0000 intf_bit equ 0 162 ; constant raif_bit 0 163 0000 raif_bit equ 0 164 ; comment {WPUA :} 165 0095 wpua equ 149 166 ; comment {Define port A bit assignments :} 167 ; constant motor0a_bit 0 168 0000 motor0a_bit equ 0 169 ; constant motor0b_bit 1 170 0001 motor0b_bit equ 1 171 ; constant motor1b_bit 2 172 0002 motor1b_bit equ 2 173 ; constant unused1_bit 3 174 0003 unused1_bit equ 3 175 ; constant motor1a_bit 4 176 0004 motor1a_bit equ 4 177 ; constant unused0_bit 5 178 0005 unused0_bit equ 5 179 0005 porta equ 5 180 0005 motor0a__byte equ 5 181 0000 motor0a__bit equ 0 182 0005 motor0b__byte equ 5 183 0001 motor0b__bit equ 1 184 0005 motor1b__byte equ 5 185 0002 motor1b__bit equ 2 186 0005 unused0__byte equ 5 187 0005 unused0__bit equ 5 188 0005 motor1a__byte equ 5 189 0004 motor1a__bit equ 4 190 0005 unsued1__byte equ 5 191 0003 unsued1__bit equ 3 192 ; comment {Define port C bit assignments :} 193 ; constant serial_in_bit 0 194 0000 serial_in_bit equ 0 195 ; constant serial_out_bit 1 196 0001 serial_out_bit equ 1 197 ; constant motor0e_bit 2 198 0002 motor0e_bit equ 2 199 ; constant motor1e_bit 3 200 0003 motor1e_bit equ 3 201 ; constant unused2_bit 4 202 0004 unused2_bit equ 4 203 ; constant unused3_bit 5 204 0005 unused3_bit equ 5 205 0007 portc equ 7 206 0007 serial_in__byte equ 7 207 0000 serial_in__bit equ 0 208 0007 serial_out__byte equ 7 209 0001 serial_out__bit equ 1 210 0007 motor0e__byte equ 7 211 0002 motor0e__bit equ 2 212 0007 motor1e__byte equ 7 213 0003 motor1e__bit equ 3 214 0007 unused2__byte equ 7 215 0004 unused2__bit equ 4 216 0007 unsued3__byte equ 7 217 0004 unsued3__bit equ 4 218 ; comment {Define some masks :} 219 ; constant motor0a_mask {{ 1 << motor0a_bit }} 220 0001 motor0a_mask equ 1 221 ; constant motor0e_mask {{ 1 << motor0e_bit }} 222 0004 motor0e_mask equ 4 223 ; constant motor0b_mask {{ 1 << motor0b_bit }} 224 0002 motor0b_mask equ 2 225 ; constant motor1a_mask {{ 1 << motor1a_bit }} 226 0010 motor1a_mask equ 16 227 ; constant motor1e_mask {{ 1 << motor1e_bit }} 228 0008 motor1e_mask equ 8 229 ; constant motor1b_mask {{ 1 << motor1b_bit }} 230 0004 motor1b_mask equ 4 231 ; constant serial_in_mask {{ 1 << serial_in_bit }} 232 0001 serial_in_mask equ 1 233 ; constant serial_out_mask {{ 1 << serial_out_bit }} 234 0002 serial_out_mask equ 2 235 ; comment {Define duty cycle and motor on / off masks :} 236 0020 actual_speed0 equ global__variables__bank0+0 237 0021 actual_speed1 equ global__variables__bank0+1 238 0022 motor0_off equ global__variables__bank0+2 239 0023 motor0_on equ global__variables__bank0+3 240 0024 motor1_off equ global__variables__bank0+4 241 0025 motor1_on equ global__variables__bank0+5 242 ; comment {Ramp variables :} 243 0026 desired_speed0 equ global__variables__bank0+6 244 0027 desired_speed1 equ global__variables__bank0+7 245 0028 ramp0 equ global__variables__bank0+8 246 0029 ramp1 equ global__variables__bank0+9 247 002a ramp0_delay equ global__variables__bank0+10 248 002b ramp1_delay equ global__variables__bank0+11 249 002c ramp0_offset equ global__variables__bank0+12 250 002d ramp1_offset equ global__variables__bank0+13 251 ; comment {Fail safe variables :} 252 002e fail_safe equ global__variables__bank0+14 253 002f fail_safe_errors equ global__variables__bank0+15 254 0030 fail_safe_high_counter equ global__variables__bank0+16 255 0031 fail_safe_low_counter equ global__variables__bank0+17 256 0032 motor0 equ global__variables__bank0+18 257 0033 motor1 equ global__variables__bank0+19 258 ; comment {Mode < pulsed vs . continuous > bits :} 259 0042 motor0_mode equ global__bit__variables__bank0+0 260 0042 motor0_mode__byte equ global__bit__variables__bank0+0 261 0000 motor0_mode__bit equ 0 262 0042 motor1_mode equ global__bit__variables__bank0+0 263 0042 motor1_mode__byte equ global__bit__variables__bank0+0 264 0001 motor1_mode__bit equ 1 265 0042 motor0_direction equ global__bit__variables__bank0+0 266 0042 motor0_direction__byte equ global__bit__variables__bank0+0 267 0002 motor0_direction__bit equ 2 268 0042 motor1_direction equ global__bit__variables__bank0+0 269 0042 motor1_direction__byte equ global__bit__variables__bank0+0 270 0003 motor1_direction__bit equ 3 271 ; comment {Shared command registers and option :} 272 0034 glitch equ global__variables__bank0+20 273 0035 id_index equ global__variables__bank0+21 274 0036 spare equ global__variables__bank0+22 275 ; string_constants Start 276 string___fetch: 277 013 0082 movwf pcl___register 278 ; id = 1 , 0 , 14 , 2 , 0 , 0 , 0 , 0 , 0r'16' , 7 , 0s'Motor2D' , 15 , 0s'Gramlich&Benson' 279 0000 id___string equ 0 280 id: 281 014 0782 addwf pcl___register,f 282 ; Length = 48 283 015 3430 retlw 48 284 ; 1 285 016 3401 retlw 1 286 ; 0 287 017 3400 retlw 0 288 ; 14 289 018 340e retlw 14 290 ; 2 291 019 3402 retlw 2 292 ; 0 293 01a 3400 retlw 0 294 ; 0 295 01b 3400 retlw 0 296 ; 0 297 01c 3400 retlw 0 298 ; 0 299 01d 3400 retlw 0 300 ; 0r'16' 301 01e 348c retlw 140 ; random number 302 01f 34ce retlw 206 ; random number 303 020 340b retlw 11 ; random number 304 021 34e6 retlw 230 ; random number 305 022 34b9 retlw 185 ; random number 306 023 349f retlw 159 ; random number 307 024 3459 retlw 89 ; random number 308 025 343b retlw 59 ; random number 309 026 3419 retlw 25 ; random number 310 027 34fb retlw 251 ; random number 311 028 3476 retlw 118 ; random number 312 029 3411 retlw 17 ; random number 313 02a 34fb retlw 251 ; random number 314 02b 34f7 retlw 247 ; random number 315 02c 3431 retlw 49 ; random number 316 02d 3497 retlw 151 ; random number 317 ; 7 318 02e 3407 retlw 7 319 ; `Motor2D' 320 02f 344d retlw 77 321 030 346f retlw 111 322 031 3474 retlw 116 323 032 346f retlw 111 324 033 3472 retlw 114 325 034 3432 retlw 50 326 035 3444 retlw 68 327 ; 15 328 036 340f retlw 15 329 ; `Gramlich&Benson' 330 037 3447 retlw 71 331 038 3472 retlw 114 332 039 3461 retlw 97 333 03a 346d retlw 109 334 03b 346c retlw 108 335 03c 3469 retlw 105 336 03d 3463 retlw 99 337 03e 3468 retlw 104 338 03f 3426 retlw 38 339 040 3442 retlw 66 340 041 3465 retlw 101 341 042 346e retlw 110 342 043 3473 retlw 115 343 044 346f retlw 111 344 045 346e retlw 110 345 ; string__constants End 346 ; comment {Globals :} 347 0042 receiving equ global__bit__variables__bank0+0 348 0042 receiving__byte equ global__bit__variables__bank0+0 349 0004 receiving__bit equ 4 350 351 ; procedure get_byte start 352 get_byte: 353 0037 get_byte__variables__base equ global__variables__bank0+23 354 0037 get_byte__bytes__base equ get_byte__variables__base+0 355 003a get_byte__bits__base equ get_byte__variables__base+3 356 0004 get_byte__total__bytes equ 4 357 ; arguments_none 358 0037 get_byte__0return__byte equ get_byte__bytes__base+0 359 ; Wait for a character and return it . 360 ; The get_byte < > procedure only waits for 9 - 2 / 3 bits . That 361 ; way the next call to get_byte < > will sychronize on the start 362 ; bit instead of possibly starting a little later . 363 0038 get_byte__count equ get_byte__bytes__base+1 364 0039 get_byte__char equ get_byte__bytes__base+2 365 ; Wait for start bit : 366 ; receiving := 1 367 046 1642 bsf receiving__byte,receiving__bit 368 ; `while serial_in ...' start 369 get_byte__185while__continue: 370 ; expression=`serial_in' exp_delay=0 true_delay=1 false_delay=2 true_size=2 false_size=1 371 047 1c07 btfss serial_in__byte,serial_in__bit 372 048 284b goto get_byte__185while__break 373 ; call delay {{ }} 374 049 20e4 call delay 375 04a 2847 goto get_byte__185while__continue 376 ; if exp=`serial_in' false goto 377 ; Other expression=`serial_in' delay=-1 378 get_byte__185while__break: 379 ; `while serial_in ...' end 380 ; Clear any interrupt being sent : 381 ; serial_out := 1 382 04b 1487 bsf serial_out__byte,serial_out__bit 383 ; Skip over start bit : 384 ; call delay {{ }} 385 04c 20e4 call delay 386 ; call delay {{ }} 387 04d 20e4 call delay 388 ; call delay {{ }} 389 04e 20e4 call delay 390 ; Sample in the middle third of each data bit : 391 ; char := 0 392 04f 01b9 clrf get_byte__char 393 ; `count_down count 8 ...' start 394 050 3008 movlw 8 395 051 00b8 movwf get_byte__count 396 get_byte__199_loop: 397 ; call delay {{ }} 398 052 20e4 call delay 399 ; 2 cycles : 400 ; char := char >> 1 401 053 1003 bcf c___byte,c___bit 402 054 0cb9 rrf get_byte__char,f 403 ; 2 cycles : 404 ; if { serial_in } start 405 ; expression=`{ serial_in }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 406 055 1807 btfsc serial_in__byte,serial_in__bit 407 ; if { serial_in } body start 408 ; char @ 7 := 1 409 ; Select char @ 7 410 0039 get_byte__char__205select0 equ get_byte__char+0 411 0039 get_byte__char__205select0__byte equ get_byte__char+0 412 0007 get_byte__char__205select0__bit equ 7 413 056 17b9 bsf get_byte__char__205select0__byte,get_byte__char__205select0__bit 414 ; if { serial_in } body end 415 ; if exp=`serial_in' false skip delay=2 416 ; Other expression=`{ serial_in }' delay=2 417 ; if { serial_in } end 418 ; call delay {{ }} 419 057 20e4 call delay 420 ; call delay {{ }} 421 058 20e4 call delay 422 ; 3 cycles at end of loop for test and branch : 423 ; 2 + 2 + 3 = 7 424 ; nop extra_instructions_per_bit - 7 425 ; Delay 2 cycles 426 059 0000 nop 427 05a 0000 nop 428 05b 0bb8 decfsz get_byte__count,f 429 05c 2852 goto get_byte__199_loop 430 get_byte__199_done: 431 ; `count_down count 8 ...' end 432 ; Skip over 2 / 3 ' s of stop bit : 433 ; call delay {{ }} 434 05d 20e4 call delay 435 ; call delay {{ }} 436 05e 20e4 call delay 437 ; return char 438 05f 0839 movf get_byte__char,w 439 060 00b7 movwf get_byte__0return__byte 440 061 3400 retlw 0 441 ; procedure get_byte end 442 443 ; procedure send_byte start 444 send_byte: 445 003b send_byte__variables__base equ global__variables__bank0+27 446 003b send_byte__bytes__base equ send_byte__variables__base+0 447 003d send_byte__bits__base equ send_byte__variables__base+2 448 0002 send_byte__total__bytes equ 2 449 003b send_byte__char equ send_byte__bytes__base+0 450 ; Send < char > to < tx > : 451 003c send_byte__count equ send_byte__bytes__base+1 452 ; < receiving > will be 1 if the last get / put routine was a get . 453 ; Before we start transmitting a response back , we want to ensure 454 ; that there has been enough time to turn the line line around . 455 ; We delay the first 1 / 3 of a bit to pad out the 9 - 2 / 3 bits from 456 ; for get_byte to 10 bits . We delay another 1 / 3 of a bit just 457 ; for good measure . Technically , the second call to delay < > 458 ; is not really needed . 459 ; if { receiving } start 460 ; expression=`{ receiving }' exp_delay=0 true_delay=-1 false_delay=0 true_size=3 false_size=0 461 062 1e42 btfss receiving__byte,receiving__bit 462 063 2867 goto label236__0end 463 ; if { receiving } body start 464 ; receiving := 0 465 064 1242 bcf receiving__byte,receiving__bit 466 ; call delay {{ }} 467 065 20e4 call delay 468 ; call delay {{ }} 469 066 20e4 call delay 470 ; if { receiving } body end 471 label236__0end: 472 ; if exp=`receiving' empty false 473 ; Other expression=`{ receiving }' delay=-1 474 ; if { receiving } end 475 ; Send the start bit : 476 ; serial_out := 0 477 067 1087 bcf serial_out__byte,serial_out__bit 478 ; call delay {{ }} 479 068 20e4 call delay 480 ; call delay {{ }} 481 069 20e4 call delay 482 ; call delay {{ }} 483 06a 20e4 call delay 484 ; Send the data : 485 ; `count_down count 8 ...' start 486 06b 3008 movlw 8 487 06c 00bc movwf send_byte__count 488 send_byte__249_loop: 489 ; 4 cycles : 490 ; serial_out := char @ 0 491 ; Alias variable for select char @ 0 492 003b send_byte__char__251select0 equ send_byte__char+0 493 003b send_byte__char__251select0__byte equ send_byte__char+0 494 0000 send_byte__char__251select0__bit equ 0 495 06d 1c3b btfss send_byte__char__251select0__byte,send_byte__char__251select0__bit 496 06e 1087 bcf serial_out__byte,serial_out__bit 497 06f 183b btfsc send_byte__char__251select0__byte,send_byte__char__251select0__bit 498 070 1487 bsf serial_out__byte,serial_out__bit 499 ; 2 cycles : 500 ; char := char >> 1 501 071 1003 bcf c___byte,c___bit 502 072 0cbb rrf send_byte__char,f 503 ; call delay {{ }} 504 073 20e4 call delay 505 ; call delay {{ }} 506 074 20e4 call delay 507 ; call delay {{ }} 508 075 20e4 call delay 509 ; Test and jump at end of loop takes 3 cycles : 510 ; 4 + 2 + 3 = 9 = no NOP ' s needed 511 076 0bbc decfsz send_byte__count,f 512 077 286d goto send_byte__249_loop 513 send_byte__249_done: 514 ; `count_down count 8 ...' end 515 ; Send the stop bit : 516 ; serial_out := 1 517 078 1487 bsf serial_out__byte,serial_out__bit 518 ; call delay {{ }} 519 079 20e4 call delay 520 ; call delay {{ }} 521 07a 20e4 call delay 522 ; call delay {{ }} 523 07b 20e4 call delay 524 ; procedure send_byte end 525 07c 3400 retlw 0 526 527 ; procedure set_up start 528 set_up: 529 003d set_up__variables__base equ global__variables__bank0+29 530 003d set_up__bytes__base equ set_up__variables__base+0 531 003d set_up__bits__base equ set_up__variables__base+0 532 0000 set_up__total__bytes equ 0 533 ; arguments_none 534 ; This procedure will set the speed of motor to speed . 535 ; Reset failsafe : 536 ; fail_safe_low_counter := 0 537 07d 01b1 clrf fail_safe_low_counter 538 ; fail_safe_high_counter := fail_safe 539 07e 082e movf fail_safe,w 540 07f 00b0 movwf fail_safe_high_counter 541 ; Mode Dir On Off 542 ; = = = = = = = = = = = = = = = = = = 543 ; 0 0 A 0 544 ; 0 1 B 0 545 ; 1 0 A B 546 ; 1 1 B A 547 ; Motor 0 : 548 ; if { ramp0 = 0 } start 549 080 0828 movf ramp0,w 550 ; expression=`{ ramp0 = 0 }' exp_delay=1 true_delay=4 false_delay=7 true_size=4 false_size=7 551 081 1d03 btfss z___byte,z___bit 552 082 2888 goto label286__0false 553 label286__0true: 554 ; if { ramp0 = 0 } body start 555 ; No ramping : 556 ; actual_speed0 := desired_speed0 557 083 0826 movf desired_speed0,w 558 084 00a0 movwf actual_speed0 559 ; ramp0_delay := 0 560 085 01aa clrf ramp0_delay 561 ; ramp0_offset := 0 562 086 01ac clrf ramp0_offset 563 ; if { ramp0 = 0 } body end 564 087 288f goto label286__0end 565 label286__0false: 566 ; else body start 567 ; Ramping : 568 ; if { desired_speed0 < actual_speed0 } start 569 088 0820 movf actual_speed0,w 570 089 0226 subwf desired_speed0,w 571 ; expression=`{ desired_speed0 < actual_speed0 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 572 08a 1c03 btfss c___byte,c___bit 573 ; if { desired_speed0 < actual_speed0 } body start 574 ; ramp0_offset := 0xff 575 08b 30ff movlw 255 576 ; 1 instructions found for sharing 577 08c 1803 btfsc c___byte,c___bit 578 ; else body start 579 ; ramp0_offset := 1 580 08d 3001 movlw 1 581 ; 1 instructions found for sharing 582 ; if exp=` desired_speed0 < actual_speed0 ' single true and false skip delay=6 583 ; Other expression=`{ desired_speed0 < actual_speed0 }' delay=6 584 ; 1 shared instructions follow 585 08e 00ac movwf ramp0_offset 586 ; if { desired_speed0 < actual_speed0 } end 587 ; else body end 588 ; if exp=` ramp0 = 0 ' generic 589 label286__0end: 590 ; Other expression=`{ ramp0 = 0 }' delay=-1 591 ; if { ramp0 = 0 } end 592 ; FIXME : do a motor0_off := 0 and delete the appropriate statements below ; 593 ; if { motor0_direction } start 594 ; expression=`{ motor0_direction }' exp_delay=0 true_delay=-2 false_delay=-2 true_size=7 false_size=7 595 08f 1d42 btfss motor0_direction__byte,motor0_direction__bit 596 090 2899 goto label300__0false 597 label300__0true: 598 ; if { motor0_direction } body start 599 ; Direction = 1 < Backward > : 600 ; if { motor0_mode } start 601 ; expression=`{ motor0_mode }' exp_delay=0 true_delay=2 false_delay=1 true_size=2 false_size=1 602 091 1842 btfsc motor0_mode__byte,motor0_mode__bit 603 092 2895 goto label302__0true 604 label302__0false: 605 ; else body start 606 ; Mode = 0 < Pulsed > 607 ; motor0_off := 0 608 093 01a2 clrf motor0_off 609 ; else body end 610 094 2897 goto label302__0end 611 label302__0true: 612 ; if { motor0_mode } body start 613 ; Mode = 1 < Continuous > : 614 ; motor0_off := motor0a_mask 615 095 3001 movlw 1 616 096 00a2 movwf motor0_off 617 ; if { motor0_mode } body end 618 ; if exp=`motor0_mode' generic 619 label302__0end: 620 ; Other expression=`{ motor0_mode }' delay=-1 621 ; if { motor0_mode } end 622 ; motor0_on := motor0b_mask 623 097 3002 movlw 2 624 ; 1 instructions found for sharing 625 098 28a0 goto label300__0end 626 label300__0false: 627 ; else body start 628 ; Direction = 0 < Forward > : 629 ; if { motor0_mode } start 630 ; expression=`{ motor0_mode }' exp_delay=0 true_delay=2 false_delay=1 true_size=2 false_size=1 631 099 1842 btfsc motor0_mode__byte,motor0_mode__bit 632 09a 289d goto label312__0true 633 label312__0false: 634 ; else body start 635 ; Mode = 0 < Pulsed > : 636 ; motor0_off := 0 637 09b 01a2 clrf motor0_off 638 ; else body end 639 09c 289f goto label312__0end 640 label312__0true: 641 ; if { motor0_mode } body start 642 ; Mode = 1 < Continuous > : 643 ; motor0_off := motor0b_mask 644 09d 3002 movlw 2 645 09e 00a2 movwf motor0_off 646 ; if { motor0_mode } body end 647 ; if exp=`motor0_mode' generic 648 label312__0end: 649 ; Other expression=`{ motor0_mode }' delay=-1 650 ; if { motor0_mode } end 651 ; motor0_on := motor0a_mask 652 09f 3001 movlw 1 653 ; 1 instructions found for sharing 654 ; if exp=`motor0_direction' generic 655 label300__0end: 656 ; Other expression=`{ motor0_direction }' delay=-1 657 ; 1 shared instructions follow 658 0a0 00a3 movwf motor0_on 659 ; if { motor0_direction } end 660 ; Motor1 : 661 ; if { ramp1 = 0 } start 662 0a1 0829 movf ramp1,w 663 ; expression=`{ ramp1 = 0 }' exp_delay=1 true_delay=4 false_delay=7 true_size=4 false_size=7 664 0a2 1d03 btfss z___byte,z___bit 665 0a3 28a9 goto label323__0false 666 label323__0true: 667 ; if { ramp1 = 0 } body start 668 ; No ramping : 669 ; actual_speed1 := desired_speed1 670 0a4 0827 movf desired_speed1,w 671 0a5 00a1 movwf actual_speed1 672 ; ramp1_delay := 0 673 0a6 01ab clrf ramp1_delay 674 ; ramp1_offset := 0 675 0a7 01ad clrf ramp1_offset 676 ; if { ramp1 = 0 } body end 677 0a8 28b0 goto label323__0end 678 label323__0false: 679 ; else body start 680 ; Ramping : 681 ; if { desired_speed1 < actual_speed1 } start 682 0a9 0821 movf actual_speed1,w 683 0aa 0227 subwf desired_speed1,w 684 ; expression=`{ desired_speed1 < actual_speed1 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 685 0ab 1c03 btfss c___byte,c___bit 686 ; if { desired_speed1 < actual_speed1 } body start 687 ; ramp1_offset := 0xff 688 0ac 30ff movlw 255 689 ; 1 instructions found for sharing 690 0ad 1803 btfsc c___byte,c___bit 691 ; else body start 692 ; ramp1_offset := 1 693 0ae 3001 movlw 1 694 ; 1 instructions found for sharing 695 ; if exp=` desired_speed1 < actual_speed1 ' single true and false skip delay=6 696 ; Other expression=`{ desired_speed1 < actual_speed1 }' delay=6 697 ; 1 shared instructions follow 698 0af 00ad movwf ramp1_offset 699 ; if { desired_speed1 < actual_speed1 } end 700 ; else body end 701 ; if exp=` ramp1 = 0 ' generic 702 label323__0end: 703 ; Other expression=`{ ramp1 = 0 }' delay=-1 704 ; if { ramp1 = 0 } end 705 ; FIXME : do a motor1 := 0 here and delete the appropriate statements below : 706 ; if { motor1_direction } start 707 ; expression=`{ motor1_direction }' exp_delay=0 true_delay=-2 false_delay=-2 true_size=7 false_size=7 708 0b0 1dc2 btfss motor1_direction__byte,motor1_direction__bit 709 0b1 28ba goto label337__0false 710 label337__0true: 711 ; if { motor1_direction } body start 712 ; Direction = 1 < Backward > : 713 ; if { motor1_mode } start 714 ; expression=`{ motor1_mode }' exp_delay=0 true_delay=2 false_delay=1 true_size=2 false_size=1 715 0b2 18c2 btfsc motor1_mode__byte,motor1_mode__bit 716 0b3 28b6 goto label339__0true 717 label339__0false: 718 ; else body start 719 ; Mode = 1 < Pulsed > 720 ; motor1_off := 0 721 0b4 01a4 clrf motor1_off 722 ; else body end 723 0b5 28b8 goto label339__0end 724 label339__0true: 725 ; if { motor1_mode } body start 726 ; Mode = 1 < Continuous > : 727 ; motor1_off := motor1a_mask 728 0b6 3010 movlw 16 729 0b7 00a4 movwf motor1_off 730 ; if { motor1_mode } body end 731 ; if exp=`motor1_mode' generic 732 label339__0end: 733 ; Other expression=`{ motor1_mode }' delay=-1 734 ; if { motor1_mode } end 735 ; motor1_on := motor1b_mask 736 0b8 3004 movlw 4 737 ; 1 instructions found for sharing 738 0b9 28c1 goto label337__0end 739 label337__0false: 740 ; else body start 741 ; Direction = 0 < Forward > : 742 ; if { motor1_mode } start 743 ; expression=`{ motor1_mode }' exp_delay=0 true_delay=2 false_delay=1 true_size=2 false_size=1 744 0ba 18c2 btfsc motor1_mode__byte,motor1_mode__bit 745 0bb 28be goto label349__0true 746 label349__0false: 747 ; else body start 748 ; Mode = 0 < Pulsed > : 749 ; motor1_off := 0 750 0bc 01a4 clrf motor1_off 751 ; else body end 752 0bd 28c0 goto label349__0end 753 label349__0true: 754 ; if { motor1_mode } body start 755 ; Mode = 1 < Continuous > : 756 ; motor1_off := motor1b_mask 757 0be 3004 movlw 4 758 0bf 00a4 movwf motor1_off 759 ; if { motor1_mode } body end 760 ; if exp=`motor1_mode' generic 761 label349__0end: 762 ; Other expression=`{ motor1_mode }' delay=-1 763 ; if { motor1_mode } end 764 ; motor1_on := motor1a_mask 765 0c0 3010 movlw 16 766 ; 1 instructions found for sharing 767 ; if exp=`motor1_direction' generic 768 label337__0end: 769 ; Other expression=`{ motor1_direction }' delay=-1 770 ; 1 shared instructions follow 771 0c1 00a5 movwf motor1_on 772 ; if { motor1_direction } end 773 ; procedure set_up end 774 0c2 3400 retlw 0 775 776 ; procedure reset start 777 reset: 778 003d reset__variables__base equ global__variables__bank0+29 779 003d reset__bytes__base equ reset__variables__base+0 780 003d reset__bits__base equ reset__variables__base+0 781 0000 reset__total__bytes equ 0 782 ; arguments_none 783 ; Initialize everything else : 784 ; motor0e := 1 785 0c3 1507 bsf motor0e__byte,motor0e__bit 786 ; motor1e := 1 787 0c4 1587 bsf motor1e__byte,motor1e__bit 788 ; intcon := 0 789 0c5 018b clrf intcon 790 ; option := option_mask 791 0c6 3080 movlw 128 792 ; Switch from register bank 0 to register bank 1 (which contains option) 793 0c7 1683 bsf rp0___byte,rp0___bit 794 ; Register bank is now 1 795 0c8 0081 movwf option 796 ; wpua := 0 797 0c9 0195 clrf wpua 798 ; actual_speed0 := 0 799 0ca 01a0 clrf actual_speed0 800 ; actual_speed1 := 0 801 0cb 01a1 clrf actual_speed1 802 ; motor0_off := 0 803 0cc 01a2 clrf motor0_off 804 ; motor0_on := 0 805 0cd 01a3 clrf motor0_on 806 ; motor1_off := 0 807 0ce 01a4 clrf motor1_off 808 ; motor1_on := 0 809 0cf 01a5 clrf motor1_on 810 ; desired_speed0 := 0 811 0d0 01a6 clrf desired_speed0 812 ; desired_speed1 := 0 813 0d1 01a7 clrf desired_speed1 814 ; ramp0 := 0 815 0d2 01a8 clrf ramp0 816 ; ramp1 := 0 817 0d3 01a9 clrf ramp1 818 ; ramp0_delay := 0 819 0d4 01aa clrf ramp0_delay 820 ; ramp1_delay := 0 821 0d5 01ab clrf ramp1_delay 822 ; ramp0_offset := 0 823 0d6 01ac clrf ramp0_offset 824 ; ramp1_offset := 0 825 0d7 01ad clrf ramp1_offset 826 ; motor0_direction := 0 827 0d8 1142 bcf motor0_direction__byte,motor0_direction__bit 828 ; motor1_direction := 0 829 0d9 11c2 bcf motor1_direction__byte,motor1_direction__bit 830 ; motor0_mode := 0 831 0da 1042 bcf motor0_mode__byte,motor0_mode__bit 832 ; motor1_mode := 0 833 0db 10c2 bcf motor1_mode__byte,motor1_mode__bit 834 ; fail_safe := 0 835 0dc 01ae clrf fail_safe 836 ; fail_safe_errors := 0 837 0dd 01af clrf fail_safe_errors 838 ; fail_safe_high_counter := 0 839 0de 01b0 clrf fail_safe_high_counter 840 ; fail_safe_low_counter := 0 841 0df 01b1 clrf fail_safe_low_counter 842 ; glitch := 0 843 0e0 01b4 clrf glitch 844 ; id_index := 0 845 0e1 01b5 clrf id_index 846 ; procedure reset end 847 ; Switch from register bank 1 to register bank 0 848 0e2 1283 bcf rp0___byte,rp0___bit 849 ; Register bank is now 0 850 0e3 3400 retlw 0 851 852 ; procedure delay start 853 ; optimize 0 854 delay: 855 003d delay__variables__base equ global__variables__bank0+29 856 003d delay__bytes__base equ delay__variables__base+0 857 003e delay__bits__base equ delay__variables__base+1 858 0001 delay__total__bytes equ 1 859 003d delay__396byte1 equ delay__bytes__base+0 860 003d delay__476byte2 equ delay__bytes__base+0 861 003d delay__454byte2 equ delay__bytes__base+0 862 003d delay__423byte2 equ delay__bytes__base+0 863 003d delay__424byte2 equ delay__bytes__base+0 864 003d delay__421byte2 equ delay__bytes__base+0 865 ; arguments_none 866 ; uniform_delay delay_instructions 867 ; Uniform delay remaining = 131 Accumulated Delay = 0 868 ; Uniform delay remaining = 131 Accumulated Delay = 0 869 ; Delay for 1 / 3 of a bit time . 870 ; Uniform delay remaining = 131 Accumulated Delay = 0 871 ; Uniform delay remaining = 131 Accumulated Delay = 0 872 ; Kick the dog : 873 ; Uniform delay remaining = 131 Accumulated Delay = 0 874 ; watch_dog_reset 875 0e4 0064 clrwdt 876 ; Uniform delay remaining = 130 Accumulated Delay = 1 877 ; Uniform delay remaining = 130 Accumulated Delay = 1 878 ; This is the first probe of TMR0 : 879 ; Uniform delay remaining = 130 Accumulated Delay = 1 880 ; if { tmr0 < actual_speed0 } start 881 0e5 0820 movf actual_speed0,w 882 0e6 0201 subwf tmr0,w 883 ; expression=`{ tmr0 < actual_speed0 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 884 0e7 1c03 btfss c___byte,c___bit 885 ; if { tmr0 < actual_speed0 } body start 886 ; Uniform delay remaining = 130 Accumulated Delay = 0 887 ; motor0 := motor0_on 888 0e8 0823 movf motor0_on,w 889 ; 1 instructions found for sharing 890 ; Uniform delay remaining = 128 Accumulated Delay = 2 891 ; if { tmr0 < actual_speed0 } body end 892 0e9 1803 btfsc c___byte,c___bit 893 ; else body start 894 ; Uniform delay remaining = 130 Accumulated Delay = 0 895 ; motor0 := motor0_off 896 0ea 0822 movf motor0_off,w 897 ; 1 instructions found for sharing 898 ; Uniform delay remaining = 128 Accumulated Delay = 2 899 ; else body end 900 ; if exp=` tmr0 < actual_speed0 ' single true and false skip delay=6 901 ; Other expression=`{ tmr0 < actual_speed0 }' delay=6 902 ; 1 shared instructions follow 903 0eb 00b2 movwf motor0 904 ; if { tmr0 < actual_speed0 } end 905 ; Uniform delay remaining = 123 Accumulated Delay = 8 906 ; if { tmr0 < actual_speed1 } start 907 0ec 0821 movf actual_speed1,w 908 0ed 0201 subwf tmr0,w 909 ; expression=`{ tmr0 < actual_speed1 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 910 0ee 1c03 btfss c___byte,c___bit 911 ; if { tmr0 < actual_speed1 } body start 912 ; Uniform delay remaining = 123 Accumulated Delay = 0 913 ; motor1 := motor1_on 914 0ef 0825 movf motor1_on,w 915 ; 1 instructions found for sharing 916 ; Uniform delay remaining = 121 Accumulated Delay = 2 917 ; if { tmr0 < actual_speed1 } body end 918 0f0 1803 btfsc c___byte,c___bit 919 ; else body start 920 ; Uniform delay remaining = 123 Accumulated Delay = 0 921 ; motor1 := motor1_off 922 0f1 0824 movf motor1_off,w 923 ; 1 instructions found for sharing 924 ; Uniform delay remaining = 121 Accumulated Delay = 2 925 ; else body end 926 ; if exp=` tmr0 < actual_speed1 ' single true and false skip delay=6 927 ; Other expression=`{ tmr0 < actual_speed1 }' delay=6 928 ; 1 shared instructions follow 929 0f2 00b3 movwf motor1 930 ; if { tmr0 < actual_speed1 } end 931 ; Uniform delay remaining = 116 Accumulated Delay = 15 932 ; porta := motor0 | motor1 933 0f3 0832 movf motor0,w 934 0f4 0433 iorwf motor1,w 935 0f5 0085 movwf porta 936 ; Uniform delay remaining = 113 Accumulated Delay = 18 937 ; Uniform delay remaining = 113 Accumulated Delay = 18 938 ; First check out < fail_safe_counter > : 939 ; Uniform delay remaining = 113 Accumulated Delay = 18 940 ; fail_safe_low_counter := fail_safe_low_counter - 1 941 0f6 03b1 decf fail_safe_low_counter,f 942 ; Uniform delay remaining = 112 Accumulated Delay = 19 943 ; if { z } start 944 ; expression=`{ z }' exp_delay=0 true_delay=17 false_delay=0 true_size=28 false_size=0 945 0f7 1903 btfsc z__byte,z__bit 946 0f8 28fe goto label421__0true 947 label421__0false: 948 ; Delay 16 cycles 949 0f9 3005 movlw 5 950 0fa 00bd movwf delay__421byte2 951 delay__421delay1: 952 0fb 0bbd decfsz delay__421byte2,f 953 0fc 28fb goto delay__421delay1 954 0fd 291a goto label421__0end 955 label421__0true: 956 ; if { z } body start 957 ; Uniform delay remaining = 112 Accumulated Delay = 0 958 ; fail_safe_high_counter := fail_safe_high_counter - 1 959 0fe 03b0 decf fail_safe_high_counter,f 960 ; Uniform delay remaining = 111 Accumulated Delay = 1 961 ; if { z } start 962 ; expression=`{ z }' exp_delay=0 true_delay=13 false_delay=0 true_size=18 false_size=0 963 0ff 1903 btfsc z__byte,z__bit 964 100 2908 goto label423__0true 965 label423__0false: 966 ; Delay 12 cycles 967 101 3003 movlw 3 968 102 00bd movwf delay__423byte2 969 delay__423delay1: 970 103 0bbd decfsz delay__423byte2,f 971 104 2903 goto delay__423delay1 972 105 0000 nop 973 106 0000 nop 974 107 291a goto label423__0end 975 label423__0true: 976 ; if { z } body start 977 ; Uniform delay remaining = 111 Accumulated Delay = 0 978 ; if { fail_safe != 0 } start 979 108 082e movf fail_safe,w 980 ; expression=`{ fail_safe != 0 }' exp_delay=1 true_delay=9 false_delay=0 true_size=9 false_size=0 981 109 1d03 btfss z___byte,z___bit 982 10a 2911 goto label424__0true 983 label424__0false: 984 ; Delay 8 cycles 985 10b 3002 movlw 2 986 10c 00bd movwf delay__424byte2 987 delay__424delay1: 988 10d 0bbd decfsz delay__424byte2,f 989 10e 290d goto delay__424delay1 990 10f 0000 nop 991 110 291a goto label424__0end 992 label424__0true: 993 ; if { fail_safe != 0 } body start 994 ; Uniform delay remaining = 111 Accumulated Delay = 0 995 ; Turn the motors off : 996 ; Uniform delay remaining = 111 Accumulated Delay = 0 997 ; motor0_on := 0 998 111 01a3 clrf motor0_on 999 ; Uniform delay remaining = 110 Accumulated Delay = 1 1000 ; motor0_off := 0 1001 112 01a2 clrf motor0_off 1002 ; Uniform delay remaining = 109 Accumulated Delay = 2 1003 ; motor1_on := 0 1004 113 01a5 clrf motor1_on 1005 ; Uniform delay remaining = 108 Accumulated Delay = 3 1006 ; motor1_off := 0 1007 114 01a4 clrf motor1_off 1008 ; Uniform delay remaining = 107 Accumulated Delay = 4 1009 ; desired_speed0 := 0 1010 115 01a6 clrf desired_speed0 1011 ; Uniform delay remaining = 106 Accumulated Delay = 5 1012 ; desired_speed1 := 0 1013 116 01a7 clrf desired_speed1 1014 ; Uniform delay remaining = 105 Accumulated Delay = 6 1015 ; actual_speed0 := 0 1016 117 01a0 clrf actual_speed0 1017 ; Uniform delay remaining = 104 Accumulated Delay = 7 1018 ; actual_speed0 := 0 1019 118 01a0 clrf actual_speed0 1020 ; Uniform delay remaining = 103 Accumulated Delay = 8 1021 ; fail_safe_errors := fail_safe_errors + 1 1022 119 0aaf incf fail_safe_errors,f 1023 ; Uniform delay remaining = 102 Accumulated Delay = 9 1024 ; Uniform delay remaining = 102 Accumulated Delay = 9 1025 ; if { fail_safe != 0 } body end 1026 ; if exp=` fail_safe != 0 ' total delay=13 1027 ; if exp=` fail_safe != 0 ' generic 1028 label424__0end: 1029 ; Other expression=`{ fail_safe != 0 }' delay=13 1030 ; if { fail_safe != 0 } end 1031 ; Uniform delay remaining = 98 Accumulated Delay = 13 1032 ; Uniform delay remaining = 98 Accumulated Delay = 13 1033 ; if { z } body end 1034 ; if exp=`z' total delay=16 1035 ; if exp=`z' generic 1036 label423__0end: 1037 ; Other expression=`{ z }' delay=16 1038 ; if { z } end 1039 ; Uniform delay remaining = 95 Accumulated Delay = 17 1040 ; Uniform delay remaining = 95 Accumulated Delay = 17 1041 ; if { z } body end 1042 ; if exp=`z' total delay=20 1043 ; if exp=`z' generic 1044 label421__0end: 1045 ; Other expression=`{ z }' delay=20 1046 ; if { z } end 1047 ; Uniform delay remaining = 92 Accumulated Delay = 39 1048 ; Uniform delay remaining = 92 Accumulated Delay = 39 1049 ; This is the second probe of TMR0 : 1050 ; Uniform delay remaining = 92 Accumulated Delay = 39 1051 ; if { tmr0 < actual_speed0 } start 1052 11a 0820 movf actual_speed0,w 1053 11b 0201 subwf tmr0,w 1054 ; expression=`{ tmr0 < actual_speed0 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1055 11c 1c03 btfss c___byte,c___bit 1056 ; if { tmr0 < actual_speed0 } body start 1057 ; Uniform delay remaining = 92 Accumulated Delay = 0 1058 ; motor0 := motor0_on 1059 11d 0823 movf motor0_on,w 1060 ; 1 instructions found for sharing 1061 ; Uniform delay remaining = 90 Accumulated Delay = 2 1062 ; if { tmr0 < actual_speed0 } body end 1063 11e 1803 btfsc c___byte,c___bit 1064 ; else body start 1065 ; Uniform delay remaining = 92 Accumulated Delay = 0 1066 ; motor0 := motor0_off 1067 11f 0822 movf motor0_off,w 1068 ; 1 instructions found for sharing 1069 ; Uniform delay remaining = 90 Accumulated Delay = 2 1070 ; else body end 1071 ; if exp=` tmr0 < actual_speed0 ' single true and false skip delay=6 1072 ; Other expression=`{ tmr0 < actual_speed0 }' delay=6 1073 ; 1 shared instructions follow 1074 120 00b2 movwf motor0 1075 ; if { tmr0 < actual_speed0 } end 1076 ; Uniform delay remaining = 85 Accumulated Delay = 46 1077 ; if { tmr0 < actual_speed1 } start 1078 121 0821 movf actual_speed1,w 1079 122 0201 subwf tmr0,w 1080 ; expression=`{ tmr0 < actual_speed1 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1081 123 1c03 btfss c___byte,c___bit 1082 ; if { tmr0 < actual_speed1 } body start 1083 ; Uniform delay remaining = 85 Accumulated Delay = 0 1084 ; motor1 := motor1_on 1085 124 0825 movf motor1_on,w 1086 ; 1 instructions found for sharing 1087 ; Uniform delay remaining = 83 Accumulated Delay = 2 1088 ; if { tmr0 < actual_speed1 } body end 1089 125 1803 btfsc c___byte,c___bit 1090 ; else body start 1091 ; Uniform delay remaining = 85 Accumulated Delay = 0 1092 ; motor1 := motor1_off 1093 126 0824 movf motor1_off,w 1094 ; 1 instructions found for sharing 1095 ; Uniform delay remaining = 83 Accumulated Delay = 2 1096 ; else body end 1097 ; if exp=` tmr0 < actual_speed1 ' single true and false skip delay=6 1098 ; Other expression=`{ tmr0 < actual_speed1 }' delay=6 1099 ; 1 shared instructions follow 1100 127 00b3 movwf motor1 1101 ; if { tmr0 < actual_speed1 } end 1102 ; Uniform delay remaining = 78 Accumulated Delay = 53 1103 ; porta := motor0 | motor1 1104 128 0832 movf motor0,w 1105 129 0433 iorwf motor1,w 1106 12a 0085 movwf porta 1107 ; Uniform delay remaining = 75 Accumulated Delay = 56 1108 ; Uniform delay remaining = 75 Accumulated Delay = 56 1109 ; Do < ramp0 > management : 1110 ; Uniform delay remaining = 75 Accumulated Delay = 56 1111 ; ramp0_delay := ramp0_delay - 1 1112 12b 03aa decf ramp0_delay,f 1113 ; Uniform delay remaining = 74 Accumulated Delay = 57 1114 ; if { z } start 1115 ; expression=`{ z }' exp_delay=0 true_delay=9 false_delay=0 true_size=10 false_size=0 1116 12c 1903 btfsc z__byte,z__bit 1117 12d 2934 goto label454__0true 1118 label454__0false: 1119 ; Delay 8 cycles 1120 12e 3002 movlw 2 1121 12f 00bd movwf delay__454byte2 1122 delay__454delay1: 1123 130 0bbd decfsz delay__454byte2,f 1124 131 2930 goto delay__454delay1 1125 132 0000 nop 1126 133 293e goto label454__0end 1127 label454__0true: 1128 ; if { z } body start 1129 ; Uniform delay remaining = 74 Accumulated Delay = 0 1130 ; ramp0_delay := ramp0 1131 134 0828 movf ramp0,w 1132 135 00aa movwf ramp0_delay 1133 ; Uniform delay remaining = 72 Accumulated Delay = 2 1134 ; if { actual_speed0 != desired_speed0 } start 1135 136 0820 movf actual_speed0,w 1136 137 0226 subwf desired_speed0,w 1137 ; expression=`{ actual_speed0 != desired_speed0 }' exp_delay=2 true_delay=2 false_delay=0 true_size=2 false_size=0 1138 138 1d03 btfss z___byte,z___bit 1139 139 293c goto label456__0true 1140 label456__0false: 1141 ; Delay 1 cycles 1142 13a 0000 nop 1143 13b 293e goto label456__0end 1144 label456__0true: 1145 ; if { actual_speed0 != desired_speed0 } body start 1146 ; Uniform delay remaining = 72 Accumulated Delay = 0 1147 ; actual_speed0 := actual_speed0 + ramp0_offset 1148 13c 082c movf ramp0_offset,w 1149 13d 07a0 addwf actual_speed0,f 1150 ; Uniform delay remaining = 70 Accumulated Delay = 2 1151 ; Uniform delay remaining = 70 Accumulated Delay = 2 1152 ; if { actual_speed0 != desired_speed0 } body end 1153 ; if exp=` actual_speed0 != desired_speed0 ' total delay=7 1154 ; if exp=` actual_speed0 != desired_speed0 ' generic 1155 label456__0end: 1156 ; Other expression=`{ actual_speed0 != desired_speed0 }' delay=7 1157 ; if { actual_speed0 != desired_speed0 } end 1158 ; Uniform delay remaining = 65 Accumulated Delay = 9 1159 ; Uniform delay remaining = 65 Accumulated Delay = 9 1160 ; if { z } body end 1161 ; if exp=`z' total delay=12 1162 ; if exp=`z' generic 1163 label454__0end: 1164 ; Other expression=`{ z }' delay=12 1165 ; if { z } end 1166 ; Uniform delay remaining = 62 Accumulated Delay = 69 1167 ; Uniform delay remaining = 62 Accumulated Delay = 69 1168 ; This is the third probe of TMR0 : 1169 ; Uniform delay remaining = 62 Accumulated Delay = 69 1170 ; if { tmr0 < actual_speed0 } start 1171 13e 0820 movf actual_speed0,w 1172 13f 0201 subwf tmr0,w 1173 ; expression=`{ tmr0 < actual_speed0 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1174 140 1c03 btfss c___byte,c___bit 1175 ; if { tmr0 < actual_speed0 } body start 1176 ; Uniform delay remaining = 62 Accumulated Delay = 0 1177 ; motor0 := motor0_on 1178 141 0823 movf motor0_on,w 1179 ; 1 instructions found for sharing 1180 ; Uniform delay remaining = 60 Accumulated Delay = 2 1181 ; if { tmr0 < actual_speed0 } body end 1182 142 1803 btfsc c___byte,c___bit 1183 ; else body start 1184 ; Uniform delay remaining = 62 Accumulated Delay = 0 1185 ; motor0 := motor0_off 1186 143 0822 movf motor0_off,w 1187 ; 1 instructions found for sharing 1188 ; Uniform delay remaining = 60 Accumulated Delay = 2 1189 ; else body end 1190 ; if exp=` tmr0 < actual_speed0 ' single true and false skip delay=6 1191 ; Other expression=`{ tmr0 < actual_speed0 }' delay=6 1192 ; 1 shared instructions follow 1193 144 00b2 movwf motor0 1194 ; if { tmr0 < actual_speed0 } end 1195 ; Uniform delay remaining = 55 Accumulated Delay = 76 1196 ; if { tmr0 < actual_speed1 } start 1197 145 0821 movf actual_speed1,w 1198 146 0201 subwf tmr0,w 1199 ; expression=`{ tmr0 < actual_speed1 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1200 147 1c03 btfss c___byte,c___bit 1201 ; if { tmr0 < actual_speed1 } body start 1202 ; Uniform delay remaining = 55 Accumulated Delay = 0 1203 ; motor1 := motor1_on 1204 148 0825 movf motor1_on,w 1205 ; 1 instructions found for sharing 1206 ; Uniform delay remaining = 53 Accumulated Delay = 2 1207 ; if { tmr0 < actual_speed1 } body end 1208 149 1803 btfsc c___byte,c___bit 1209 ; else body start 1210 ; Uniform delay remaining = 55 Accumulated Delay = 0 1211 ; motor1 := motor1_off 1212 14a 0824 movf motor1_off,w 1213 ; 1 instructions found for sharing 1214 ; Uniform delay remaining = 53 Accumulated Delay = 2 1215 ; else body end 1216 ; if exp=` tmr0 < actual_speed1 ' single true and false skip delay=6 1217 ; Other expression=`{ tmr0 < actual_speed1 }' delay=6 1218 ; 1 shared instructions follow 1219 14b 00b3 movwf motor1 1220 ; if { tmr0 < actual_speed1 } end 1221 ; Uniform delay remaining = 48 Accumulated Delay = 83 1222 ; porta := motor0 | motor1 1223 14c 0832 movf motor0,w 1224 14d 0433 iorwf motor1,w 1225 14e 0085 movwf porta 1226 ; Uniform delay remaining = 45 Accumulated Delay = 86 1227 ; Uniform delay remaining = 45 Accumulated Delay = 86 1228 ; Do < ramp1 > management : 1229 ; Uniform delay remaining = 45 Accumulated Delay = 86 1230 ; ramp1_delay := ramp1_delay - 1 1231 14f 03ab decf ramp1_delay,f 1232 ; Uniform delay remaining = 44 Accumulated Delay = 87 1233 ; if { z } start 1234 ; expression=`{ z }' exp_delay=0 true_delay=9 false_delay=0 true_size=10 false_size=0 1235 150 1903 btfsc z__byte,z__bit 1236 151 2958 goto label476__0true 1237 label476__0false: 1238 ; Delay 8 cycles 1239 152 3002 movlw 2 1240 153 00bd movwf delay__476byte2 1241 delay__476delay1: 1242 154 0bbd decfsz delay__476byte2,f 1243 155 2954 goto delay__476delay1 1244 156 0000 nop 1245 157 2962 goto label476__0end 1246 label476__0true: 1247 ; if { z } body start 1248 ; Uniform delay remaining = 44 Accumulated Delay = 0 1249 ; ramp1_delay := ramp1 1250 158 0829 movf ramp1,w 1251 159 00ab movwf ramp1_delay 1252 ; Uniform delay remaining = 42 Accumulated Delay = 2 1253 ; if { actual_speed1 != desired_speed1 } start 1254 15a 0821 movf actual_speed1,w 1255 15b 0227 subwf desired_speed1,w 1256 ; expression=`{ actual_speed1 != desired_speed1 }' exp_delay=2 true_delay=2 false_delay=0 true_size=2 false_size=0 1257 15c 1d03 btfss z___byte,z___bit 1258 15d 2960 goto label478__0true 1259 label478__0false: 1260 ; Delay 1 cycles 1261 15e 0000 nop 1262 15f 2962 goto label478__0end 1263 label478__0true: 1264 ; if { actual_speed1 != desired_speed1 } body start 1265 ; Uniform delay remaining = 42 Accumulated Delay = 0 1266 ; actual_speed1 := actual_speed1 + ramp1_offset 1267 160 082d movf ramp1_offset,w 1268 161 07a1 addwf actual_speed1,f 1269 ; Uniform delay remaining = 40 Accumulated Delay = 2 1270 ; Uniform delay remaining = 40 Accumulated Delay = 2 1271 ; if { actual_speed1 != desired_speed1 } body end 1272 ; if exp=` actual_speed1 != desired_speed1 ' total delay=7 1273 ; if exp=` actual_speed1 != desired_speed1 ' generic 1274 label478__0end: 1275 ; Other expression=`{ actual_speed1 != desired_speed1 }' delay=7 1276 ; if { actual_speed1 != desired_speed1 } end 1277 ; Uniform delay remaining = 35 Accumulated Delay = 9 1278 ; Uniform delay remaining = 35 Accumulated Delay = 9 1279 ; if { z } body end 1280 ; if exp=`z' total delay=12 1281 ; if exp=`z' generic 1282 label476__0end: 1283 ; Other expression=`{ z }' delay=12 1284 ; if { z } end 1285 ; Uniform delay remaining = 32 Accumulated Delay = 99 1286 ; Uniform delay remaining = 32 Accumulated Delay = 99 1287 ; This is the forth probe of TMR0 : 1288 ; Uniform delay remaining = 32 Accumulated Delay = 99 1289 ; if { tmr0 < actual_speed0 } start 1290 162 0820 movf actual_speed0,w 1291 163 0201 subwf tmr0,w 1292 ; expression=`{ tmr0 < actual_speed0 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1293 164 1c03 btfss c___byte,c___bit 1294 ; if { tmr0 < actual_speed0 } body start 1295 ; Uniform delay remaining = 32 Accumulated Delay = 0 1296 ; motor0 := motor0_on 1297 165 0823 movf motor0_on,w 1298 ; 1 instructions found for sharing 1299 ; Uniform delay remaining = 30 Accumulated Delay = 2 1300 ; if { tmr0 < actual_speed0 } body end 1301 166 1803 btfsc c___byte,c___bit 1302 ; else body start 1303 ; Uniform delay remaining = 32 Accumulated Delay = 0 1304 ; motor0 := motor0_off 1305 167 0822 movf motor0_off,w 1306 ; 1 instructions found for sharing 1307 ; Uniform delay remaining = 30 Accumulated Delay = 2 1308 ; else body end 1309 ; if exp=` tmr0 < actual_speed0 ' single true and false skip delay=6 1310 ; Other expression=`{ tmr0 < actual_speed0 }' delay=6 1311 ; 1 shared instructions follow 1312 168 00b2 movwf motor0 1313 ; if { tmr0 < actual_speed0 } end 1314 ; Uniform delay remaining = 25 Accumulated Delay = 106 1315 ; if { tmr0 < actual_speed1 } start 1316 169 0821 movf actual_speed1,w 1317 16a 0201 subwf tmr0,w 1318 ; expression=`{ tmr0 < actual_speed1 }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 1319 16b 1c03 btfss c___byte,c___bit 1320 ; if { tmr0 < actual_speed1 } body start 1321 ; Uniform delay remaining = 25 Accumulated Delay = 0 1322 ; motor1 := motor1_on 1323 16c 0825 movf motor1_on,w 1324 ; 1 instructions found for sharing 1325 ; Uniform delay remaining = 23 Accumulated Delay = 2 1326 ; if { tmr0 < actual_speed1 } body end 1327 16d 1803 btfsc c___byte,c___bit 1328 ; else body start 1329 ; Uniform delay remaining = 25 Accumulated Delay = 0 1330 ; motor1 := motor1_off 1331 16e 0824 movf motor1_off,w 1332 ; 1 instructions found for sharing 1333 ; Uniform delay remaining = 23 Accumulated Delay = 2 1334 ; else body end 1335 ; if exp=` tmr0 < actual_speed1 ' single true and false skip delay=6 1336 ; Other expression=`{ tmr0 < actual_speed1 }' delay=6 1337 ; 1 shared instructions follow 1338 16f 00b3 movwf motor1 1339 ; if { tmr0 < actual_speed1 } end 1340 ; Uniform delay remaining = 18 Accumulated Delay = 113 1341 ; porta := motor0 | motor1 1342 170 0832 movf motor0,w 1343 171 0433 iorwf motor1,w 1344 172 0085 movwf porta 1345 ; Uniform delay remaining = 15 Accumulated Delay = 116 1346 ; Uniform delay remaining = 15 Accumulated Delay = 116 1347 ; Soak up remaining 15 cycles 1348 ; Delay 15 cycles 1349 173 3004 movlw 4 1350 174 00bd movwf delay__396byte1 1351 delay__396delay0: 1352 175 0bbd decfsz delay__396byte1,f 1353 176 2975 goto delay__396delay0 1354 177 0000 nop 1355 178 0000 nop 1356 ; procedure delay end 1357 179 3400 retlw 0 1358 ; optimize 1 1359 1360 ; procedure main start 1361 main: 1362 003e main__variables__base equ global__variables__bank0+30 1363 003e main__bytes__base equ main__variables__base+0 1364 0042 main__bits__base equ main__variables__base+4 1365 0004 main__total__bytes equ 4 1366 0040 main__715byte0 equ main__bytes__base+2 1367 0040 main__515byte2 equ main__bytes__base+2 1368 0040 main__515byte3 equ main__bytes__base+2 1369 0040 main__542byte0 equ main__bytes__base+2 1370 0040 main__528byte0 equ main__bytes__base+2 1371 0040 main__512byte0 equ main__bytes__base+2 1372 0041 main__515byte1 equ main__bytes__base+3 1373 ; arguments_none 1374 003e main__command equ main__bytes__base+0 1375 003f main__temp equ main__bytes__base+1 1376 ; call reset {{ }} 1377 17a 20c3 call reset 1378 ; Loop waiting for commands : 1379 ; loop_forever ... start 1380 main__507loop__forever: 1381 ; Get a command byte : 1382 ; command := get_byte {{ }} 1383 17b 2046 call get_byte 1384 17c 0837 movf get_byte__0return__byte,w 1385 17d 00be movwf main__command 1386 ; Dispatch on command : 1387 ; switch { command >> 6 } 1388 17e 3001 movlw HIGH switch__512block_start 1389 17f 008a movwf pclath___register 1390 180 0e3e swapf main__command,w 1391 181 00c0 movwf main__512byte0 1392 182 0cc0 rrf main__512byte0,f 1393 183 0c40 rrf main__512byte0,w 1394 184 3903 andlw 3 1395 ; case 0 1396 ; case 1 1397 ; case 2 1398 ; case 3 1399 switch__512block_start: 1400 185 0782 addwf pcl___register,f 1401 186 298a goto switch__512block513 1402 187 29a4 goto switch__512block526 1403 188 29bc goto switch__512block540 1404 189 2a84 goto switch__512block713 1405 switch__512block_end: 1406 ; switch_check 512 switch__512block_start switch__512block_end 1407 switch__512block513: 1408 ; Set Quick < Command = 00 hh hhdm > : 1409 ; temp := {{ {{ command << 2 }} & 0xf0 }} | {{ command >> 2 }} 1410 18a 0d3e rlf main__command,w 1411 18b 00c0 movwf main__515byte3 1412 18c 0d40 rlf main__515byte3,w 1413 18d 39f0 andlw 240 1414 18e 00c0 movwf main__515byte2 1415 18f 0c3e rrf main__command,w 1416 190 00c1 movwf main__515byte1 1417 191 0c41 rrf main__515byte1,w 1418 192 393f andlw 63 1419 193 0440 iorwf main__515byte2,w 1420 194 00bf movwf main__temp 1421 ; if { command @ 0 } start 1422 ; Alias variable for select command @ 0 1423 003e main__command__516select0 equ main__command+0 1424 003e main__command__516select0__byte equ main__command+0 1425 0000 main__command__516select0__bit equ 0 1426 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=5 false_delay=5 true_size=5 false_size=5 1427 195 1c3e btfss main__command__516select0__byte,main__command__516select0__bit 1428 196 299d goto label516__1false 1429 label516__1true: 1430 ; if { command @ 0 } body start 1431 ; Motor : 1432 ; desired_speed1 := temp 1433 197 083f movf main__temp,w 1434 198 00a7 movwf desired_speed1 1435 ; motor1_direction := command @ 1 1436 ; Alias variable for select command @ 1 1437 003e main__command__519select0 equ main__command+0 1438 003e main__command__519select0__byte equ main__command+0 1439 0001 main__command__519select0__bit equ 1 1440 199 11c2 bcf motor1_direction__byte,motor1_direction__bit 1441 19a 18be btfsc main__command__519select0__byte,main__command__519select0__bit 1442 19b 15c2 bsf motor1_direction__byte,motor1_direction__bit 1443 ; if { command @ 0 } body end 1444 19c 29a2 goto label516__1end 1445 label516__1false: 1446 ; else body start 1447 ; desired_speed0 := temp 1448 19d 083f movf main__temp,w 1449 19e 00a6 movwf desired_speed0 1450 ; motor0_direction := command @ 1 1451 ; Alias variable for select command @ 1 1452 003e main__command__522select0 equ main__command+0 1453 003e main__command__522select0__byte equ main__command+0 1454 0001 main__command__522select0__bit equ 1 1455 19f 1142 bcf motor0_direction__byte,motor0_direction__bit 1456 1a0 18be btfsc main__command__522select0__byte,main__command__522select0__bit 1457 1a1 1542 bsf motor0_direction__byte,motor0_direction__bit 1458 ; else body end 1459 ; if exp=` command @ 0 ' generic 1460 label516__1end: 1461 ; Other expression=`{ command @ 0 }' delay=-1 1462 ; if { command @ 0 } end 1463 ; call set_up {{ }} 1464 1a2 207d call set_up 1465 1a3 2acd goto switch__512end 1466 switch__512block526: 1467 ; Set Low < Command = 01 ll lldm > : 1468 ; temp := {{ command >> 2 }} & 0xf 1469 1a4 0c3e rrf main__command,w 1470 1a5 00c0 movwf main__528byte0 1471 1a6 0c40 rrf main__528byte0,w 1472 1a7 390f andlw 15 1473 1a8 00bf movwf main__temp 1474 ; if { command @ 0 } start 1475 ; Alias variable for select command @ 0 1476 003e main__command__529select0 equ main__command+0 1477 003e main__command__529select0__byte equ main__command+0 1478 0000 main__command__529select0__bit equ 0 1479 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=7 false_delay=7 true_size=7 false_size=7 1480 1a9 1c3e btfss main__command__529select0__byte,main__command__529select0__bit 1481 1aa 29b3 goto label529__1false 1482 label529__1true: 1483 ; if { command @ 0 } body start 1484 ; Motor 1 : 1485 ; desired_speed1 := desired_speed1 & 0xf0 | temp 1486 1ab 30f0 movlw 240 1487 1ac 0527 andwf desired_speed1,w 1488 1ad 043f iorwf main__temp,w 1489 1ae 00a7 movwf desired_speed1 1490 ; motor1_direction := command @ 1 1491 ; Alias variable for select command @ 1 1492 003e main__command__532select0 equ main__command+0 1493 003e main__command__532select0__byte equ main__command+0 1494 0001 main__command__532select0__bit equ 1 1495 1af 11c2 bcf motor1_direction__byte,motor1_direction__bit 1496 1b0 18be btfsc main__command__532select0__byte,main__command__532select0__bit 1497 1b1 15c2 bsf motor1_direction__byte,motor1_direction__bit 1498 ; if { command @ 0 } body end 1499 1b2 29ba goto label529__1end 1500 label529__1false: 1501 ; else body start 1502 ; Motor 0 : 1503 ; desired_speed0 := desired_speed0 & 0xf0 | temp 1504 1b3 30f0 movlw 240 1505 1b4 0526 andwf desired_speed0,w 1506 1b5 043f iorwf main__temp,w 1507 1b6 00a6 movwf desired_speed0 1508 ; motor0_direction := command @ 1 1509 ; Alias variable for select command @ 1 1510 003e main__command__536select0 equ main__command+0 1511 003e main__command__536select0__byte equ main__command+0 1512 0001 main__command__536select0__bit equ 1 1513 1b7 1142 bcf motor0_direction__byte,motor0_direction__bit 1514 1b8 18be btfsc main__command__536select0__byte,main__command__536select0__bit 1515 1b9 1542 bsf motor0_direction__byte,motor0_direction__bit 1516 ; else body end 1517 ; if exp=` command @ 0 ' generic 1518 label529__1end: 1519 ; Other expression=`{ command @ 0 }' delay=-1 1520 ; if { command @ 0 } end 1521 ; call set_up {{ }} 1522 1ba 207d call set_up 1523 1bb 2acd goto switch__512end 1524 switch__512block540: 1525 ; Command = 10 xx xxxx : 1526 ; switch { {{ command >> 3 }} & 7 } 1527 1bc 3001 movlw HIGH switch__542block_start 1528 1bd 008a movwf pclath___register 1529 1be 0c3e rrf main__command,w 1530 1bf 00c0 movwf main__542byte0 1531 1c0 0cc0 rrf main__542byte0,f 1532 1c1 0c40 rrf main__542byte0,w 1533 1c2 3907 andlw 7 1534 ; case 0 1535 ; case 1 1536 ; case 2 1537 ; case 3 1538 ; case 4 1539 ; case 5 1540 switch__542block_start: 1541 1c3 0782 addwf pcl___register,f 1542 1c4 29cc goto switch__542block543 1543 1c5 2a01 goto switch__542block583 1544 1c6 2a18 goto switch__542block606 1545 1c7 2a1f goto switch__542block610 1546 1c8 2a56 goto switch__542block662 1547 1c9 2a7c goto switch__542block700 1548 1ca 2a83 goto switch__542default708 1549 1cb 2a83 goto switch__542default708 1550 switch__542block_end: 1551 ; switch_check 542 switch__542block_start switch__542block_end 1552 switch__542block543: 1553 ; Command = 1000 0 xxx : 1554 ; switch { command & 7 } 1555 1cc 3001 movlw HIGH switch__545block_start 1556 1cd 008a movwf pclath___register 1557 1ce 3007 movlw 7 1558 1cf 053e andwf main__command,w 1559 ; case 0 1 1560 ; case 2 1561 ; case 3 1562 ; case 4 5 6 7 1563 switch__545block_start: 1564 1d0 0782 addwf pcl___register,f 1565 1d1 29d9 goto switch__545block546 1566 1d2 29d9 goto switch__545block546 1567 1d3 29e5 goto switch__545block556 1568 1d4 29eb goto switch__545block562 1569 1d5 29ef goto switch__545block567 1570 1d6 29ef goto switch__545block567 1571 1d7 29ef goto switch__545block567 1572 1d8 29ef goto switch__545block567 1573 switch__545block_end: 1574 ; switch_check 545 switch__545block_start switch__545block_end 1575 switch__545block546: 1576 ; Set Ramp < Command = 1000 000 m > : 1577 ; temp := get_byte {{ }} 1578 1d9 2046 call get_byte 1579 1da 0837 movf get_byte__0return__byte,w 1580 1db 00bf movwf main__temp 1581 ; if { command @ 0 } start 1582 ; Alias variable for select command @ 0 1583 003e main__command__549select0 equ main__command+0 1584 003e main__command__549select0__byte equ main__command+0 1585 0000 main__command__549select0__bit equ 0 1586 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=2 false_delay=2 true_size=2 false_size=2 1587 1dc 1c3e btfss main__command__549select0__byte,main__command__549select0__bit 1588 1dd 29e1 goto label549__1false 1589 label549__1true: 1590 ; if { command @ 0 } body start 1591 ; ramp1 := temp 1592 1de 083f movf main__temp,w 1593 1df 00a9 movwf ramp1 1594 ; if { command @ 0 } body end 1595 1e0 29e3 goto label549__1end 1596 label549__1false: 1597 ; else body start 1598 ; ramp0 := temp 1599 1e1 083f movf main__temp,w 1600 1e2 00a8 movwf ramp0 1601 ; else body end 1602 ; if exp=` command @ 0 ' generic 1603 label549__1end: 1604 ; Other expression=`{ command @ 0 }' delay=-1 1605 ; if { command @ 0 } end 1606 ; call set_up {{ }} 1607 1e3 207d call set_up 1608 1e4 2a00 goto switch__545end 1609 switch__545block556: 1610 ; Set Failsafe < Command = 1000 0010 > : 1611 ; fail_safe := get_byte {{ }} 1612 1e5 2046 call get_byte 1613 1e6 0837 movf get_byte__0return__byte,w 1614 1e7 00ae movwf fail_safe 1615 ; fail_safe_high_counter := fail_safe 1616 1e8 00b0 movwf fail_safe_high_counter 1617 ; fail_safe_low_counter := 0 1618 1e9 01b1 clrf fail_safe_low_counter 1619 1ea 2a00 goto switch__545end 1620 switch__545block562: 1621 ; Reset Failsafe < Command = 1000 0011 > : 1622 ; fail_safe_high_counter := fail_safe 1623 1eb 082e movf fail_safe,w 1624 1ec 00b0 movwf fail_safe_high_counter 1625 ; fail_safe_low_counter := 0 1626 1ed 01b1 clrf fail_safe_low_counter 1627 1ee 2a00 goto switch__545end 1628 switch__545block567: 1629 ; Set Speed < Command = 1000 01 dm > : 1630 ; temp := get_byte {{ }} 1631 1ef 2046 call get_byte 1632 1f0 0837 movf get_byte__0return__byte,w 1633 1f1 00bf movwf main__temp 1634 ; if { command @ 0 } start 1635 ; Alias variable for select command @ 0 1636 003e main__command__570select0 equ main__command+0 1637 003e main__command__570select0__byte equ main__command+0 1638 0000 main__command__570select0__bit equ 0 1639 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=5 false_delay=5 true_size=5 false_size=5 1640 1f2 1c3e btfss main__command__570select0__byte,main__command__570select0__bit 1641 1f3 29fa goto label570__1false 1642 label570__1true: 1643 ; if { command @ 0 } body start 1644 ; Motor 1 : 1645 ; desired_speed1 := temp 1646 1f4 083f movf main__temp,w 1647 1f5 00a7 movwf desired_speed1 1648 ; motor1_direction := command @ 1 1649 ; Alias variable for select command @ 1 1650 003e main__command__573select0 equ main__command+0 1651 003e main__command__573select0__byte equ main__command+0 1652 0001 main__command__573select0__bit equ 1 1653 1f6 11c2 bcf motor1_direction__byte,motor1_direction__bit 1654 1f7 18be btfsc main__command__573select0__byte,main__command__573select0__bit 1655 1f8 15c2 bsf motor1_direction__byte,motor1_direction__bit 1656 ; if { command @ 0 } body end 1657 1f9 29ff goto label570__1end 1658 label570__1false: 1659 ; else body start 1660 ; Motor 0 : 1661 ; desired_speed0 := temp 1662 1fa 083f movf main__temp,w 1663 1fb 00a6 movwf desired_speed0 1664 ; motor0_direction := command @ 1 1665 ; Alias variable for select command @ 1 1666 003e main__command__577select0 equ main__command+0 1667 003e main__command__577select0__byte equ main__command+0 1668 0001 main__command__577select0__bit equ 1 1669 1fc 1142 bcf motor0_direction__byte,motor0_direction__bit 1670 1fd 18be btfsc main__command__577select0__byte,main__command__577select0__bit 1671 1fe 1542 bsf motor0_direction__byte,motor0_direction__bit 1672 ; else body end 1673 ; if exp=` command @ 0 ' generic 1674 label570__1end: 1675 ; Other expression=`{ command @ 0 }' delay=-1 1676 ; if { command @ 0 } end 1677 ; call set_up {{ }} 1678 1ff 207d call set_up 1679 switch__545end: 1680 200 2a83 goto switch__542end 1681 switch__542block583: 1682 ; Command = 1000 1 xxx : 1683 ; if { command @ 2 } start 1684 ; Alias variable for select command @ 2 1685 003e main__command__585select0 equ main__command+0 1686 003e main__command__585select0__byte equ main__command+0 1687 0002 main__command__585select0__bit equ 2 1688 ; expression=`{ command @ 2 }' exp_delay=0 true_delay=-1 false_delay=-1 true_size=9 false_size=9 1689 201 1d3e btfss main__command__585select0__byte,main__command__585select0__bit 1690 202 2a0d goto label585__1false 1691 label585__1true: 1692 ; if { command @ 2 } body start 1693 ; Set direction < Command = 1000 11 dm > : 1694 ; if { command @ 0 } start 1695 ; Alias variable for select command @ 0 1696 003e main__command__587select0 equ main__command+0 1697 003e main__command__587select0__byte equ main__command+0 1698 0000 main__command__587select0__bit equ 0 1699 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=3 false_delay=3 true_size=3 false_size=3 1700 203 1c3e btfss main__command__587select0__byte,main__command__587select0__bit 1701 204 2a09 goto label587__1false 1702 label587__1true: 1703 ; if { command @ 0 } body start 1704 ; Motor 1 : 1705 ; motor1_direction := command @ 1 1706 ; Alias variable for select command @ 1 1707 003e main__command__589select0 equ main__command+0 1708 003e main__command__589select0__byte equ main__command+0 1709 0001 main__command__589select0__bit equ 1 1710 205 11c2 bcf motor1_direction__byte,motor1_direction__bit 1711 206 18be btfsc main__command__589select0__byte,main__command__589select0__bit 1712 207 15c2 bsf motor1_direction__byte,motor1_direction__bit 1713 ; if { command @ 0 } body end 1714 208 2a0c goto label587__1end 1715 label587__1false: 1716 ; else body start 1717 ; Motor 0 : 1718 ; motor0_direction := command @ 1 1719 ; Alias variable for select command @ 1 1720 003e main__command__592select0 equ main__command+0 1721 003e main__command__592select0__byte equ main__command+0 1722 0001 main__command__592select0__bit equ 1 1723 209 1142 bcf motor0_direction__byte,motor0_direction__bit 1724 20a 18be btfsc main__command__592select0__byte,main__command__592select0__bit 1725 20b 1542 bsf motor0_direction__byte,motor0_direction__bit 1726 ; else body end 1727 ; if exp=` command @ 0 ' generic 1728 label587__1end: 1729 ; Other expression=`{ command @ 0 }' delay=-1 1730 ; if { command @ 0 } end 1731 ; if { command @ 2 } body end 1732 20c 2a16 goto label585__1end 1733 label585__1false: 1734 ; else body start 1735 ; Set mode < Command = 1000 10 xm > : 1736 ; if { command @ 0 } start 1737 ; Alias variable for select command @ 0 1738 003e main__command__596select0 equ main__command+0 1739 003e main__command__596select0__byte equ main__command+0 1740 0000 main__command__596select0__bit equ 0 1741 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=3 false_delay=3 true_size=3 false_size=3 1742 20d 1c3e btfss main__command__596select0__byte,main__command__596select0__bit 1743 20e 2a13 goto label596__1false 1744 label596__1true: 1745 ; if { command @ 0 } body start 1746 ; Motor 1 : 1747 ; motor1_mode := command @ 1 1748 ; Alias variable for select command @ 1 1749 003e main__command__598select0 equ main__command+0 1750 003e main__command__598select0__byte equ main__command+0 1751 0001 main__command__598select0__bit equ 1 1752 20f 10c2 bcf motor1_mode__byte,motor1_mode__bit 1753 210 18be btfsc main__command__598select0__byte,main__command__598select0__bit 1754 211 14c2 bsf motor1_mode__byte,motor1_mode__bit 1755 ; if { command @ 0 } body end 1756 212 2a16 goto label596__1end 1757 label596__1false: 1758 ; else body start 1759 ; Motor 0 : 1760 ; motor0_mode := command @ 1 1761 ; Alias variable for select command @ 1 1762 003e main__command__601select0 equ main__command+0 1763 003e main__command__601select0__byte equ main__command+0 1764 0001 main__command__601select0__bit equ 1 1765 213 1042 bcf motor0_mode__byte,motor0_mode__bit 1766 214 18be btfsc main__command__601select0__byte,main__command__601select0__bit 1767 215 1442 bsf motor0_mode__byte,motor0_mode__bit 1768 ; else body end 1769 ; if exp=` command @ 0 ' generic 1770 label596__1end: 1771 ; Other expression=`{ command @ 0 }' delay=-1 1772 ; if { command @ 0 } end 1773 ; else body end 1774 ; if exp=` command @ 2 ' generic 1775 label585__1end: 1776 ; Other expression=`{ command @ 2 }' delay=-1 1777 ; if { command @ 2 } end 1778 ; call set_up {{ }} 1779 216 207d call set_up 1780 217 2a83 goto switch__542end 1781 switch__542block606: 1782 ; Set Prescaler < Command = 1001 0 ppp > : 1783 ; option := option_mask | {{ command & 7 }} 1784 218 3007 movlw 7 1785 219 053e andwf main__command,w 1786 21a 3880 iorlw 128 1787 ; Switch from register bank 0 to register bank 1 (which contains option) 1788 21b 1683 bsf rp0___byte,rp0___bit 1789 ; Register bank is now 1 1790 21c 0081 movwf option 1791 ; Switch from register bank 1 to register bank 0 1792 21d 1283 bcf rp0___byte,rp0___bit 1793 ; Register bank is now 0 1794 21e 2a83 goto switch__542end 1795 switch__542block610: 1796 ; Command = 1001 1 xxx : 1797 ; switch { command & 7 } 1798 21f 3002 movlw HIGH switch__612block_start 1799 220 008a movwf pclath___register 1800 221 3007 movlw 7 1801 222 053e andwf main__command,w 1802 ; case 0 1803 ; case 1 1804 ; case 2 3 1805 ; case 4 5 1806 ; case 6 7 1807 switch__612block_start: 1808 223 0782 addwf pcl___register,f 1809 224 2a2c goto switch__612block613 1810 225 2a30 goto switch__612block617 1811 226 2a37 goto switch__612block621 1812 227 2a37 goto switch__612block621 1813 228 2a3e goto switch__612block629 1814 229 2a3e goto switch__612block629 1815 22a 2a4e goto switch__612block651 1816 22b 2a4e goto switch__612block651 1817 switch__612block_end: 1818 ; switch_check 612 switch__612block_start switch__612block_end 1819 switch__612block613: 1820 ; Read Failsafe < Command = 1001 1000 > : 1821 ; call send_byte {{ fail_safe }} 1822 22c 082e movf fail_safe,w 1823 22d 00bb movwf send_byte__char 1824 22e 2062 call send_byte 1825 22f 2a55 goto switch__612end 1826 switch__612block617: 1827 ; Read Prescaler < Command = 1001 1001 > : 1828 ; call send_byte {{ option & 7 }} 1829 230 3007 movlw 7 1830 ; Switch from register bank 0 to register bank 1 (which contains option) 1831 231 1683 bsf rp0___byte,rp0___bit 1832 ; Register bank is now 1 1833 232 0501 andwf option,w 1834 233 00bb movwf send_byte__char 1835 ; Switch from register bank 1 to register bank 0 1836 234 1283 bcf rp0___byte,rp0___bit 1837 ; Register bank is now 0 1838 235 2062 call send_byte 1839 236 2a55 goto switch__612end 1840 switch__612block621: 1841 ; Read Speed < Command = 1001 101 m > : 1842 ; if { command @ 0 } start 1843 ; Alias variable for select command @ 0 1844 003e main__command__623select0 equ main__command+0 1845 003e main__command__623select0__byte equ main__command+0 1846 0000 main__command__623select0__bit equ 0 1847 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=-1 false_delay=-1 true_size=1 false_size=1 1848 237 183e btfsc main__command__623select0__byte,main__command__623select0__bit 1849 ; if { command @ 0 } body start 1850 ; call send_byte {{ actual_speed1 }} 1851 238 0821 movf actual_speed1,w 1852 ; 2 instructions found for sharing 1853 239 1c3e btfss main__command__623select0__byte,main__command__623select0__bit 1854 ; else body start 1855 ; call send_byte {{ actual_speed0 }} 1856 23a 0820 movf actual_speed0,w 1857 ; 2 instructions found for sharing 1858 ; if exp=` command @ 0 ' single true and false skip delay=4 1859 ; Other expression=`{ command @ 0 }' delay=4 1860 ; 2 shared instructions follow 1861 23b 00bb movwf send_byte__char 1862 23c 2062 call send_byte 1863 ; if { command @ 0 } end 1864 23d 2a55 goto switch__612end 1865 switch__612block629: 1866 ; Read Mode / Direction < Command = 1001 110 m > : 1867 ; temp := 0 1868 23e 01bf clrf main__temp 1869 ; if { command @ 0 } start 1870 ; Alias variable for select command @ 0 1871 003e main__command__632select0 equ main__command+0 1872 003e main__command__632select0__byte equ main__command+0 1873 0000 main__command__632select0__bit equ 0 1874 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=4 false_delay=4 true_size=4 false_size=4 1875 23f 1c3e btfss main__command__632select0__byte,main__command__632select0__bit 1876 240 2a46 goto label632__1false 1877 label632__1true: 1878 ; if { command @ 0 } body start 1879 ; Motor 1 : 1880 ; if { motor1_direction } start 1881 ; expression=`{ motor1_direction }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1882 241 19c2 btfsc motor1_direction__byte,motor1_direction__bit 1883 ; if { motor1_direction } body start 1884 ; temp @ 1 := 1 1885 ; Select temp @ 1 1886 003f main__temp__635select0 equ main__temp+0 1887 003f main__temp__635select0__byte equ main__temp+0 1888 0001 main__temp__635select0__bit equ 1 1889 242 14bf bsf main__temp__635select0__byte,main__temp__635select0__bit 1890 ; if { motor1_direction } body end 1891 ; if exp=`motor1_direction' false skip delay=2 1892 ; Other expression=`{ motor1_direction }' delay=2 1893 ; if { motor1_direction } end 1894 ; if { motor1_mode } start 1895 ; expression=`{ motor1_mode }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1896 243 18c2 btfsc motor1_mode__byte,motor1_mode__bit 1897 ; if { motor1_mode } body start 1898 ; temp @ 0 := 1 1899 ; Select temp @ 0 1900 003f main__temp__638select0 equ main__temp+0 1901 003f main__temp__638select0__byte equ main__temp+0 1902 0000 main__temp__638select0__bit equ 0 1903 244 143f bsf main__temp__638select0__byte,main__temp__638select0__bit 1904 ; if { motor1_mode } body end 1905 ; if exp=`motor1_mode' false skip delay=2 1906 ; Other expression=`{ motor1_mode }' delay=2 1907 ; if { motor1_mode } end 1908 ; if { command @ 0 } body end 1909 245 2a4a goto label632__1end 1910 label632__1false: 1911 ; else body start 1912 ; Motor 0 : 1913 ; if { motor0_direction } start 1914 ; expression=`{ motor0_direction }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1915 246 1942 btfsc motor0_direction__byte,motor0_direction__bit 1916 ; if { motor0_direction } body start 1917 ; temp @ 1 := 1 1918 ; Select temp @ 1 1919 003f main__temp__643select0 equ main__temp+0 1920 003f main__temp__643select0__byte equ main__temp+0 1921 0001 main__temp__643select0__bit equ 1 1922 247 14bf bsf main__temp__643select0__byte,main__temp__643select0__bit 1923 ; if { motor0_direction } body end 1924 ; if exp=`motor0_direction' false skip delay=2 1925 ; Other expression=`{ motor0_direction }' delay=2 1926 ; if { motor0_direction } end 1927 ; if { motor0_mode } start 1928 ; expression=`{ motor0_mode }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1929 248 1842 btfsc motor0_mode__byte,motor0_mode__bit 1930 ; if { motor0_mode } body start 1931 ; temp @ 0 := 1 1932 ; Select temp @ 0 1933 003f main__temp__646select0 equ main__temp+0 1934 003f main__temp__646select0__byte equ main__temp+0 1935 0000 main__temp__646select0__bit equ 0 1936 249 143f bsf main__temp__646select0__byte,main__temp__646select0__bit 1937 ; if { motor0_mode } body end 1938 ; if exp=`motor0_mode' false skip delay=2 1939 ; Other expression=`{ motor0_mode }' delay=2 1940 ; if { motor0_mode } end 1941 ; else body end 1942 ; if exp=` command @ 0 ' generic 1943 label632__1end: 1944 ; Other expression=`{ command @ 0 }' delay=-1 1945 ; if { command @ 0 } end 1946 ; call send_byte {{ temp }} 1947 24a 083f movf main__temp,w 1948 24b 00bb movwf send_byte__char 1949 24c 2062 call send_byte 1950 24d 2a55 goto switch__612end 1951 switch__612block651: 1952 ; Read Ramp < Command = 1001 101 m > : 1953 ; if { command @ 0 } start 1954 ; Alias variable for select command @ 0 1955 003e main__command__653select0 equ main__command+0 1956 003e main__command__653select0__byte equ main__command+0 1957 0000 main__command__653select0__bit equ 0 1958 ; expression=`{ command @ 0 }' exp_delay=0 true_delay=1 false_delay=1 true_size=1 false_size=1 1959 24e 183e btfsc main__command__653select0__byte,main__command__653select0__bit 1960 ; if { command @ 0 } body start 1961 ; temp := ramp1 1962 24f 0829 movf ramp1,w 1963 ; 1 instructions found for sharing 1964 250 1c3e btfss main__command__653select0__byte,main__command__653select0__bit 1965 ; else body start 1966 ; temp := ramp0 1967 251 0828 movf ramp0,w 1968 ; 1 instructions found for sharing 1969 ; if exp=` command @ 0 ' single true and false skip delay=4 1970 ; Other expression=`{ command @ 0 }' delay=4 1971 ; 1 shared instructions follow 1972 252 00bf movwf main__temp 1973 ; if { command @ 0 } end 1974 ; call send_byte {{ temp }} 1975 253 00bb movwf send_byte__char 1976 254 2062 call send_byte 1977 switch__612end: 1978 255 2a83 goto switch__542end 1979 switch__542block662: 1980 ; Command = 0110 0 xxx : 1981 ; switch { command & 7 } 1982 256 3002 movlw HIGH switch__664block_start 1983 257 008a movwf pclath___register 1984 258 3007 movlw 7 1985 259 053e andwf main__command,w 1986 ; case 0 1987 ; case 1 1988 ; case 2 1989 ; case 3 1990 ; case 4 1991 ; case 5 1992 ; case 6 1993 ; case 7 1994 switch__664block_start: 1995 25a 0782 addwf pcl___register,f 1996 25b 2a63 goto switch__664block665 1997 25c 2a68 goto switch__664block670 1998 25d 2a6c goto switch__664block674 1999 25e 2a70 goto switch__664block678 2000 25f 2a74 goto switch__664block682 2001 260 2a76 goto switch__664block686 2002 261 2a78 goto switch__664block690 2003 262 2a7a goto switch__664block694 2004 switch__664block_end: 2005 ; switch_check 664 switch__664block_start switch__664block_end 2006 switch__664block665: 2007 ; Read Failsafe Errors < Command = 1010 0000 > : 2008 ; call send_byte {{ fail_safe_errors }} 2009 263 082f movf fail_safe_errors,w 2010 264 00bb movwf send_byte__char 2011 265 2062 call send_byte 2012 ; fail_safe_errors := 0 2013 266 01af clrf fail_safe_errors 2014 267 2a7b goto switch__664end 2015 switch__664block670: 2016 ; Read Failsafe Counter < Command = 1010 0001 > : 2017 ; call send_byte {{ fail_safe_high_counter }} 2018 268 0830 movf fail_safe_high_counter,w 2019 269 00bb movwf send_byte__char 2020 26a 2062 call send_byte 2021 26b 2a7b goto switch__664end 2022 switch__664block674: 2023 ; Read Actual Speed 0 < Command = 1010 0010 > : 2024 ; call send_byte {{ actual_speed0 }} 2025 26c 0820 movf actual_speed0,w 2026 26d 00bb movwf send_byte__char 2027 26e 2062 call send_byte 2028 26f 2a7b goto switch__664end 2029 switch__664block678: 2030 ; Read Actual Speed 1 < Command = 1010 0011 > : 2031 ; call send_byte {{ actual_speed1 }} 2032 270 0821 movf actual_speed1,w 2033 271 00bb movwf send_byte__char 2034 272 2062 call send_byte 2035 273 2a7b goto switch__664end 2036 switch__664block682: 2037 ; Set Motor 0 off < Command = 1010 0100 > : 2038 ; motor0e := 0 2039 274 1107 bcf motor0e__byte,motor0e__bit 2040 275 2a7b goto switch__664end 2041 switch__664block686: 2042 ; Set Motor 0 on < Command = 1010 0101 > : 2043 ; motor0e := 1 2044 276 1507 bsf motor0e__byte,motor0e__bit 2045 277 2a7b goto switch__664end 2046 switch__664block690: 2047 ; Set Motor 1 off < Command = 1010 0110 > : 2048 ; motor1e := 0 2049 278 1187 bcf motor1e__byte,motor1e__bit 2050 279 2a7b goto switch__664end 2051 switch__664block694: 2052 ; Set Motor 1 on < Command = 1010 0111 > : 2053 ; motor1e := 1 2054 27a 1587 bsf motor1e__byte,motor1e__bit 2055 switch__664end: 2056 27b 2a83 goto switch__542end 2057 switch__542block700: 2058 ; if { command & 3 = 0 } start 2059 27c 3003 movlw 3 2060 27d 053e andwf main__command,w 2061 ; expression=`{ command & 3 = 0 }' exp_delay=2 true_delay=-1 false_delay=0 true_size=2 false_size=0 2062 27e 1d03 btfss z___byte,z___bit 2063 27f 2a82 goto label701__0end 2064 ; if { command & 3 = 0 } body start 2065 ; FIXME : Code generator chokes on single call instruction 2066 ; in the then clause . Add ' ramp0 := 0 ' to work around ! ! ! 2067 ; ramp0 := 0 2068 280 01a8 clrf ramp0 2069 ; call reset {{ }} 2070 281 20c3 call reset 2071 ; if { command & 3 = 0 } body end 2072 label701__0end: 2073 ; if exp=` command & 3 = 0 ' empty false 2074 ; Other expression=`{ command & 3 = 0 }' delay=-1 2075 ; if { command & 3 = 0 } end 2076 282 2a83 goto switch__542end 2077 switch__542default708: 2078 ; Do nothing : 2079 switch__542end: 2080 283 2acd goto switch__512end 2081 switch__512block713: 2082 ; Command = 11 xx xxxx : 2083 ; switch { {{ command >> 3 }} & 7 } 2084 284 3002 movlw HIGH switch__715block_start 2085 285 008a movwf pclath___register 2086 286 0c3e rrf main__command,w 2087 287 00c0 movwf main__715byte0 2088 288 0cc0 rrf main__715byte0,f 2089 289 0c40 rrf main__715byte0,w 2090 28a 3907 andlw 7 2091 ; case 7 2092 switch__715block_start: 2093 28b 0782 addwf pcl___register,f 2094 28c 2acd goto switch__715end 2095 28d 2acd goto switch__715end 2096 28e 2acd goto switch__715end 2097 28f 2acd goto switch__715end 2098 290 2acd goto switch__715end 2099 291 2acd goto switch__715end 2100 292 2acd goto switch__715end 2101 293 2a94 goto switch__715block716 2102 switch__715block_end: 2103 ; switch_check 715 switch__715block_start switch__715block_end 2104 switch__715block716: 2105 ; Shared commands < Command = 1111 1 ccc > : 2106 ; switch { command & 7 } 2107 294 3002 movlw HIGH switch__718block_start 2108 295 008a movwf pclath___register 2109 296 3007 movlw 7 2110 297 053e andwf main__command,w 2111 ; case 0 2112 ; case 1 2113 ; case 2 2114 ; case 3 2115 ; case 4 2116 ; case 5 2117 ; case 6 2118 ; case 7 2119 switch__718block_start: 2120 298 0782 addwf pcl___register,f 2121 299 2aa1 goto switch__718block719 2122 29a 2aa6 goto switch__718block723 2123 29b 2aab goto switch__718block727 2124 29c 2ab1 goto switch__718block731 2125 29d 2ab4 goto switch__718block735 2126 29e 2ac3 goto switch__718block746 2127 29f 2ac5 goto switch__718block750 2128 2a0 2aca goto switch__718block755 2129 switch__718block_end: 2130 ; switch_check 718 switch__718block_start switch__718block_end 2131 switch__718block719: 2132 ; Clock Decrement < Command = 1111 1000 > : 2133 ; osccal := osccal - osccal_unit 2134 2a1 30fc movlw 252 2135 ; Switch from register bank 0 to register bank 1 (which contains osccal) 2136 2a2 1683 bsf rp0___byte,rp0___bit 2137 ; Register bank is now 1 2138 2a3 0790 addwf osccal,f 2139 ; Switch from register bank 1 to register bank 0 2140 2a4 1283 bcf rp0___byte,rp0___bit 2141 ; Register bank is now 0 2142 2a5 2acd goto switch__718end 2143 switch__718block723: 2144 ; Clock Increment < Command = 1111 1001 > : 2145 ; osccal := osccal + osccal_unit 2146 2a6 3004 movlw 4 2147 ; Switch from register bank 0 to register bank 1 (which contains osccal) 2148 2a7 1683 bsf rp0___byte,rp0___bit 2149 ; Register bank is now 1 2150 2a8 0790 addwf osccal,f 2151 ; Switch from register bank 1 to register bank 0 2152 2a9 1283 bcf rp0___byte,rp0___bit 2153 ; Register bank is now 0 2154 2aa 2acd goto switch__718end 2155 switch__718block727: 2156 ; Clock Read < Command = 1111 1010 > : 2157 ; call send_byte {{ osccal }} 2158 ; Switch from register bank 0 to register bank 1 (which contains osccal) 2159 2ab 1683 bsf rp0___byte,rp0___bit 2160 ; Register bank is now 1 2161 2ac 0810 movf osccal,w 2162 2ad 00bb movwf send_byte__char 2163 ; Switch from register bank 1 to register bank 0 2164 2ae 1283 bcf rp0___byte,rp0___bit 2165 ; Register bank is now 0 2166 2af 2062 call send_byte 2167 2b0 2acd goto switch__718end 2168 switch__718block731: 2169 ; Clock Pulse < Command = 1111 1011 > : 2170 ; call send_byte {{ 0 }} 2171 2b1 01bb clrf send_byte__char 2172 2b2 2062 call send_byte 2173 2b3 2acd goto switch__718end 2174 switch__718block735: 2175 ; ID Next < Command = 1111 1100 > : 2176 ; if { id_index >= id . size } start 2177 2b4 3030 movlw 48 2178 2b5 0235 subwf id_index,w 2179 ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 2180 2b6 1803 btfsc c___byte,c___bit 2181 ; if { id_index >= id . size } body start 2182 ; id_index := 0 2183 2b7 01b5 clrf id_index 2184 ; if { id_index >= id . size } body end 2185 ; if exp=` id_index >= id . size ' false skip delay=4 2186 ; Other expression=`{ id_index >= id . size }' delay=4 2187 ; if { id_index >= id . size } end 2188 ; call send_byte {{ id ~~ {{ id_index }} }} 2189 2b8 0a35 incf id_index,w 2190 2b9 018a clrf pclath___register 2191 2ba 2014 call id 2192 2bb 00bb movwf send_byte__char 2193 2bc 2062 call send_byte 2194 ; id_index := id_index + 1 2195 2bd 0ab5 incf id_index,f 2196 ; if { id_index >= id . size } start 2197 2be 3030 movlw 48 2198 2bf 0235 subwf id_index,w 2199 ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 2200 2c0 1803 btfsc c___byte,c___bit 2201 ; if { id_index >= id . size } body start 2202 ; id_index := 0 2203 2c1 01b5 clrf id_index 2204 ; if { id_index >= id . size } body end 2205 ; if exp=` id_index >= id . size ' false skip delay=4 2206 ; Other expression=`{ id_index >= id . size }' delay=4 2207 ; if { id_index >= id . size } end 2208 2c2 2acd goto switch__718end 2209 switch__718block746: 2210 ; ID Reset < Command = 1111 1101 > : 2211 ; id_index := 0 2212 2c3 01b5 clrf id_index 2213 2c4 2acd goto switch__718end 2214 switch__718block750: 2215 ; Glitch Read < Command = 1111 1110 > : 2216 ; call send_byte {{ glitch }} 2217 2c5 0834 movf glitch,w 2218 2c6 00bb movwf send_byte__char 2219 2c7 2062 call send_byte 2220 ; glitch := 0 2221 2c8 01b4 clrf glitch 2222 2c9 2acd goto switch__718end 2223 switch__718block755: 2224 ; Glitch < Command = 1111 1111 > : 2225 ; if { glitch != 0xff } start 2226 2ca 0a34 incf glitch,w 2227 ; expression=`{ glitch != 0xff }' exp_delay=1 true_delay=1 false_delay=0 true_size=1 false_size=0 2228 2cb 1d03 btfss z___byte,z___bit 2229 ; if { glitch != 0xff } body start 2230 ; glitch := glitch + 1 2231 2cc 0ab4 incf glitch,f 2232 ; if { glitch != 0xff } body end 2233 ; if exp=` glitch != 0xff ' false skip delay=3 2234 ; Other expression=`{ glitch != 0xff }' delay=3 2235 ; if { glitch != 0xff } end 2236 switch__718end: 2237 switch__715end: 2238 switch__512end: 2239 2cd 297b goto main__507loop__forever 2240 ; loop_forever ... end 2241 ; procedure main end 2242 2243 ; Register bank 0 used 34 bytes of 64 available bytes 2244 ; Register bank 1 used 0 bytes of 0 available bytes 2245 2246 end