1 radix dec 2 0020 global__variables__bank0 equ 32 3 00a0 global__variables__bank1 equ 160 4 0120 global__variables__bank2 equ 288 5 01f0 global__variables__bank3 equ 496 6 0067 global__bit__variables__bank0 equ 103 7 00a0 global__bit__variables__bank1 equ 160 8 0120 global__bit__variables__bank2 equ 288 9 01f0 global__bit__variables__bank3 equ 496 10 0000 indf___register equ 0 11 0002 pcl___register equ 2 12 0003 c___byte equ 3 13 0000 c___bit equ 0 14 0003 z___byte equ 3 15 0002 z___bit equ 2 16 0003 rp0___byte equ 3 17 0005 rp0___bit equ 5 18 0003 rp1___byte equ 3 19 0006 rp1___bit equ 6 20 0003 irp___byte equ 3 21 0007 irp___bit equ 7 22 0085 trisa___register equ 0x85 23 0086 trisb___register equ 0x86 24 0004 fsr___register equ 4 25 000a pclath___register equ 10 26 org 0 27 start: 28 000 0000 nop 29 001 0000 nop 30 002 0000 nop 31 003 2805 goto skip___interrupt 32 interrupt___vector: 33 004 0009 retfie 34 skip___interrupt: 35 ; Initialize A/D system to allow digital I/O 36 005 3007 movlw 7 37 006 009f movwf 31 38 ; Switch from register bank 0 to register bank 1 (which contains 159) 39 007 1683 bsf rp0___byte,rp0___bit 40 ; Register bank is now 1 41 008 019f clrf 159 42 ; Initialize TRIS registers 43 009 30eb movlw 235 44 00a 0086 movwf trisb___register 45 00b 018a clrf pclath___register 46 ; Switch from register bank 1 to register bank 0 47 00c 1283 bcf rp0___byte,rp0___bit 48 ; Register bank is now 0 49 00d 286e goto main 50 ; comment ############################################################################# 51 ; comment {} 52 ; comment {Copyright < c > 1999 - 2001 by Wayne C . Gramlich .} 53 ; comment {All rights reserved .} 54 ; comment {} 55 ; comment {Permission to use , copy , modify , distribute , and sell this software} 56 ; comment {for any purpose is hereby granted without fee provided that the above} 57 ; comment {copyright notice and this permission are retained . The author makes} 58 ; comment {no representations about the suitability of this software for any purpose .} 59 ; comment {It is provided { as is } without express or implied warranty .} 60 ; comment {} 61 ; comment {This is a test harness for testing the LED10 RoboBrick . See :} 62 ; comment {} 63 ; comment {http : / / web . gramlich . net / projects / robobricks / led10 / index . html} 64 ; comment {} 65 ; comment {for more details .} 66 ; comment {} 67 ; comment ############################################################################# 68 ; processor pic16f628 cp = off cpd = off lvp = off bowden = off mclre = on pwrte = off wdte = off fosc = xt 69 ; 16169=0x3f29 8199=0x2007 70 __config 16169 71 2007 configuration___address equ 8199 72 ; constant clock_rate 10000000 73 989680 clock_rate equ 10000000 74 ; constant clock_ticks_per_instruction 4 75 0004 clock_ticks_per_instruction equ 4 76 ; constant instructions_per_second clock_rate / clock_ticks_per_instruction 77 2625a0 instructions_per_second equ 2500000 78 ; constant baud_rate 2400 79 0960 baud_rate equ 2400 80 ; constant instructions_per_bit clock_rate / {{ clock_ticks_per_instruction * baud_rate }} 81 0411 instructions_per_bit equ 1041 82 ; constant delays_per_bit 3 83 0003 delays_per_bit equ 3 84 ; constant instructions_per_delay instructions_per_bit / delays_per_bit 85 015b instructions_per_delay equ 347 86 ; constant extra_instructions_per_bit 12 87 000c extra_instructions_per_bit equ 12 88 ; constant extra_instructions_per_delay extra_instructions_per_bit / delays_per_bit 89 0004 extra_instructions_per_delay equ 4 90 ; constant delay_instructions instructions_per_delay - extra_instructions_per_delay 91 0157 delay_instructions equ 343 92 ; comment {The null pulse that comes back from a clock pulse command is supposed to be} 93 ; comment {exactly 9 bits long . 9 bits at 2400 baud is 9 / 2400 = 3 . 75 mS . The number} 94 ; comment {iterations through the loop is 3 . 75 mS / < number of instructions per iteration . >} 95 ; constant nine_bits_instructions {{ clock_rate * 9 }} / {{ clock_ticks_per_instruction * baud_rate }} 96 249f nine_bits_instructions equ 9375 97 ; constant instructions_per_iteration 7 98 0007 instructions_per_iteration equ 7 99 ; constant iterations_for_nine_bits nine_bits_instructions / instructions_per_iteration 100 053b iterations_for_nine_bits equ 1339 101 ; constant iterations_high iterations_for_nine_bits / 256 102 0005 iterations_high equ 5 103 ; constant iterations_low iterations_for_nine_bits - {{ iterations_high * 256 }} 104 003b iterations_low equ 59 105 ; comment {Some character constants :} 106 ; constant sp 32 107 0020 sp equ 32 108 ; constant cr 13 109 000d cr equ 13 110 ; constant lf 10 111 000a lf equ 10 112 ; comment {Some bit definitions :} 113 ; constant rx_slave_bit 5 114 0005 rx_slave_bit equ 5 115 ; constant tx_slave_bit 4 116 0004 tx_slave_bit equ 4 117 ; constant rx_master_bit 1 118 0001 rx_master_bit equ 1 119 ; constant tx_master_bit 2 120 0002 tx_master_bit equ 2 121 ; constant rx_slave_mask 1 << rx_slave_bit 122 0020 rx_slave_mask equ 32 123 ; constant tx_slave_mask 1 << tx_slave_bit 124 0010 tx_slave_mask equ 16 125 ; constant rx_master_mask 1 << rx_master_bit 126 0002 rx_master_mask equ 2 127 ; constant tx_master_mask 1 << tx_master_bit 128 0004 tx_master_mask equ 4 129 ; comment {Some register definitions :} 130 0003 status equ 3 131 ; bind c status @ 0 132 0003 c equ status+0 133 0003 c__byte equ status+0 134 0000 c__bit equ 0 135 ; bind z status @ 2 136 0003 z equ status+0 137 0003 z__byte equ status+0 138 0002 z__bit equ 2 139 ; comment {Some port and pin definitions :} 140 ; comment {port porta a unused none} 141 0006 portb equ 6 142 0006 tx_master_pin__byte equ 6 143 0002 tx_master_pin__bit equ 2 144 0006 rx_master_pin__byte equ 6 145 0001 rx_master_pin__bit equ 1 146 0006 tx_slave_pin__byte equ 6 147 0004 tx_slave_pin__bit equ 4 148 0006 rx_slave_pin__byte equ 6 149 0005 rx_slave_pin__bit equ 5 150 ; comment {Miscellaneous definitions :} 151 ; constant space 0xff 152 00ff space equ 255 153 ; constant buffer_size 3 154 0003 buffer_size equ 3 155 ; string_constants Start 156 string___fetch: 157 00e 0082 movwf pcl___register 158 ; common_string = 0s'Common' 159 0000 common_string___string equ 0 160 common_string: 161 00f 0782 addwf pcl___register,f 162 ; Length = 6 163 010 3406 retlw 6 164 ; `Common' 165 011 3443 retlw 67 166 012 346f retlw 111 167 013 346d retlw 109 168 014 346d retlw 109 169 015 346f retlw 111 170 016 346e retlw 110 171 ; done_string = 0s'Done' 172 0008 done_string___string equ 8 173 done_string: 174 017 0782 addwf pcl___register,f 175 ; Length = 4 176 018 3404 retlw 4 177 ; `Done' 178 019 3444 retlw 68 179 01a 346f retlw 111 180 01b 346e retlw 110 181 01c 3465 retlw 101 182 ; fail_string = 0s'Fail' 183 000e fail_string___string equ 14 184 fail_string: 185 01d 0782 addwf pcl___register,f 186 ; Length = 4 187 01e 3404 retlw 4 188 ; `Fail' 189 01f 3446 retlw 70 190 020 3461 retlw 97 191 021 3469 retlw 105 192 022 346c retlw 108 193 ; hello_string = 0s'BIROD2_Test' 194 0014 hello_string___string equ 20 195 hello_string: 196 023 0782 addwf pcl___register,f 197 ; Length = 11 198 024 340b retlw 11 199 ; `BIROD2_Test' 200 025 3442 retlw 66 201 026 3449 retlw 73 202 027 3452 retlw 82 203 028 344f retlw 79 204 029 3444 retlw 68 205 02a 3432 retlw 50 206 02b 345f retlw 95 207 02c 3454 retlw 84 208 02d 3465 retlw 101 209 02e 3473 retlw 115 210 02f 3474 retlw 116 211 ; input_string = 0s'Input' 212 0021 input_string___string equ 33 213 input_string: 214 030 0782 addwf pcl___register,f 215 ; Length = 5 216 031 3405 retlw 5 217 ; `Input' 218 032 3449 retlw 73 219 033 346e retlw 110 220 034 3470 retlw 112 221 035 3475 retlw 117 222 036 3474 retlw 116 223 ; interrupt_string = 0s'Interrupt' 224 0028 interrupt_string___string equ 40 225 interrupt_string: 226 037 0782 addwf pcl___register,f 227 ; Length = 9 228 038 3409 retlw 9 229 ; `Interrupt' 230 039 3449 retlw 73 231 03a 346e retlw 110 232 03b 3474 retlw 116 233 03c 3465 retlw 101 234 03d 3472 retlw 114 235 03e 3472 retlw 114 236 03f 3475 retlw 117 237 040 3470 retlw 112 238 041 3474 retlw 116 239 ; enable_string = 0s'Enable and Alternate' 240 0033 enable_string___string equ 51 241 enable_string: 242 042 0782 addwf pcl___register,f 243 ; Length = 20 244 043 3414 retlw 20 245 ; `Enable and Alternate' 246 044 3445 retlw 69 247 045 346e retlw 110 248 046 3461 retlw 97 249 047 3462 retlw 98 250 048 346c retlw 108 251 049 3465 retlw 101 252 04a 3420 retlw 32 253 04b 3461 retlw 97 254 04c 346e retlw 110 255 04d 3464 retlw 100 256 04e 3420 retlw 32 257 04f 3441 retlw 65 258 050 346c retlw 108 259 051 3474 retlw 116 260 052 3465 retlw 101 261 053 3472 retlw 114 262 054 346e retlw 110 263 055 3461 retlw 97 264 056 3474 retlw 116 265 057 3465 retlw 101 266 ; read_string = 0s'Read' 267 0049 read_string___string equ 73 268 read_string: 269 058 0782 addwf pcl___register,f 270 ; Length = 4 271 059 3404 retlw 4 272 ; `Read' 273 05a 3452 retlw 82 274 05b 3465 retlw 101 275 05c 3461 retlw 97 276 05d 3464 retlw 100 277 ; register_string = 0s'Register' 278 004f register_string___string equ 79 279 register_string: 280 05e 0782 addwf pcl___register,f 281 ; Length = 8 282 05f 3408 retlw 8 283 ; `Register' 284 060 3452 retlw 82 285 061 3465 retlw 101 286 062 3467 retlw 103 287 063 3469 retlw 105 288 064 3473 retlw 115 289 065 3474 retlw 116 290 066 3465 retlw 101 291 067 3472 retlw 114 292 ; test_string = 0s'Test' 293 0059 test_string___string equ 89 294 test_string: 295 068 0782 addwf pcl___register,f 296 ; Length = 4 297 069 3404 retlw 4 298 ; `Test' 299 06a 3454 retlw 84 300 06b 3465 retlw 101 301 06c 3473 retlw 115 302 06d 3474 retlw 116 303 ; string__constants End 304 0020 temp equ global__variables__bank0+0 305 306 ; procedure main start 307 main: 308 0021 main__variables__base equ global__variables__bank0+1 309 0021 main__bytes__base equ main__variables__base+0 310 0028 main__bits__base equ main__variables__base+7 311 0007 main__total__bytes equ 7 312 0027 main__119byte0 equ main__bytes__base+6 313 0027 main__147byte0 equ main__bytes__base+6 314 ; arguments_none 315 ; Read a byte . 316 0021 main__buffer equ main__bytes__base+0 317 0024 main__char equ main__bytes__base+3 318 0025 main__index equ main__bytes__base+4 319 0026 main__number equ main__bytes__base+5 320 ; Print out a welcome message : 321 ; call master_crlf {{ }} 322 06e 2408 call master_crlf 323 ; call master_string {{ hello_string }} 324 06f 3024 movlw LOW hello_string+1 325 070 00e3 movwf master_string__message 326 071 24a8 call master_string 327 ; call master_crlf {{ }} 328 072 2408 call master_crlf 329 ; Main loop 330 ; number := 0 331 073 01a6 clrf main__number 332 ; loop_forever ... start 333 main__107loop__forever: 334 ; Get a character : 335 ; tx_slave_pin := 1 336 074 1606 bsf tx_slave_pin__byte,tx_slave_pin__bit 337 ; char := master_get {{ }} 338 075 241a call master_get 339 076 0853 movf master_get__0return__byte,w 340 077 00a4 movwf main__char 341 ; Delay 2 / 3 ' s of bit make sure that get_byte is done . 342 ; call delay {{ }} 343 078 24bb call delay 344 ; call delay {{ }} 345 079 24bb call delay 346 ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } start 347 07a 3030 movlw 48 348 07b 0224 subwf main__char,w 349 ; expression=`0c'0' <= char' exp_delay=2 true_delay=-1 false_delay=1 true_size=127 false_size=1 350 07c 1c03 btfss c___byte,c___bit 351 07d 288e goto and116__0false 352 07e 303a movlw 58 353 07f 0224 subwf main__char,w 354 ; expression=`char < {{ 0c'9' + 1 }}' exp_delay=2 true_delay=9 false_delay=-1 true_size=11 false_size=111 355 080 1803 btfsc c___byte,c___bit 356 081 288e goto label116__1false 357 label116__1true: 358 and116__0true: 359 ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body start 360 ; Do a multiply by 8 then add in digit : 361 ; call master_send {{ char }} 362 082 0824 movf main__char,w 363 083 00e2 movwf master_send__character 364 084 24a2 call master_send 365 ; number := {{ number << 3 }} + char - 0c'0' 366 085 0d26 rlf main__number,w 367 086 00a7 movwf main__119byte0 368 087 0da7 rlf main__119byte0,f 369 088 0d27 rlf main__119byte0,w 370 089 39f8 andlw 248 371 08a 0724 addwf main__char,w 372 08b 3ed0 addlw 208 373 08c 00a6 movwf main__number 374 ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body end 375 08d 28fd goto label116__1end 376 label116__1false: 377 and116__0false: 378 08e 3073 movlw 115 379 08f 0224 subwf main__char,w 380 ; expression=`{ char = 0c's' }' exp_delay=2 true_delay=-1 false_delay=-1 true_size=8 false_size=98 381 090 1d03 btfss z___byte,z___bit 382 091 289b goto label120__0false 383 label120__0true: 384 ; else_if { char = 0c's' } body start 385 ; Send byte to brick , no wait : 386 ; Echo command and send CRLF : 387 ; call master_send {{ char }} 388 092 0824 movf main__char,w 389 093 00e2 movwf master_send__character 390 094 24a2 call master_send 391 ; call master_crlf {{ }} 392 095 2408 call master_crlf 393 ; Ship the byte down to the brick : 394 ; call slave_send {{ number }} 395 096 0826 movf main__number,w 396 097 00d8 movwf slave_send__data 397 098 2448 call slave_send 398 ; number := 0 399 099 01a6 clrf main__number 400 ; else_if { char = 0c's' } body end 401 09a 28fd goto label120__0end 402 label120__0false: 403 09b 3077 movlw 119 404 09c 0224 subwf main__char,w 405 ; expression=`{ char = 0c'w' }' exp_delay=2 true_delay=-1 false_delay=-1 true_size=39 false_size=54 406 09d 1d03 btfss z___byte,z___bit 407 09e 28c7 goto label131__0false 408 label131__0true: 409 ; else_if { char = 0c'w' } body start 410 ; Send byte to brick , wait for results : 411 ; Echo command and send CRLF : 412 ; call master_send {{ char }} 413 09f 0824 movf main__char,w 414 0a0 00e2 movwf master_send__character 415 0a1 24a2 call master_send 416 ; call master_crlf {{ }} 417 0a2 2408 call master_crlf 418 ; Ship the byte down to the brick ... 419 ; call slave_send {{ number }} 420 0a3 0826 movf main__number,w 421 0a4 00d8 movwf slave_send__data 422 0a5 2448 call slave_send 423 ; number := 0 424 0a6 01a6 clrf main__number 425 ; call delay < > 426 ; ... and wait for a response : 427 ; index := 0 428 0a7 01a5 clrf main__index 429 ; `while index < buffer_size ...' start 430 main__146while__continue: 431 0a8 3003 movlw 3 432 0a9 0225 subwf main__index,w 433 ; expression=` index < buffer_size ' exp_delay=2 true_delay=10 false_delay=2 true_size=11 false_size=1 434 0aa 1803 btfsc c___byte,c___bit 435 0ab 28b7 goto main__146while__break 436 ; buffer ~~ {{ index }} := slave_get {{ }} 437 0ac 2442 call slave_get 438 0ad 0857 movf slave_get__0return__byte,w 439 0ae 00a7 movwf main__147byte0 440 0af 3021 movlw LOW main__buffer 441 0b0 0725 addwf main__index,w 442 0b1 0084 movwf fsr___register 443 0b2 0827 movf main__147byte0,w 444 0b3 1383 bcf irp___register,irp___bit 445 0b4 0080 movwf indf___register 446 ; index := index + 1 447 0b5 0aa5 incf main__index,f 448 0b6 28a8 goto main__146while__continue 449 ; if exp=` index < buffer_size ' false goto 450 ; Other expression=` index < buffer_size ' delay=-1 451 main__146while__break: 452 ; `while index < buffer_size ...' end 453 ; index := 0 454 0b7 01a5 clrf main__index 455 ; `while index < buffer_size ...' start 456 main__152while__continue: 457 0b8 3003 movlw 3 458 0b9 0225 subwf main__index,w 459 ; expression=` index < buffer_size ' exp_delay=2 true_delay=8 false_delay=2 true_size=9 false_size=1 460 0ba 1803 btfsc c___byte,c___bit 461 0bb 28c5 goto main__152while__break 462 ; call master_octal {{ buffer ~~ {{ index }} }} 463 0bc 3021 movlw LOW main__buffer 464 0bd 0725 addwf main__index,w 465 0be 0084 movwf fsr___register 466 0bf 1383 bcf irp___register,irp___bit 467 0c0 0800 movf indf___register,w 468 0c1 00d5 movwf master_octal__number 469 0c2 2429 call master_octal 470 ; index := index + 1 471 0c3 0aa5 incf main__index,f 472 0c4 28b8 goto main__152while__continue 473 ; if exp=` index < buffer_size ' false goto 474 ; Other expression=` index < buffer_size ' delay=-1 475 main__152while__break: 476 ; `while index < buffer_size ...' end 477 ; Terminate the output list 478 ; call master_crlf {{ }} 479 0c5 2408 call master_crlf 480 ; else_if { char = 0c'w' } body end 481 0c6 28fd goto label131__0end 482 label131__0false: 483 0c7 3069 movlw 105 484 0c8 0224 subwf main__char,w 485 ; expression=`{ char = 0c'i' }' exp_delay=2 true_delay=-1 false_delay=-1 true_size=12 false_size=37 486 0c9 1d03 btfss z___byte,z___bit 487 0ca 28d8 goto label159__0false 488 label159__0true: 489 ; else_if { char = 0c'i' } body start 490 ; Interrogate the slave RoboBrick : 491 ; call master_send {{ char }} 492 0cb 0824 movf main__char,w 493 0cc 00e2 movwf master_send__character 494 0cd 24a2 call master_send 495 ; call master_crlf {{ }} 496 0ce 2408 call master_crlf 497 ; Initialize the id index : 498 ; call slave_send {{ 0xfd }} 499 0cf 30fd movlw 253 500 0d0 00d8 movwf slave_send__data 501 0d1 2448 call slave_send 502 ; Get the first 8 bytes : 503 ; call common_test_id_bytes8 {{ }} 504 0d2 237b call common_test_id_bytes8 505 ; Get the next 8 bytes of random numbers : 506 ; call common_test_id_bytes8 {{ }} 507 0d3 237b call common_test_id_bytes8 508 ; Get the next 8 bytes of random numbers : 509 ; call common_test_id_bytes8 {{ }} 510 0d4 237b call common_test_id_bytes8 511 ; Get the slave brick name : 512 ; call common_test_id_string {{ }} 513 0d5 2385 call common_test_id_string 514 ; Get the vendor name : 515 ; call common_test_id_string {{ }} 516 0d6 2385 call common_test_id_string 517 ; else_if { char = 0c'i' } body end 518 0d7 28fd goto label159__0end 519 label159__0false: 520 0d8 3074 movlw 116 521 0d9 0224 subwf main__char,w 522 ; expression=`{ char = 0c't' }' exp_delay=2 true_delay=-1 false_delay=-1 true_size=5 false_size=27 523 0da 1d03 btfss z___byte,z___bit 524 0db 28e2 goto label182__0false 525 label182__0true: 526 ; else_if { char = 0c't' } body start 527 ; Do testing : 528 ; call master_send {{ char }} 529 0dc 0824 movf main__char,w 530 0dd 00e2 movwf master_send__character 531 0de 24a2 call master_send 532 ; call master_crlf {{ }} 533 0df 2408 call master_crlf 534 ; call test {{ }} 535 0e0 218d call test 536 ; else_if { char = 0c't' } body end 537 0e1 28fd goto label182__0end 538 label182__0false: 539 0e2 3063 movlw 99 540 0e3 0224 subwf main__char,w 541 ; expression=`{ char = 0c'c' }' exp_delay=2 true_delay=-2 false_delay=-2 true_size=7 false_size=14 542 0e4 1d03 btfss z___byte,z___bit 543 0e5 28ee goto label187__0false 544 label187__0true: 545 ; else_if { char = 0c'c' } body start 546 ; call master_send {{ char }} 547 0e6 0824 movf main__char,w 548 0e7 00e2 movwf master_send__character 549 0e8 24a2 call master_send 550 ; call master_crlf {{ }} 551 0e9 2408 call master_crlf 552 ; call clock_adjust {{ number }} 553 0ea 0826 movf main__number,w 554 0eb 00a8 movwf clock_adjust__adjust 555 0ec 20fe call clock_adjust 556 ; number := 0 557 ; 1 instructions found for sharing 558 0ed 28fc goto label187__0end 559 label187__0false: 560 ; else body start 561 ; Just echo back the current number : 562 ; call master_send {{ 0c'<' }} 563 0ee 303c movlw 60 564 0ef 00e2 movwf master_send__character 565 0f0 24a2 call master_send 566 ; call master_octal {{ char }} 567 0f1 0824 movf main__char,w 568 0f2 00d5 movwf master_octal__number 569 0f3 2429 call master_octal 570 ; call master_send {{ 0c'>' }} 571 0f4 303e movlw 62 572 0f5 00e2 movwf master_send__character 573 0f6 24a2 call master_send 574 ; Send a carriage - return line - feed : 575 ; call master_crlf {{ }} 576 0f7 2408 call master_crlf 577 ; Output the character in octal : 578 ; call master_octal {{ number }} 579 0f8 0826 movf main__number,w 580 0f9 00d5 movwf master_octal__number 581 0fa 2429 call master_octal 582 ; Send a carriage - return line - feed : 583 ; call master_crlf {{ }} 584 0fb 2408 call master_crlf 585 ; Reset number 586 ; number := 0 587 ; 1 instructions found for sharing 588 ; if exp=` char = 0c'c' ' generic 589 label187__0end: 590 ; Other expression=`{ char = 0c'c' }' delay=-1 591 ; 1 shared instructions follow 592 0fc 01a6 clrf main__number 593 ; if exp=` char = 0c't' ' generic 594 label182__0end: 595 ; Other expression=`{ char = 0c't' }' delay=-1 596 ; if exp=` char = 0c'i' ' generic 597 label159__0end: 598 ; Other expression=`{ char = 0c'i' }' delay=-1 599 ; if exp=` char = 0c'w' ' generic 600 label131__0end: 601 ; Other expression=`{ char = 0c'w' }' delay=-1 602 ; if exp=` char = 0c's' ' generic 603 label120__0end: 604 ; Other expression=`{ char = 0c's' }' delay=-1 605 ; if exp=`char < {{ 0c'9' + 1 }}' generic 606 label116__1end: 607 ; Other expression=`char < {{ 0c'9' + 1 }}' delay=-1 608 ; if exp=`0c'0' <= char' false goto 609 ; Other expression=`0c'0' <= char' delay=-1 610 and116__0end: 611 ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } end 612 0fd 2874 goto main__107loop__forever 613 ; loop_forever ... end 614 ; procedure main end 615 616 ; procedure clock_adjust start 617 clock_adjust: 618 0028 clock_adjust__variables__base equ global__variables__bank0+8 619 0028 clock_adjust__bytes__base equ clock_adjust__variables__base+0 620 0031 clock_adjust__bits__base equ clock_adjust__variables__base+9 621 0009 clock_adjust__total__bytes equ 9 622 0030 clock_adjust__228byte0 equ clock_adjust__bytes__base+8 623 0030 clock_adjust__270byte0 equ clock_adjust__bytes__base+8 624 0030 clock_adjust__280byte0 equ clock_adjust__bytes__base+8 625 0030 clock_adjust__284byte0 equ clock_adjust__bytes__base+8 626 0028 clock_adjust__adjust equ clock_adjust__bytes__base+0 627 ; This procedure will adjust the clock to the slave . 628 0029 clock_adjust__command equ clock_adjust__bytes__base+1 629 002a clock_adjust__count equ clock_adjust__bytes__base+2 630 002b clock_adjust__error equ clock_adjust__bytes__base+3 631 002c clock_adjust__error_minimum equ clock_adjust__bytes__base+4 632 002d clock_adjust__high equ clock_adjust__bytes__base+5 633 002e clock_adjust__low equ clock_adjust__bytes__base+6 634 002f clock_adjust__target equ clock_adjust__bytes__base+7 635 ; target := iterations_low - adjust 636 0fe 303b movlw 59 637 0ff 00b0 movwf clock_adjust__228byte0 638 100 0828 movf clock_adjust__adjust,w 639 101 0230 subwf clock_adjust__228byte0,w 640 102 00af movwf clock_adjust__target 641 ; count := 2 642 103 3002 movlw 2 643 104 00aa movwf clock_adjust__count 644 ; error := 0xff 645 105 30ff movlw 255 646 106 00ab movwf clock_adjust__error 647 ; error_minimum := 0xf0 648 107 30f0 movlw 240 649 108 00ac movwf clock_adjust__error_minimum 650 ; Print out the target : 651 ; call master_send {{ 0c'T' }} 652 109 3054 movlw 84 653 10a 00e2 movwf master_send__character 654 10b 24a2 call master_send 655 ; call master_octal {{ iterations_high }} 656 10c 3005 movlw 5 657 10d 00d5 movwf master_octal__number 658 10e 2429 call master_octal 659 ; call master_octal {{ target }} 660 10f 082f movf clock_adjust__target,w 661 110 00d5 movwf master_octal__number 662 111 2429 call master_octal 663 ; call master_crlf {{ }} 664 112 2408 call master_crlf 665 ; loop_forever ... start 666 clock_adjust__239loop__forever: 667 ; Print out the clock value : 668 ; call master_send {{ 0c'C' }} 669 113 3043 movlw 67 670 114 00e2 movwf master_send__character 671 115 24a2 call master_send 672 ; call slave_send {{ 0xfa }} 673 116 30fa movlw 250 674 117 00d8 movwf slave_send__data 675 118 2448 call slave_send 676 ; call master_octal {{ slave_get {{ }} }} 677 119 2442 call slave_get 678 11a 0857 movf slave_get__0return__byte,w 679 11b 00d5 movwf master_octal__number 680 11c 2429 call master_octal 681 ; Ask for a timing byte : 682 ; call slave_send {{ 0xfb }} 683 11d 30fb movlw 251 684 11e 00d8 movwf slave_send__data 685 11f 2448 call slave_send 686 ; low := 0 687 120 01ae clrf clock_adjust__low 688 ; high := 0 689 121 01ad clrf clock_adjust__high 690 ; `while rx_slave_pin ...' start 691 clock_adjust__250while__continue: 692 ; expression=`rx_slave_pin' exp_delay=0 true_delay=2 false_delay=2 true_size=1 false_size=1 693 122 1a86 btfsc rx_slave_pin__byte,rx_slave_pin__bit 694 ; Do nothing : 695 123 2922 goto clock_adjust__250while__continue 696 124 2925 goto clock_adjust__250while__break 697 ; if exp=`rx_slave_pin' true goto small true 698 clock_adjust__250while__break: 699 ; `while rx_slave_pin ...' end 700 ; `while ! rx_slave_pin ...' start 701 clock_adjust__253while__continue: 702 ; expression=`rx_slave_pin' exp_delay=0 true_delay=2 false_delay=5 true_size=1 false_size=4 703 125 1a86 btfsc rx_slave_pin__byte,rx_slave_pin__bit 704 126 292b goto clock_adjust__253while__break 705 ; low := low + 1 706 127 0aae incf clock_adjust__low,f 707 ; if { z } start 708 ; expression=`{ z }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 709 128 1903 btfsc z__byte,z__bit 710 ; if { z } body start 711 ; high := high + 1 712 129 0aad incf clock_adjust__high,f 713 ; if { z } body end 714 ; if exp=`z' false skip delay=2 715 ; Other expression=`{ z }' delay=2 716 ; if { z } end 717 12a 2925 goto clock_adjust__253while__continue 718 ; if exp=`rx_slave_pin' true goto 719 ; Other expression=`rx_slave_pin' delay=-1 720 clock_adjust__253while__break: 721 ; `while ! rx_slave_pin ...' end 722 ; Print out high and low : 723 ; call master_send {{ 0c'H' }} 724 12b 3048 movlw 72 725 12c 00e2 movwf master_send__character 726 12d 24a2 call master_send 727 ; call master_octal {{ high }} 728 12e 082d movf clock_adjust__high,w 729 12f 00d5 movwf master_octal__number 730 130 2429 call master_octal 731 ; call master_send {{ 0c'L' }} 732 131 304c movlw 76 733 132 00e2 movwf master_send__character 734 133 24a2 call master_send 735 ; call master_octal {{ low }} 736 134 082e movf clock_adjust__low,w 737 135 00d5 movwf master_octal__number 738 136 2429 call master_octal 739 ; Now think about adjusting clock . 740 ; if { high > iterations_high } start 741 137 3006 movlw 6 742 138 022d subwf clock_adjust__high,w 743 ; expression=`{ high > iterations_high }' exp_delay=2 true_delay=7 false_delay=-1 true_size=7 false_size=36 744 139 1803 btfsc c___byte,c___bit 745 13a 2960 goto label267__0true 746 label267__0false: 747 13b 3005 movlw 5 748 13c 022d subwf clock_adjust__high,w 749 ; expression=`{ high < iterations_high }' exp_delay=2 true_delay=4 false_delay=-1 true_size=4 false_size=27 750 13d 1c03 btfss c___byte,c___bit 751 13e 295b goto label271__0true 752 label271__0false: 753 ; else body start 754 ; The high 8 - bits are equal : 755 ; if { low > target } start 756 13f 082e movf clock_adjust__low,w 757 140 022f subwf clock_adjust__target,w 758 ; expression=`{ low > target }' exp_delay=2 true_delay=7 false_delay=-1 true_size=7 false_size=15 759 141 1c03 btfss c___byte,c___bit 760 142 2953 goto label277__0true 761 label277__0false: 762 143 082f movf clock_adjust__target,w 763 144 022e subwf clock_adjust__low,w 764 ; expression=`{ low < target }' exp_delay=2 true_delay=7 false_delay=3 true_size=7 false_size=3 765 145 1c03 btfss c___byte,c___bit 766 146 294b goto label281__0true 767 label281__0false: 768 ; else body start 769 ; Exact match ; we are done : 770 ; command := 0 771 147 01a9 clrf clock_adjust__command 772 ; error := 0 773 148 01ab clrf clock_adjust__error 774 ; error_minimum := 0 775 149 01ac clrf clock_adjust__error_minimum 776 ; else body end 777 14a 2952 goto label281__0end 778 label281__0true: 779 ; else_if { low < target } body start 780 ; Clock pulse is too short ; slave clock is too fast : 781 ; command := 0xf8 782 14b 30f8 movlw 248 783 14c 00a9 movwf clock_adjust__command 784 ; error := target - low 785 14d 082f movf clock_adjust__target,w 786 14e 00b0 movwf clock_adjust__284byte0 787 14f 082e movf clock_adjust__low,w 788 150 0230 subwf clock_adjust__284byte0,w 789 151 00ab movwf clock_adjust__error 790 ; else_if { low < target } body end 791 ; if exp=` low < target ' generic 792 label281__0end: 793 ; Other expression=`{ low < target }' delay=-1 794 152 295a goto label277__0end 795 label277__0true: 796 ; if { low > target } body start 797 ; Clock pulse is too long ; slave clock is too slow : 798 ; command := 0xf9 799 153 30f9 movlw 249 800 154 00a9 movwf clock_adjust__command 801 ; error := low - target 802 155 082e movf clock_adjust__low,w 803 156 00b0 movwf clock_adjust__280byte0 804 157 082f movf clock_adjust__target,w 805 158 0230 subwf clock_adjust__280byte0,w 806 159 00ab movwf clock_adjust__error 807 ; if { low > target } body end 808 ; if exp=` low > target ' generic 809 label277__0end: 810 ; Other expression=`{ low > target }' delay=-1 811 ; if { low > target } end 812 ; else body end 813 15a 295f goto label271__0end 814 label271__0true: 815 ; else_if { high < iterations_high } body start 816 ; Clock pulse is too short ; slave clock is too fast : 817 ; command := 0xf8 818 15b 30f8 movlw 248 819 15c 00a9 movwf clock_adjust__command 820 ; error := target 821 15d 082f movf clock_adjust__target,w 822 15e 00ab movwf clock_adjust__error 823 ; else_if { high < iterations_high } body end 824 ; if exp=` high < iterations_high ' generic 825 label271__0end: 826 ; Other expression=`{ high < iterations_high }' delay=-1 827 15f 2967 goto label267__0end 828 label267__0true: 829 ; if { high > iterations_high } body start 830 ; Clock pulse is too long ; slave clock is too slow : 831 ; command := 0xf9 832 160 30f9 movlw 249 833 161 00a9 movwf clock_adjust__command 834 ; error := 0xff - target 835 162 30ff movlw 255 836 163 00b0 movwf clock_adjust__270byte0 837 164 082f movf clock_adjust__target,w 838 165 0230 subwf clock_adjust__270byte0,w 839 166 00ab movwf clock_adjust__error 840 ; if { high > iterations_high } body end 841 ; if exp=` high > iterations_high ' generic 842 label267__0end: 843 ; Other expression=`{ high > iterations_high }' delay=-1 844 ; if { high > iterations_high } end 845 ; Print out the error and error minimum : 846 ; call master_send {{ 0c'E' }} 847 167 3045 movlw 69 848 168 00e2 movwf master_send__character 849 169 24a2 call master_send 850 ; call master_octal {{ error }} 851 16a 082b movf clock_adjust__error,w 852 16b 00d5 movwf master_octal__number 853 16c 2429 call master_octal 854 ; call master_send {{ 0c'M' }} 855 16d 304d movlw 77 856 16e 00e2 movwf master_send__character 857 16f 24a2 call master_send 858 ; call master_octal {{ error_minimum }} 859 170 082c movf clock_adjust__error_minimum,w 860 171 00d5 movwf master_octal__number 861 172 2429 call master_octal 862 ; if { error = error_minimum } start 863 173 082b movf clock_adjust__error,w 864 174 022c subwf clock_adjust__error_minimum,w 865 ; expression=`{ error = error_minimum }' exp_delay=2 true_delay=-1 false_delay=-1 true_size=2 false_size=14 866 175 1d03 btfss z___byte,z___bit 867 176 297a goto label299__0false 868 label299__0true: 869 ; if { error = error_minimum } body start 870 ; call master_crlf {{ }} 871 177 2408 call master_crlf 872 ; return 873 178 3400 retlw 0 874 ; if { error = error_minimum } body end 875 179 2988 goto label299__0end 876 label299__0false: 877 17a 082c movf clock_adjust__error_minimum,w 878 17b 022b subwf clock_adjust__error,w 879 ; expression=`{ error < error_minimum }' exp_delay=2 true_delay=3 false_delay=-1 true_size=3 false_size=6 880 17c 1c03 btfss c___byte,c___bit 881 17d 2985 goto label302__0true 882 label302__0false: 883 ; else body start 884 ; count := count - 1 885 17e 03aa decf clock_adjust__count,f 886 ; if { z } start 887 ; expression=`{ z }' exp_delay=0 true_delay=3 false_delay=0 true_size=3 false_size=0 888 17f 1d03 btfss z__byte,z__bit 889 180 2984 goto label307__0end 890 ; if { z } body start 891 ; error_minimum := error_minimum + 1 892 181 0aac incf clock_adjust__error_minimum,f 893 ; count := 2 894 182 3002 movlw 2 895 183 00aa movwf clock_adjust__count 896 ; if { z } body end 897 label307__0end: 898 ; if exp=`z' empty false 899 ; Other expression=`{ z }' delay=-1 900 ; if { z } end 901 ; else body end 902 184 2988 goto label302__0end 903 label302__0true: 904 ; else_if { error < error_minimum } body start 905 ; error_minimum := error 906 185 082b movf clock_adjust__error,w 907 186 00ac movwf clock_adjust__error_minimum 908 ; error := error + 1 909 187 0aab incf clock_adjust__error,f 910 ; else_if { error < error_minimum } body end 911 ; if exp=` error < error_minimum ' generic 912 label302__0end: 913 ; Other expression=`{ error < error_minimum }' delay=-1 914 ; if exp=` error = error_minimum ' generic 915 label299__0end: 916 ; Other expression=`{ error = error_minimum }' delay=-1 917 ; if { error = error_minimum } end 918 ; Now adjust the clock : 919 ; call slave_send {{ command }} 920 188 0829 movf clock_adjust__command,w 921 189 00d8 movwf slave_send__data 922 18a 2448 call slave_send 923 ; call master_crlf {{ }} 924 18b 2408 call master_crlf 925 18c 2913 goto clock_adjust__239loop__forever 926 ; loop_forever ... end 927 ; procedure clock_adjust end 928 929 ; procedure test start 930 test: 931 0031 test__variables__base equ global__variables__bank0+17 932 0031 test__bytes__base equ test__variables__base+0 933 0031 test__bits__base equ test__variables__base+0 934 0000 test__total__bytes equ 0 935 ; arguments_none 936 ; This procedure will test the Shaft2 RoboBrick : 937 ; Verify that the common commands are working : 938 ; call common_test {{ }} 939 18d 22fa call common_test 940 ; Verify that we can interrupt : 941 ; call interrupt_test {{ }} 942 18e 2397 call interrupt_test 943 ; Let ' s go test some registers : 944 ; call master_string {{ register_string }} 945 18f 305f movlw LOW register_string+1 946 190 00e3 movwf master_string__message 947 191 24a8 call master_string 948 ; call master_string {{ test_string }} 949 192 3069 movlw LOW test_string+1 950 193 00e3 movwf master_string__message 951 194 24a8 call master_string 952 ; call master_crlf {{ }} 953 195 2408 call master_crlf 954 ; Enable / Complement : 955 ; call test_register {{ 0x10 , 3 , 0x30 }} 956 196 3010 movlw 16 957 197 00c3 movwf test_register__set_command 958 198 3003 movlw 3 959 199 00c4 movwf test_register__read_command 960 19a 3030 movlw 48 961 19b 00c5 movwf test_register__error 962 19c 22da call test_register 963 ; High / Low : 964 ; call test_register {{ 0x20 , 4 , 0x31 }} 965 19d 3020 movlw 32 966 19e 00c3 movwf test_register__set_command 967 19f 3004 movlw 4 968 1a0 00c4 movwf test_register__read_command 969 1a1 3031 movlw 49 970 1a2 00c5 movwf test_register__error 971 1a3 22da call test_register 972 ; Raising / Falling : 973 ; call test_register {{ 0x30 , 5 , 0x32 }} 974 1a4 3030 movlw 48 975 1a5 00c3 movwf test_register__set_command 976 1a6 3005 movlw 5 977 1a7 00c4 movwf test_register__read_command 978 1a8 3032 movlw 50 979 1a9 00c5 movwf test_register__error 980 1aa 22da call test_register 981 ; Now test that the BIROD ' s are actually working : 982 ; call test_inputs {{ 0 }} 983 1ab 01b1 clrf test_inputs__pattern 984 1ac 21e2 call test_inputs 985 ; call test_inputs {{ 1 }} 986 1ad 3001 movlw 1 987 1ae 00b1 movwf test_inputs__pattern 988 1af 21e2 call test_inputs 989 ; call test_inputs {{ 2 }} 990 1b0 3002 movlw 2 991 1b1 00b1 movwf test_inputs__pattern 992 1b2 21e2 call test_inputs 993 ; call test_inputs {{ 3 }} 994 1b3 3003 movlw 3 995 1b4 00b1 movwf test_inputs__pattern 996 1b5 21e2 call test_inputs 997 ; Test for interrupts : 998 ; call master_string {{ interrupt_string }} 999 1b6 3038 movlw LOW interrupt_string+1 1000 1b7 00e3 movwf master_string__message 1001 1b8 24a8 call master_string 1002 ; call master_string {{ test_string }} 1003 1b9 3069 movlw LOW test_string+1 1004 1ba 00e3 movwf master_string__message 1005 1bb 24a8 call master_string 1006 ; call master_crlf {{ }} 1007 1bc 2408 call master_crlf 1008 ; High interrupt : 1009 ; call test_interrupt {{ 0 , 1 , 0x20 , 4 }} 1010 1bd 01bf clrf test_interrupt__start_pattern 1011 1be 3001 movlw 1 1012 1bf 00c0 movwf test_interrupt__end_pattern 1013 1c0 3020 movlw 32 1014 1c1 00c1 movwf test_interrupt__set_command 1015 1c2 3004 movlw 4 1016 1c3 00c2 movwf test_interrupt__set_bits 1017 1c4 22bc call test_interrupt 1018 ; Low interrupt : 1019 ; call test_interrupt {{ 1 , 0 , 0x20 , 1 }} 1020 1c5 3001 movlw 1 1021 1c6 00bf movwf test_interrupt__start_pattern 1022 1c7 01c0 clrf test_interrupt__end_pattern 1023 1c8 3020 movlw 32 1024 1c9 00c1 movwf test_interrupt__set_command 1025 1ca 3001 movlw 1 1026 1cb 00c2 movwf test_interrupt__set_bits 1027 1cc 22bc call test_interrupt 1028 ; Raising interrupt : 1029 ; call test_interrupt {{ 0 , 1 , 0x30 , 4 }} 1030 1cd 01bf clrf test_interrupt__start_pattern 1031 1ce 3001 movlw 1 1032 1cf 00c0 movwf test_interrupt__end_pattern 1033 1d0 3030 movlw 48 1034 1d1 00c1 movwf test_interrupt__set_command 1035 1d2 3004 movlw 4 1036 1d3 00c2 movwf test_interrupt__set_bits 1037 1d4 22bc call test_interrupt 1038 ; Falling interrupt : 1039 ; call test_interrupt {{ 1 , 0 , 0x30 , 1 }} 1040 1d5 3001 movlw 1 1041 1d6 00bf movwf test_interrupt__start_pattern 1042 1d7 01c0 clrf test_interrupt__end_pattern 1043 1d8 3030 movlw 48 1044 1d9 00c1 movwf test_interrupt__set_command 1045 1da 3001 movlw 1 1046 1db 00c2 movwf test_interrupt__set_bits 1047 1dc 22bc call test_interrupt 1048 ; Announce we are done : 1049 ; call master_string {{ done_string }} 1050 1dd 3018 movlw LOW done_string+1 1051 1de 00e3 movwf master_string__message 1052 1df 24a8 call master_string 1053 ; call master_crlf {{ }} 1054 1e0 2408 call master_crlf 1055 ; procedure test end 1056 1e1 3400 retlw 0 1057 1058 ; procedure test_inputs start 1059 test_inputs: 1060 0031 test_inputs__variables__base equ global__variables__bank0+17 1061 0031 test_inputs__bytes__base equ test_inputs__variables__base+0 1062 003b test_inputs__bits__base equ test_inputs__variables__base+10 1063 000a test_inputs__total__bytes equ 10 1064 003a test_inputs__396byte0 equ test_inputs__bytes__base+9 1065 0031 test_inputs__pattern equ test_inputs__bytes__base+0 1066 ; This procedure will verify that the inputs can be set to pattern . 1067 0032 test_inputs__sleep1 equ test_inputs__bytes__base+1 1068 0033 test_inputs__sleep2 equ test_inputs__bytes__base+2 1069 0034 test_inputs__counter equ test_inputs__bytes__base+3 1070 0035 test_inputs__test equ test_inputs__bytes__base+4 1071 0036 test_inputs__command equ test_inputs__bytes__base+5 1072 0037 test_inputs__mask equ test_inputs__bytes__base+6 1073 0038 test_inputs__masked_pattern equ test_inputs__bytes__base+7 1074 0039 test_inputs__alternate equ test_inputs__bytes__base+8 1075 ; Enable the IROD ' s : 1076 ; call test_prompt {{ pattern }} 1077 1e2 0831 movf test_inputs__pattern,w 1078 1e3 00bb movwf test_prompt__pattern 1079 1e4 2285 call test_prompt 1080 ; `count_down counter 8 ...' start 1081 1e5 3008 movlw 8 1082 1e6 00b4 movwf test_inputs__counter 1083 test_inputs__392_loop: 1084 ; Set the enable bits : 1085 ; test := counter - 1 1086 1e7 0334 decf test_inputs__counter,w 1087 1e8 00b5 movwf test_inputs__test 1088 ; mask := test & 3 1089 1e9 3003 movlw 3 1090 1ea 0535 andwf test_inputs__test,w 1091 1eb 00b7 movwf test_inputs__mask 1092 ; command := 0x10 | {{ mask << 2 }} 1093 1ec 0d37 rlf test_inputs__mask,w 1094 1ed 00ba movwf test_inputs__396byte0 1095 1ee 0d3a rlf test_inputs__396byte0,w 1096 1ef 39fc andlw 252 1097 1f0 3810 iorlw 16 1098 1f1 00b6 movwf test_inputs__command 1099 ; call slave_send {{ command }} 1100 1f2 00d8 movwf slave_send__data 1101 1f3 2448 call slave_send 1102 ; masked_pattern := mask & pattern 1103 1f4 0837 movf test_inputs__mask,w 1104 1f5 0531 andwf test_inputs__pattern,w 1105 1f6 00b8 movwf test_inputs__masked_pattern 1106 ; Set the alternate bit : 1107 ; alternate := test >> 2 1108 1f7 0c35 rrf test_inputs__test,w 1109 1f8 00b9 movwf test_inputs__alternate 1110 1f9 0c39 rrf test_inputs__alternate,w 1111 1fa 393f andlw 63 1112 1fb 00b9 movwf test_inputs__alternate 1113 ; call slave_send {{ 6 | alternate }} 1114 1fc 3006 movlw 6 1115 1fd 0439 iorwf test_inputs__alternate,w 1116 1fe 00d8 movwf slave_send__data 1117 1ff 2448 call slave_send 1118 ; Announce test : 1119 ; call master_octal {{ test }} 1120 200 0835 movf test_inputs__test,w 1121 201 00d5 movwf master_octal__number 1122 202 2429 call master_octal 1123 ; call master_octal {{ masked_pattern }} 1124 203 0838 movf test_inputs__masked_pattern,w 1125 204 00d5 movwf master_octal__number 1126 205 2429 call master_octal 1127 ; call master_string {{ enable_string }} 1128 206 3043 movlw LOW enable_string+1 1129 207 00e3 movwf master_string__message 1130 208 24a8 call master_string 1131 ; call master_string {{ test_string }} 1132 209 3069 movlw LOW test_string+1 1133 20a 00e3 movwf master_string__message 1134 20b 24a8 call master_string 1135 ; call master_crlf {{ }} 1136 20c 2408 call master_crlf 1137 ; Let the enables take hold : 1138 ; `count_down sleep1 50 ...' start 1139 20d 3032 movlw 50 1140 20e 00b2 movwf test_inputs__sleep1 1141 test_inputs__412_loop: 1142 ; 30 * 1 / 3 bit delays = 10 bit delays : 1143 ; `count_down sleep2 30 ...' start 1144 20f 301e movlw 30 1145 210 00b3 movwf test_inputs__sleep2 1146 test_inputs__414_loop: 1147 ; call delay {{ }} 1148 211 24bb call delay 1149 212 0bb3 decfsz test_inputs__sleep2,f 1150 213 2a11 goto test_inputs__414_loop 1151 test_inputs__414_done: 1152 ; `count_down sleep2 30 ...' end 1153 214 0bb2 decfsz test_inputs__sleep1,f 1154 215 2a0f goto test_inputs__412_loop 1155 test_inputs__412_done: 1156 ; `count_down sleep1 50 ...' end 1157 ; Verify that the alternate bit is set : 1158 ; call slave_send {{ 3 }} 1159 216 3003 movlw 3 1160 217 00d8 movwf slave_send__data 1161 218 2448 call slave_send 1162 ; temp := slave_get {{ }} 1163 219 2442 call slave_get 1164 21a 0857 movf slave_get__0return__byte,w 1165 21b 00a0 movwf temp 1166 ; if { temp != command & 0xf } start 1167 21c 300f movlw 15 1168 21d 0536 andwf test_inputs__command,w 1169 21e 0220 subwf temp,w 1170 ; expression=`{ temp != command & 0xf }' exp_delay=3 true_delay=4 false_delay=0 true_size=8 false_size=0 1171 21f 1903 btfsc z___byte,z___bit 1172 220 2a29 goto label422__0end 1173 ; if { temp != command & 0xf } body start 1174 ; call master_octal {{ temp }} 1175 221 0820 movf temp,w 1176 222 00d5 movwf master_octal__number 1177 223 2429 call master_octal 1178 ; call master_fail {{ read_string , 0x40 }} 1179 224 3059 movlw LOW read_string+1 1180 225 00d1 movwf master_fail__test_name 1181 226 3040 movlw 64 1182 227 00d2 movwf master_fail__test_number 1183 228 240f call master_fail 1184 ; if { temp != command & 0xf } body end 1185 label422__0end: 1186 ; if exp=` temp != command & 0xf ' empty false 1187 ; Other expression=`{ temp != command & 0xf }' delay=-1 1188 ; if { temp != command & 0xf } end 1189 ; Verify that the alternate bit is set : 1190 ; call slave_send {{ 2 }} 1191 229 3002 movlw 2 1192 22a 00d8 movwf slave_send__data 1193 22b 2448 call slave_send 1194 ; temp := slave_get {{ }} 1195 22c 2442 call slave_get 1196 22d 0857 movf slave_get__0return__byte,w 1197 22e 00a0 movwf temp 1198 ; if { temp != alternate } start 1199 22f 0239 subwf test_inputs__alternate,w 1200 ; expression=`{ temp != alternate }' exp_delay=2 true_delay=3 false_delay=0 true_size=5 false_size=0 1201 230 1903 btfsc z___byte,z___bit 1202 231 2a37 goto label430__0end 1203 ; if { temp != alternate } body start 1204 ; call master_octal < temp > 1205 ; call master_fail {{ read_string , 0x41 }} 1206 232 3059 movlw LOW read_string+1 1207 233 00d1 movwf master_fail__test_name 1208 234 3041 movlw 65 1209 235 00d2 movwf master_fail__test_number 1210 236 240f call master_fail 1211 ; if { temp != alternate } body end 1212 label430__0end: 1213 ; if exp=` temp != alternate ' empty false 1214 ; Other expression=`{ temp != alternate }' delay=-1 1215 ; if { temp != alternate } end 1216 ; Regular read : 1217 ; call slave_send {{ 0 }} 1218 237 01d8 clrf slave_send__data 1219 238 2448 call slave_send 1220 ; temp := slave_get {{ }} 1221 239 2442 call slave_get 1222 23a 0857 movf slave_get__0return__byte,w 1223 23b 00a0 movwf temp 1224 ; if { temp != masked_pattern } start 1225 23c 0238 subwf test_inputs__masked_pattern,w 1226 ; expression=`{ temp != masked_pattern }' exp_delay=2 true_delay=4 false_delay=0 true_size=8 false_size=0 1227 23d 1903 btfsc z___byte,z___bit 1228 23e 2a47 goto label438__0end 1229 ; if { temp != masked_pattern } body start 1230 ; call master_octal {{ temp }} 1231 23f 0820 movf temp,w 1232 240 00d5 movwf master_octal__number 1233 241 2429 call master_octal 1234 ; call master_fail {{ read_string , 0x42 }} 1235 242 3059 movlw LOW read_string+1 1236 243 00d1 movwf master_fail__test_name 1237 244 3042 movlw 66 1238 245 00d2 movwf master_fail__test_number 1239 246 240f call master_fail 1240 ; if { temp != masked_pattern } body end 1241 label438__0end: 1242 ; if exp=` temp != masked_pattern ' empty false 1243 ; Other expression=`{ temp != masked_pattern }' delay=-1 1244 ; if { temp != masked_pattern } end 1245 ; Read raw : 1246 ; call slave_send {{ 1 }} 1247 247 3001 movlw 1 1248 248 00d8 movwf slave_send__data 1249 249 2448 call slave_send 1250 ; temp := slave_get {{ }} 1251 24a 2442 call slave_get 1252 24b 0857 movf slave_get__0return__byte,w 1253 24c 00a0 movwf temp 1254 ; if { temp != masked_pattern } start 1255 24d 0238 subwf test_inputs__masked_pattern,w 1256 ; expression=`{ temp != masked_pattern }' exp_delay=2 true_delay=4 false_delay=0 true_size=8 false_size=0 1257 24e 1903 btfsc z___byte,z___bit 1258 24f 2a58 goto label446__0end 1259 ; if { temp != masked_pattern } body start 1260 ; call master_octal {{ temp }} 1261 250 0820 movf temp,w 1262 251 00d5 movwf master_octal__number 1263 252 2429 call master_octal 1264 ; call master_fail {{ read_string , 0x43 }} 1265 253 3059 movlw LOW read_string+1 1266 254 00d1 movwf master_fail__test_name 1267 255 3043 movlw 67 1268 256 00d2 movwf master_fail__test_number 1269 257 240f call master_fail 1270 ; if { temp != masked_pattern } body end 1271 label446__0end: 1272 ; if exp=` temp != masked_pattern ' empty false 1273 ; Other expression=`{ temp != masked_pattern }' delay=-1 1274 ; if { temp != masked_pattern } end 1275 ; Now test complement : 1276 ; call slave_send {{ command | 3 }} 1277 258 3003 movlw 3 1278 259 0436 iorwf test_inputs__command,w 1279 25a 00d8 movwf slave_send__data 1280 25b 2448 call slave_send 1281 ; call slave_send {{ 0 }} 1282 25c 01d8 clrf slave_send__data 1283 25d 2448 call slave_send 1284 ; temp := slave_get {{ }} 1285 25e 2442 call slave_get 1286 25f 0857 movf slave_get__0return__byte,w 1287 260 00a0 movwf temp 1288 ; if { temp ^ 3 != masked_pattern } start 1289 261 3003 movlw 3 1290 262 0620 xorwf temp,w 1291 263 0238 subwf test_inputs__masked_pattern,w 1292 ; expression=`{ temp ^ 3 != masked_pattern }' exp_delay=3 true_delay=4 false_delay=0 true_size=8 false_size=0 1293 264 1903 btfsc z___byte,z___bit 1294 265 2a6e goto label455__0end 1295 ; if { temp ^ 3 != masked_pattern } body start 1296 ; call master_octal {{ temp }} 1297 266 0820 movf temp,w 1298 267 00d5 movwf master_octal__number 1299 268 2429 call master_octal 1300 ; call master_fail {{ read_string , 0x44 }} 1301 269 3059 movlw LOW read_string+1 1302 26a 00d1 movwf master_fail__test_name 1303 26b 3044 movlw 68 1304 26c 00d2 movwf master_fail__test_number 1305 26d 240f call master_fail 1306 ; if { temp ^ 3 != masked_pattern } body end 1307 label455__0end: 1308 ; if exp=` temp ^ 3 != masked_pattern ' empty false 1309 ; Other expression=`{ temp ^ 3 != masked_pattern }' delay=-1 1310 ; if { temp ^ 3 != masked_pattern } end 1311 ; Verify that raw did not change : 1312 ; call slave_send {{ 1 }} 1313 26e 3001 movlw 1 1314 26f 00d8 movwf slave_send__data 1315 270 2448 call slave_send 1316 ; temp := slave_get {{ }} 1317 271 2442 call slave_get 1318 272 0857 movf slave_get__0return__byte,w 1319 273 00a0 movwf temp 1320 ; if { temp != masked_pattern } start 1321 274 0238 subwf test_inputs__masked_pattern,w 1322 ; expression=`{ temp != masked_pattern }' exp_delay=2 true_delay=4 false_delay=0 true_size=8 false_size=0 1323 275 1903 btfsc z___byte,z___bit 1324 276 2a7f goto label463__0end 1325 ; if { temp != masked_pattern } body start 1326 ; call master_octal {{ temp }} 1327 277 0820 movf temp,w 1328 278 00d5 movwf master_octal__number 1329 279 2429 call master_octal 1330 ; call master_fail {{ read_string , 0x45 }} 1331 27a 3059 movlw LOW read_string+1 1332 27b 00d1 movwf master_fail__test_name 1333 27c 3045 movlw 69 1334 27d 00d2 movwf master_fail__test_number 1335 27e 240f call master_fail 1336 ; if { temp != masked_pattern } body end 1337 label463__0end: 1338 ; if exp=` temp != masked_pattern ' empty false 1339 ; Other expression=`{ temp != masked_pattern }' delay=-1 1340 ; if { temp != masked_pattern } end 1341 ; Reset complement bits : 1342 ; call slave_send {{ command }} 1343 27f 0836 movf test_inputs__command,w 1344 280 00d8 movwf slave_send__data 1345 281 2448 call slave_send 1346 282 0bb4 decfsz test_inputs__counter,f 1347 283 29e7 goto test_inputs__392_loop 1348 test_inputs__392_done: 1349 ; `count_down counter 8 ...' end 1350 ; procedure test_inputs end 1351 284 3400 retlw 0 1352 1353 ; procedure test_prompt start 1354 test_prompt: 1355 003b test_prompt__variables__base equ global__variables__bank0+27 1356 003b test_prompt__bytes__base equ test_prompt__variables__base+0 1357 003d test_prompt__bits__base equ test_prompt__variables__base+2 1358 0002 test_prompt__total__bytes equ 2 1359 003b test_prompt__pattern equ test_prompt__bytes__base+0 1360 ; This procedure will prompt the user for pattern . 1361 003c test_prompt__character equ test_prompt__bytes__base+1 1362 ; Enable both sensors : 1363 ; call slave_send {{ 0x1c }} 1364 285 301c movlw 28 1365 286 00d8 movwf slave_send__data 1366 287 2448 call slave_send 1367 ; Wait for the inputs to match : 1368 ; call master_crlf {{ }} 1369 288 2408 call master_crlf 1370 ; temp := pattern + 1 1371 289 0a3b incf test_prompt__pattern,w 1372 28a 00a0 movwf temp 1373 ; `while temp != pattern ...' start 1374 test_prompt__487while__continue: 1375 28b 0820 movf temp,w 1376 28c 023b subwf test_prompt__pattern,w 1377 ; expression=` temp != pattern ' exp_delay=2 true_delay=11 false_delay=2 true_size=28 false_size=1 1378 28d 1903 btfsc z___byte,z___bit 1379 28e 2aab goto test_prompt__487while__break 1380 ; Display the pattern : 1381 ; call master_send {{ cr }} 1382 28f 300d movlw 13 1383 290 00e2 movwf master_send__character 1384 291 24a2 call master_send 1385 ; call master_string {{ input_string }} 1386 292 3031 movlw LOW input_string+1 1387 293 00e3 movwf master_string__message 1388 294 24a8 call master_string 1389 ; call test_show {{ pattern }} 1390 295 083b movf test_prompt__pattern,w 1391 296 00bd movwf test_show__pattern 1392 297 22ad call test_show 1393 ; call master_send {{ 0c'<' }} 1394 298 303c movlw 60 1395 299 00e2 movwf master_send__character 1396 29a 24a2 call master_send 1397 ; call test_show {{ temp }} 1398 29b 0820 movf temp,w 1399 29c 00bd movwf test_show__pattern 1400 29d 22ad call test_show 1401 ; call master_send {{ 0c'>' }} 1402 29e 303e movlw 62 1403 29f 00e2 movwf master_send__character 1404 2a0 24a2 call master_send 1405 ; call master_send {{ 0c':' }} 1406 2a1 303a movlw 58 1407 2a2 00e2 movwf master_send__character 1408 2a3 24a2 call master_send 1409 ; Read the raw inputs : 1410 ; call slave_send {{ 1 }} 1411 2a4 3001 movlw 1 1412 2a5 00d8 movwf slave_send__data 1413 2a6 2448 call slave_send 1414 ; temp := slave_get {{ }} 1415 2a7 2442 call slave_get 1416 2a8 0857 movf slave_get__0return__byte,w 1417 2a9 00a0 movwf temp 1418 2aa 2a8b goto test_prompt__487while__continue 1419 ; if exp=` temp != pattern ' false goto 1420 ; Other expression=` temp != pattern ' delay=-1 1421 test_prompt__487while__break: 1422 ; `while temp != pattern ...' end 1423 ; Print a carraige - return line - feed : 1424 ; call master_crlf {{ }} 1425 2ab 2408 call master_crlf 1426 ; procedure test_prompt end 1427 2ac 3400 retlw 0 1428 1429 ; procedure test_show start 1430 test_show: 1431 003d test_show__variables__base equ global__variables__bank0+29 1432 003d test_show__bytes__base equ test_show__variables__base+0 1433 003f test_show__bits__base equ test_show__variables__base+2 1434 0002 test_show__total__bytes equ 2 1435 003d test_show__pattern equ test_show__bytes__base+0 1436 ; This procedure will print out pattern : 1437 003e test_show__character equ test_show__bytes__base+1 1438 ; if { pattern @ 1 } start 1439 ; Alias variable for select pattern @ 1 1440 003d test_show__pattern__514select0 equ test_show__pattern+0 1441 003d test_show__pattern__514select0__byte equ test_show__pattern+0 1442 0001 test_show__pattern__514select0__bit equ 1 1443 ; expression=`{ pattern @ 1 }' exp_delay=0 true_delay=1 false_delay=1 true_size=1 false_size=1 1444 2ad 18bd btfsc test_show__pattern__514select0__byte,test_show__pattern__514select0__bit 1445 ; if { pattern @ 1 } body start 1446 ; character := 0c'1' 1447 2ae 3031 movlw 49 1448 ; 1 instructions found for sharing 1449 2af 1cbd btfss test_show__pattern__514select0__byte,test_show__pattern__514select0__bit 1450 ; else body start 1451 ; character := 0c'0' 1452 2b0 3030 movlw 48 1453 ; 1 instructions found for sharing 1454 ; if exp=` pattern @ 1 ' single true and false skip delay=4 1455 ; Other expression=`{ pattern @ 1 }' delay=4 1456 ; 1 shared instructions follow 1457 2b1 00be movwf test_show__character 1458 ; if { pattern @ 1 } end 1459 ; call master_send {{ character }} 1460 2b2 00e2 movwf master_send__character 1461 2b3 24a2 call master_send 1462 ; if { pattern @ 0 } start 1463 ; Alias variable for select pattern @ 0 1464 003d test_show__pattern__520select0 equ test_show__pattern+0 1465 003d test_show__pattern__520select0__byte equ test_show__pattern+0 1466 0000 test_show__pattern__520select0__bit equ 0 1467 ; expression=`{ pattern @ 0 }' exp_delay=0 true_delay=1 false_delay=1 true_size=1 false_size=1 1468 2b4 183d btfsc test_show__pattern__520select0__byte,test_show__pattern__520select0__bit 1469 ; if { pattern @ 0 } body start 1470 ; character := 0c'1' 1471 2b5 3031 movlw 49 1472 ; 1 instructions found for sharing 1473 2b6 1c3d btfss test_show__pattern__520select0__byte,test_show__pattern__520select0__bit 1474 ; else body start 1475 ; character := 0c'0' 1476 2b7 3030 movlw 48 1477 ; 1 instructions found for sharing 1478 ; if exp=` pattern @ 0 ' single true and false skip delay=4 1479 ; Other expression=`{ pattern @ 0 }' delay=4 1480 ; 1 shared instructions follow 1481 2b8 00be movwf test_show__character 1482 ; if { pattern @ 0 } end 1483 ; call master_send {{ character }} 1484 2b9 00e2 movwf master_send__character 1485 2ba 24a2 call master_send 1486 ; procedure test_show end 1487 2bb 3400 retlw 0 1488 1489 ; procedure test_interrupt start 1490 test_interrupt: 1491 003f test_interrupt__variables__base equ global__variables__bank0+31 1492 003f test_interrupt__bytes__base equ test_interrupt__variables__base+0 1493 0043 test_interrupt__bits__base equ test_interrupt__variables__base+4 1494 0004 test_interrupt__total__bytes equ 4 1495 003f test_interrupt__start_pattern equ test_interrupt__bytes__base+0 1496 0040 test_interrupt__end_pattern equ test_interrupt__bytes__base+1 1497 0041 test_interrupt__set_command equ test_interrupt__bytes__base+2 1498 0042 test_interrupt__set_bits equ test_interrupt__bytes__base+3 1499 ; This procedure will validate that an interrupt occurs . 1500 ; call test_prompt {{ start_pattern }} 1501 2bc 083f movf test_interrupt__start_pattern,w 1502 2bd 00bb movwf test_prompt__pattern 1503 2be 2285 call test_prompt 1504 ; Enable only one : 1505 ; call slave_send {{ 0x14 }} 1506 2bf 3014 movlw 20 1507 2c0 00d8 movwf slave_send__data 1508 2c1 2448 call slave_send 1509 ; Enable the mask : 1510 ; call slave_send {{ set_command | set_bits }} 1511 2c2 0841 movf test_interrupt__set_command,w 1512 2c3 0442 iorwf test_interrupt__set_bits,w 1513 2c4 00d8 movwf slave_send__data 1514 2c5 2448 call slave_send 1515 ; Let the tester know what we want : 1516 ; call test_show {{ end_pattern }} 1517 2c6 0840 movf test_interrupt__end_pattern,w 1518 2c7 00bd movwf test_show__pattern 1519 2c8 22ad call test_show 1520 ; call master_send {{ 0c':' }} 1521 2c9 303a movlw 58 1522 2ca 00e2 movwf master_send__character 1523 2cb 24a2 call master_send 1524 ; Wait for an interrupt : 1525 ; call test_interrupt_wait {{ }} 1526 2cc 22d1 call test_interrupt_wait 1527 ; Disable mask : 1528 ; call slave_send {{ set_command }} 1529 2cd 0841 movf test_interrupt__set_command,w 1530 2ce 00d8 movwf slave_send__data 1531 2cf 2448 call slave_send 1532 ; procedure test_interrupt end 1533 2d0 3400 retlw 0 1534 1535 ; procedure test_interrupt_wait start 1536 test_interrupt_wait: 1537 0043 test_interrupt_wait__variables__base equ global__variables__bank0+35 1538 0043 test_interrupt_wait__bytes__base equ test_interrupt_wait__variables__base+0 1539 0043 test_interrupt_wait__bits__base equ test_interrupt_wait__variables__base+0 1540 0000 test_interrupt_wait__total__bytes equ 0 1541 ; arguments_none 1542 ; This procedure will test an interrupt : 1543 ; Now enable interrupts : 1544 ; call slave_send {{ 0xf2 }} 1545 2d1 30f2 movlw 242 1546 2d2 00d8 movwf slave_send__data 1547 2d3 2448 call slave_send 1548 ; Now wait for interrupt : 1549 ; `while rx_slave_pin ...' start 1550 test_interrupt_wait__566while__continue: 1551 ; expression=`rx_slave_pin' exp_delay=0 true_delay=1 false_delay=2 true_size=2 false_size=1 1552 2d4 1e86 btfss rx_slave_pin__byte,rx_slave_pin__bit 1553 2d5 2ad8 goto test_interrupt_wait__566while__break 1554 ; call delay {{ }} 1555 2d6 24bb call delay 1556 2d7 2ad4 goto test_interrupt_wait__566while__continue 1557 ; if exp=`rx_slave_pin' false goto 1558 ; Other expression=`rx_slave_pin' delay=-1 1559 test_interrupt_wait__566while__break: 1560 ; `while rx_slave_pin ...' end 1561 ; call master_crlf {{ }} 1562 2d8 2408 call master_crlf 1563 ; procedure test_interrupt_wait end 1564 2d9 3400 retlw 0 1565 1566 ; procedure test_register start 1567 test_register: 1568 0043 test_register__variables__base equ global__variables__bank0+35 1569 0043 test_register__bytes__base equ test_register__variables__base+0 1570 0047 test_register__bits__base equ test_register__variables__base+4 1571 0004 test_register__total__bytes equ 4 1572 0043 test_register__set_command equ test_register__bytes__base+0 1573 0044 test_register__read_command equ test_register__bytes__base+1 1574 0045 test_register__error equ test_register__bytes__base+2 1575 ; This procedure will test the ability to set and read back a byte register : 1576 0046 test_register__index equ test_register__bytes__base+3 1577 ; index := 16 1578 2da 3010 movlw 16 1579 2db 00c6 movwf test_register__index 1580 ; `while index != 0 ...' start 1581 test_register__583while__continue: 1582 2dc 0846 movf test_register__index,w 1583 ; expression=` index != 0 ' exp_delay=1 true_delay=1 false_delay=2 true_size=27 false_size=1 1584 2dd 1903 btfsc z___byte,z___bit 1585 2de 2af9 goto test_register__583while__break 1586 ; index := index - 1 1587 2df 03c6 decf test_register__index,f 1588 ; call slave_send {{ set_command | index }} 1589 2e0 0843 movf test_register__set_command,w 1590 2e1 0446 iorwf test_register__index,w 1591 2e2 00d8 movwf slave_send__data 1592 2e3 2448 call slave_send 1593 ; call slave_send {{ read_command }} 1594 2e4 0844 movf test_register__read_command,w 1595 2e5 00d8 movwf slave_send__data 1596 2e6 2448 call slave_send 1597 ; temp := slave_get {{ }} 1598 2e7 2442 call slave_get 1599 2e8 0857 movf slave_get__0return__byte,w 1600 2e9 00a0 movwf temp 1601 ; if { temp != index } start 1602 2ea 0246 subwf test_register__index,w 1603 ; expression=`{ temp != index }' exp_delay=2 true_delay=5 false_delay=0 true_size=11 false_size=0 1604 2eb 1903 btfsc z___byte,z___bit 1605 2ec 2af8 goto label589__0end 1606 ; if { temp != index } body start 1607 ; call master_octal {{ index }} 1608 2ed 0846 movf test_register__index,w 1609 2ee 00d5 movwf master_octal__number 1610 2ef 2429 call master_octal 1611 ; call master_octal {{ temp }} 1612 2f0 0820 movf temp,w 1613 2f1 00d5 movwf master_octal__number 1614 2f2 2429 call master_octal 1615 ; call master_fail {{ register_string , error }} 1616 2f3 305f movlw LOW register_string+1 1617 2f4 00d1 movwf master_fail__test_name 1618 2f5 0845 movf test_register__error,w 1619 2f6 00d2 movwf master_fail__test_number 1620 2f7 240f call master_fail 1621 ; if { temp != index } body end 1622 label589__0end: 1623 ; if exp=` temp != index ' empty false 1624 ; Other expression=`{ temp != index }' delay=-1 1625 ; if { temp != index } end 1626 2f8 2adc goto test_register__583while__continue 1627 ; if exp=` index != 0 ' false goto 1628 ; Other expression=` index != 0 ' delay=-1 1629 test_register__583while__break: 1630 ; `while index != 0 ...' end 1631 ; procedure test_register end 1632 2f9 3400 retlw 0 1633 ; comment {The procedures below are used to test the common shared commands :} 1634 1635 ; procedure common_test start 1636 common_test: 1637 0047 common_test__variables__base equ global__variables__bank0+39 1638 0047 common_test__bytes__base equ common_test__variables__base+0 1639 0049 common_test__bits__base equ common_test__variables__base+2 1640 0002 common_test__total__bytes equ 2 1641 0048 common_test__642byte0 equ common_test__bytes__base+1 1642 ; arguments_none 1643 ; This procedure will verify that the common shared commands work . 1644 0047 common_test__actual equ common_test__bytes__base+0 1645 ; Print the ID information : 1646 ; ID reset : 1647 ; call slave_send {{ 0xfd }} 1648 2fa 30fd movlw 253 1649 2fb 00d8 movwf slave_send__data 1650 2fc 2448 call slave_send 1651 ; Read the fixed bytes : 1652 ; call common_test_id_match {{ 1 , 0xc0 }} 1653 2fd 3001 movlw 1 1654 2fe 00c9 movwf common_test_id_match__desired 1655 2ff 30c0 movlw 192 1656 300 00ca movwf common_test_id_match__test_number 1657 301 2370 call common_test_id_match 1658 ; call common_test_id_match {{ 0 , 0xc1 }} 1659 302 01c9 clrf common_test_id_match__desired 1660 303 30c1 movlw 193 1661 304 00ca movwf common_test_id_match__test_number 1662 305 2370 call common_test_id_match 1663 ; call common_test_id_match {{ 11 , 0xc2 }} 1664 306 300b movlw 11 1665 307 00c9 movwf common_test_id_match__desired 1666 308 30c2 movlw 194 1667 309 00ca movwf common_test_id_match__test_number 1668 30a 2370 call common_test_id_match 1669 ; call common_test_id_match {{ 1 , 0xc3 }} 1670 30b 3001 movlw 1 1671 30c 00c9 movwf common_test_id_match__desired 1672 30d 30c3 movlw 195 1673 30e 00ca movwf common_test_id_match__test_number 1674 30f 2370 call common_test_id_match 1675 ; call common_test_id_match {{ 0 , 0xc4 }} 1676 310 01c9 clrf common_test_id_match__desired 1677 311 30c4 movlw 196 1678 312 00ca movwf common_test_id_match__test_number 1679 313 2370 call common_test_id_match 1680 ; call common_test_id_match {{ 0 , 0xc5 }} 1681 314 01c9 clrf common_test_id_match__desired 1682 315 30c5 movlw 197 1683 316 00ca movwf common_test_id_match__test_number 1684 317 2370 call common_test_id_match 1685 ; call common_test_id_match {{ 0 , 0xc6 }} 1686 318 01c9 clrf common_test_id_match__desired 1687 319 30c6 movlw 198 1688 31a 00ca movwf common_test_id_match__test_number 1689 31b 2370 call common_test_id_match 1690 ; call common_test_id_match {{ 0 , 0xc7 }} 1691 31c 01c9 clrf common_test_id_match__desired 1692 31d 30c7 movlw 199 1693 31e 00ca movwf common_test_id_match__test_number 1694 31f 2370 call common_test_id_match 1695 ; call master_crlf {{ }} 1696 320 2408 call master_crlf 1697 ; call common_test_id_bytes8 {{ }} 1698 321 237b call common_test_id_bytes8 1699 ; call common_test_id_bytes8 {{ }} 1700 322 237b call common_test_id_bytes8 1701 ; Read the brick name : 1702 ; call common_test_id_string {{ }} 1703 323 2385 call common_test_id_string 1704 ; Read the vendor name : 1705 ; call common_test_id_string {{ }} 1706 324 2385 call common_test_id_string 1707 ; Verfify that we don ' t read off the end of the id and crash : 1708 ; call common_test_id_next {{ }} 1709 325 2390 call common_test_id_next 1710 326 084d movf common_test_id_next__0return__byte,w 1711 ; Reset id : 1712 ; call slave_send {{ 0xfd }} 1713 327 30fd movlw 253 1714 328 00d8 movwf slave_send__data 1715 329 2448 call slave_send 1716 ; Verify that we are still alive : 1717 ; call common_test_id_match {{ 1 , 0xc8 }} 1718 32a 3001 movlw 1 1719 32b 00c9 movwf common_test_id_match__desired 1720 32c 30c8 movlw 200 1721 32d 00ca movwf common_test_id_match__test_number 1722 32e 2370 call common_test_id_match 1723 ; Read glitch : 1724 ; Clear glitch register : 1725 ; call slave_send {{ 0xfe }} 1726 32f 30fe movlw 254 1727 330 00d8 movwf slave_send__data 1728 331 2448 call slave_send 1729 ; actual := slave_get {{ }} 1730 332 2442 call slave_get 1731 333 0857 movf slave_get__0return__byte,w 1732 334 00c7 movwf common_test__actual 1733 ; Send a couple of glitches : 1734 ; call slave_send {{ 0xff }} 1735 335 30ff movlw 255 1736 336 00d8 movwf slave_send__data 1737 337 2448 call slave_send 1738 ; call slave_send {{ 0xff }} 1739 338 30ff movlw 255 1740 339 00d8 movwf slave_send__data 1741 33a 2448 call slave_send 1742 ; Read the glitch register : 1743 ; call slave_send {{ 0xfe }} 1744 33b 30fe movlw 254 1745 33c 00d8 movwf slave_send__data 1746 33d 2448 call slave_send 1747 ; if { slave_get {{ }} != 2 } start 1748 33e 2442 call slave_get 1749 33f 0857 movf slave_get__0return__byte,w 1750 340 00c8 movwf common_test__642byte0 1751 341 3002 movlw 2 1752 342 0248 subwf common_test__642byte0,w 1753 ; expression=`{ slave_get {{ }} != 2 }' exp_delay=3 true_delay=3 false_delay=0 true_size=5 false_size=0 1754 343 1903 btfsc z___byte,z___bit 1755 344 2b4a goto label642__1end 1756 ; if { slave_get {{ }} != 2 } body start 1757 ; call master_fail {{ common_string , 0xc9 }} 1758 345 3010 movlw LOW common_string+1 1759 346 00d1 movwf master_fail__test_name 1760 347 30c9 movlw 201 1761 348 00d2 movwf master_fail__test_number 1762 349 240f call master_fail 1763 ; if { slave_get {{ }} != 2 } body end 1764 label642__1end: 1765 ; if exp=` slave_get ## {{ }} != 2 ' empty false 1766 ; Other expression=`{ slave_get {{ }} != 2 }' delay=-1 1767 ; if { slave_get {{ }} != 2 } end 1768 ; Do a clock pulse : 1769 ; call slave_send {{ 0xfb }} 1770 34a 30fb movlw 251 1771 34b 00d8 movwf slave_send__data 1772 34c 2448 call slave_send 1773 ; if { slave_get {{ }} != 0 } start 1774 34d 2442 call slave_get 1775 34e 0857 movf slave_get__0return__byte,w 1776 ; expression=`{ slave_get {{ }} != 0 }' exp_delay=0 true_delay=3 false_delay=0 true_size=5 false_size=0 1777 34f 1903 btfsc z___byte,z___bit 1778 350 2b56 goto label648__0end 1779 ; if { slave_get {{ }} != 0 } body start 1780 ; call master_fail {{ common_string , 0xca }} 1781 351 3010 movlw LOW common_string+1 1782 352 00d1 movwf master_fail__test_name 1783 353 30ca movlw 202 1784 354 00d2 movwf master_fail__test_number 1785 355 240f call master_fail 1786 ; if { slave_get {{ }} != 0 } body end 1787 label648__0end: 1788 ; if exp=` slave_get ## {{ }} != 0 ' empty false 1789 ; Other expression=`{ slave_get {{ }} != 0 }' delay=-1 1790 ; if { slave_get {{ }} != 0 } end 1791 ; Read clock : 1792 ; call slave_send {{ 0xfa }} 1793 356 30fa movlw 250 1794 357 00d8 movwf slave_send__data 1795 358 2448 call slave_send 1796 ; actual := slave_get {{ }} 1797 359 2442 call slave_get 1798 35a 0857 movf slave_get__0return__byte,w 1799 35b 00c7 movwf common_test__actual 1800 ; Increment : 1801 ; call slave_send {{ 0xf9 }} 1802 35c 30f9 movlw 249 1803 35d 00d8 movwf slave_send__data 1804 35e 2448 call slave_send 1805 ; Decrement : 1806 ; call slave_send {{ 0xf8 }} 1807 35f 30f8 movlw 248 1808 360 00d8 movwf slave_send__data 1809 361 2448 call slave_send 1810 ; Read clock again : 1811 ; call slave_send {{ 0xfa }} 1812 362 30fa movlw 250 1813 363 00d8 movwf slave_send__data 1814 364 2448 call slave_send 1815 ; if { actual != slave_get {{ }} } start 1816 365 2442 call slave_get 1817 366 0857 movf slave_get__0return__byte,w 1818 367 0247 subwf common_test__actual,w 1819 ; expression=`{ actual != slave_get {{ }} }' exp_delay=1 true_delay=3 false_delay=0 true_size=5 false_size=0 1820 368 1903 btfsc z___byte,z___bit 1821 369 2b6f goto label660__0end 1822 ; if { actual != slave_get {{ }} } body start 1823 ; call master_fail {{ common_string , 0xcb }} 1824 36a 3010 movlw LOW common_string+1 1825 36b 00d1 movwf master_fail__test_name 1826 36c 30cb movlw 203 1827 36d 00d2 movwf master_fail__test_number 1828 36e 240f call master_fail 1829 ; if { actual != slave_get {{ }} } body end 1830 label660__0end: 1831 ; if exp=` actual != slave_get ## {{ }} ' empty false 1832 ; Other expression=`{ actual != slave_get {{ }} }' delay=-1 1833 ; if { actual != slave_get {{ }} } end 1834 ; procedure common_test end 1835 36f 3400 retlw 0 1836 1837 ; procedure common_test_id_match start 1838 common_test_id_match: 1839 0049 common_test_id_match__variables__base equ global__variables__bank0+41 1840 0049 common_test_id_match__bytes__base equ common_test_id_match__variables__base+0 1841 004b common_test_id_match__bits__base equ common_test_id_match__variables__base+2 1842 0002 common_test_id_match__total__bytes equ 2 1843 0049 common_test_id_match__desired equ common_test_id_match__bytes__base+0 1844 004a common_test_id_match__test_number equ common_test_id_match__bytes__base+1 1845 ; This procedure will verify that the next byte in the id is < desired > . 1846 ; if { desired != common_test_id_next {{ }} } start 1847 370 2390 call common_test_id_next 1848 371 084d movf common_test_id_next__0return__byte,w 1849 372 0249 subwf common_test_id_match__desired,w 1850 ; expression=`{ desired != common_test_id_next {{ }} }' exp_delay=1 true_delay=3 false_delay=0 true_size=5 false_size=0 1851 373 1903 btfsc z___byte,z___bit 1852 374 2b7a goto label672__0end 1853 ; if { desired != common_test_id_next {{ }} } body start 1854 ; call master_fail {{ common_string , test_number }} 1855 375 3010 movlw LOW common_string+1 1856 376 00d1 movwf master_fail__test_name 1857 377 084a movf common_test_id_match__test_number,w 1858 378 00d2 movwf master_fail__test_number 1859 379 240f call master_fail 1860 ; if { desired != common_test_id_next {{ }} } body end 1861 label672__0end: 1862 ; if exp=` desired != common_test_id_next ## {{ }} ' empty false 1863 ; Other expression=`{ desired != common_test_id_next {{ }} }' delay=-1 1864 ; if { desired != common_test_id_next {{ }} } end 1865 ; procedure common_test_id_match end 1866 37a 3400 retlw 0 1867 1868 ; procedure common_test_id_bytes8 start 1869 common_test_id_bytes8: 1870 004b common_test_id_bytes8__variables__base equ global__variables__bank0+43 1871 004b common_test_id_bytes8__bytes__base equ common_test_id_bytes8__variables__base+0 1872 004c common_test_id_bytes8__bits__base equ common_test_id_bytes8__variables__base+1 1873 0001 common_test_id_bytes8__total__bytes equ 1 1874 ; arguments_none 1875 ; This procedure will print out the next 8 bytes of the id in octal . 1876 004b common_test_id_bytes8__count equ common_test_id_bytes8__bytes__base+0 1877 ; `count_down count 8 ...' start 1878 37b 3008 movlw 8 1879 37c 00cb movwf common_test_id_bytes8__count 1880 common_test_id_bytes8__685_loop: 1881 ; call master_octal {{ common_test_id_next {{ }} }} 1882 37d 2390 call common_test_id_next 1883 37e 084d movf common_test_id_next__0return__byte,w 1884 37f 00d5 movwf master_octal__number 1885 380 2429 call master_octal 1886 381 0bcb decfsz common_test_id_bytes8__count,f 1887 382 2b7d goto common_test_id_bytes8__685_loop 1888 common_test_id_bytes8__685_done: 1889 ; `count_down count 8 ...' end 1890 ; call master_crlf {{ }} 1891 383 2408 call master_crlf 1892 ; procedure common_test_id_bytes8 end 1893 384 3400 retlw 0 1894 1895 ; procedure common_test_id_string start 1896 common_test_id_string: 1897 004c common_test_id_string__variables__base equ global__variables__bank0+44 1898 004c common_test_id_string__bytes__base equ common_test_id_string__variables__base+0 1899 004d common_test_id_string__bits__base equ common_test_id_string__variables__base+1 1900 0001 common_test_id_string__total__bytes equ 1 1901 ; arguments_none 1902 ; This procedure will print out the next id string . 1903 004c common_test_id_string__count equ common_test_id_string__bytes__base+0 1904 ; `count_down count common_test_id_next ## {{ }} ...' start 1905 385 2390 call common_test_id_next 1906 386 084d movf common_test_id_next__0return__byte,w 1907 387 00cc movwf common_test_id_string__count 1908 common_test_id_string__699_loop: 1909 ; call master_send {{ common_test_id_next {{ }} }} 1910 388 2390 call common_test_id_next 1911 389 084d movf common_test_id_next__0return__byte,w 1912 38a 00e2 movwf master_send__character 1913 38b 24a2 call master_send 1914 38c 0bcc decfsz common_test_id_string__count,f 1915 38d 2b88 goto common_test_id_string__699_loop 1916 common_test_id_string__699_done: 1917 ; `count_down count common_test_id_next ## {{ }} ...' end 1918 ; call master_crlf {{ }} 1919 38e 2408 call master_crlf 1920 ; procedure common_test_id_string end 1921 38f 3400 retlw 0 1922 1923 ; procedure common_test_id_next start 1924 common_test_id_next: 1925 004d common_test_id_next__variables__base equ global__variables__bank0+45 1926 004d common_test_id_next__bytes__base equ common_test_id_next__variables__base+0 1927 004e common_test_id_next__bits__base equ common_test_id_next__variables__base+1 1928 0001 common_test_id_next__total__bytes equ 1 1929 ; arguments_none 1930 004d common_test_id_next__0return__byte equ common_test_id_next__bytes__base+0 1931 ; This procedure returns the next byte from the identification string . 1932 ; call slave_send {{ 0xfc }} 1933 390 30fc movlw 252 1934 391 00d8 movwf slave_send__data 1935 392 2448 call slave_send 1936 ; return slave_get {{ }} 1937 393 2442 call slave_get 1938 394 0857 movf slave_get__0return__byte,w 1939 395 00cd movwf common_test_id_next__0return__byte 1940 396 3400 retlw 0 1941 ; procedure common_test_id_next end 1942 ; comment {The procedures below are used to test the shared interrupt commands :} 1943 1944 ; procedure interrupt_test start 1945 interrupt_test: 1946 004e interrupt_test__variables__base equ global__variables__bank0+46 1947 004e interrupt_test__bytes__base equ interrupt_test__variables__base+0 1948 004f interrupt_test__bits__base equ interrupt_test__variables__base+1 1949 0001 interrupt_test__total__bytes equ 1 1950 ; arguments_none 1951 ; This procedure tests the common shared interrupt commands . 1952 004e interrupt_test__counter equ interrupt_test__bytes__base+0 1953 ; Clear interrupt bits : 1954 ; call slave_send {{ 0xf0 }} 1955 397 30f0 movlw 240 1956 398 00d8 movwf slave_send__data 1957 399 2448 call slave_send 1958 ; call interrupt_read {{ 0 , 0xd0 }} 1959 39a 01cf clrf interrupt_read__desired 1960 39b 30d0 movlw 208 1961 39c 00d0 movwf interrupt_read__test_number 1962 39d 23f6 call interrupt_read 1963 ; Set / clear interrupt pending bit only : 1964 ; call slave_send {{ 0xf5 }} 1965 39e 30f5 movlw 245 1966 39f 00d8 movwf slave_send__data 1967 3a0 2448 call slave_send 1968 ; call interrupt_read {{ 1 , 0xd1 }} 1969 3a1 3001 movlw 1 1970 3a2 00cf movwf interrupt_read__desired 1971 3a3 30d1 movlw 209 1972 3a4 00d0 movwf interrupt_read__test_number 1973 3a5 23f6 call interrupt_read 1974 ; call slave_send {{ 0xf4 }} 1975 3a6 30f4 movlw 244 1976 3a7 00d8 movwf slave_send__data 1977 3a8 2448 call slave_send 1978 ; call interrupt_read {{ 0 , 0xd2 }} 1979 3a9 01cf clrf interrupt_read__desired 1980 3aa 30d2 movlw 210 1981 3ab 00d0 movwf interrupt_read__test_number 1982 3ac 23f6 call interrupt_read 1983 ; call slave_send {{ 0xf1 }} 1984 3ad 30f1 movlw 241 1985 3ae 00d8 movwf slave_send__data 1986 3af 2448 call slave_send 1987 ; call interrupt_read {{ 1 , 0xd3 }} 1988 3b0 3001 movlw 1 1989 3b1 00cf movwf interrupt_read__desired 1990 3b2 30d3 movlw 211 1991 3b3 00d0 movwf interrupt_read__test_number 1992 3b4 23f6 call interrupt_read 1993 ; call slave_send {{ 0xf0 }} 1994 3b5 30f0 movlw 240 1995 3b6 00d8 movwf slave_send__data 1996 3b7 2448 call slave_send 1997 ; call interrupt_read {{ 0 , 0xd4 }} 1998 3b8 01cf clrf interrupt_read__desired 1999 3b9 30d4 movlw 212 2000 3ba 00d0 movwf interrupt_read__test_number 2001 3bb 23f6 call interrupt_read 2002 ; Set / clear interrupt enable bit only : 2003 ; call slave_send {{ 0xf7 }} 2004 3bc 30f7 movlw 247 2005 3bd 00d8 movwf slave_send__data 2006 3be 2448 call slave_send 2007 ; call interrupt_read {{ 2 , 0xd5 }} 2008 3bf 3002 movlw 2 2009 3c0 00cf movwf interrupt_read__desired 2010 3c1 30d5 movlw 213 2011 3c2 00d0 movwf interrupt_read__test_number 2012 3c3 23f6 call interrupt_read 2013 ; call slave_send {{ 0xf6 }} 2014 3c4 30f6 movlw 246 2015 3c5 00d8 movwf slave_send__data 2016 3c6 2448 call slave_send 2017 ; call interrupt_read {{ 0 , 0xd6 }} 2018 3c7 01cf clrf interrupt_read__desired 2019 3c8 30d6 movlw 214 2020 3c9 00d0 movwf interrupt_read__test_number 2021 3ca 23f6 call interrupt_read 2022 ; call slave_send {{ 0xf2 }} 2023 3cb 30f2 movlw 242 2024 3cc 00d8 movwf slave_send__data 2025 3cd 2448 call slave_send 2026 ; call interrupt_read {{ 2 , 0xd7 }} 2027 3ce 3002 movlw 2 2028 3cf 00cf movwf interrupt_read__desired 2029 3d0 30d7 movlw 215 2030 3d1 00d0 movwf interrupt_read__test_number 2031 3d2 23f6 call interrupt_read 2032 ; call slave_send {{ 0xf0 }} 2033 3d3 30f0 movlw 240 2034 3d4 00d8 movwf slave_send__data 2035 3d5 2448 call slave_send 2036 ; call interrupt_read {{ 0 , 0xd8 }} 2037 3d6 01cf clrf interrupt_read__desired 2038 3d7 30d8 movlw 216 2039 3d8 00d0 movwf interrupt_read__test_number 2040 3d9 23f6 call interrupt_read 2041 ; Now set both the interrupt enable and pending bit . 2042 ; This must trigger an interrupt . 2043 ; call slave_send {{ 0xf3 }} 2044 3da 30f3 movlw 243 2045 3db 00d8 movwf slave_send__data 2046 3dc 2448 call slave_send 2047 ; `count_down counter 3 ...' start 2048 3dd 3003 movlw 3 2049 3de 00ce movwf interrupt_test__counter 2050 interrupt_test__753_loop: 2051 ; call delay {{ }} 2052 3df 24bb call delay 2053 3e0 0bce decfsz interrupt_test__counter,f 2054 3e1 2bdf goto interrupt_test__753_loop 2055 interrupt_test__753_done: 2056 ; `count_down counter 3 ...' end 2057 ; if { rx_slave_pin } start 2058 ; expression=`{ rx_slave_pin }' exp_delay=0 true_delay=3 false_delay=0 true_size=5 false_size=0 2059 3e2 1e86 btfss rx_slave_pin__byte,rx_slave_pin__bit 2060 3e3 2be9 goto label756__0end 2061 ; if { rx_slave_pin } body start 2062 ; No interrupt detected : 2063 ; call master_fail {{ interrupt_string , 0xd9 }} 2064 3e4 3038 movlw LOW interrupt_string+1 2065 3e5 00d1 movwf master_fail__test_name 2066 3e6 30d9 movlw 217 2067 3e7 00d2 movwf master_fail__test_number 2068 3e8 240f call master_fail 2069 ; if { rx_slave_pin } body end 2070 label756__0end: 2071 ; if exp=`rx_slave_pin' empty false 2072 ; Other expression=`{ rx_slave_pin }' delay=-1 2073 ; if { rx_slave_pin } end 2074 ; Read the interrupt enable bit is cleared as a side effect 2075 ; of reading the bit . 2076 ; call interrupt_read {{ 1 , 0xda }} 2077 3e9 3001 movlw 1 2078 3ea 00cf movwf interrupt_read__desired 2079 3eb 30da movlw 218 2080 3ec 00d0 movwf interrupt_read__test_number 2081 3ed 23f6 call interrupt_read 2082 ; Clear the interrupt pending bit : 2083 ; call slave_send {{ 0xf0 }} 2084 3ee 30f0 movlw 240 2085 3ef 00d8 movwf slave_send__data 2086 3f0 2448 call slave_send 2087 ; call interrupt_read {{ 0 , 0xdb }} 2088 3f1 01cf clrf interrupt_read__desired 2089 3f2 30db movlw 219 2090 3f3 00d0 movwf interrupt_read__test_number 2091 3f4 23f6 call interrupt_read 2092 ; procedure interrupt_test end 2093 3f5 3400 retlw 0 2094 2095 ; procedure interrupt_read start 2096 interrupt_read: 2097 004f interrupt_read__variables__base equ global__variables__bank0+47 2098 004f interrupt_read__bytes__base equ interrupt_read__variables__base+0 2099 0051 interrupt_read__bits__base equ interrupt_read__variables__base+2 2100 0002 interrupt_read__total__bytes equ 2 2101 004f interrupt_read__desired equ interrupt_read__bytes__base+0 2102 0050 interrupt_read__test_number equ interrupt_read__bytes__base+1 2103 ; This procedure will verify that the interrupt bits match < desired > . 2104 ; call slave_send {{ 0xef }} 2105 3f6 30ef movlw 239 2106 3f7 00d8 movwf slave_send__data 2107 3f8 2448 call slave_send 2108 ; temp := slave_get {{ }} 2109 3f9 2442 call slave_get 2110 3fa 0857 movf slave_get__0return__byte,w 2111 3fb 00a0 movwf temp 2112 ; if { temp != desired } start 2113 3fc 024f subwf interrupt_read__desired,w 2114 ; expression=`{ temp != desired }' exp_delay=2 true_delay=4 false_delay=0 true_size=8 false_size=0 2115 3fd 1903 btfsc z___byte,z___bit 2116 3fe 2c07 goto label778__0end 2117 ; if { temp != desired } body start 2118 ; call master_octal {{ temp }} 2119 3ff 0820 movf temp,w 2120 400 00d5 movwf master_octal__number 2121 401 2429 call master_octal 2122 ; call master_fail {{ interrupt_string , test_number }} 2123 402 3038 movlw LOW interrupt_string+1 2124 403 00d1 movwf master_fail__test_name 2125 404 0850 movf interrupt_read__test_number,w 2126 405 00d2 movwf master_fail__test_number 2127 406 240f call master_fail 2128 ; if { temp != desired } body end 2129 label778__0end: 2130 ; if exp=` temp != desired ' empty false 2131 ; Other expression=`{ temp != desired }' delay=-1 2132 ; if { temp != desired } end 2133 ; procedure interrupt_read end 2134 407 3400 retlw 0 2135 ; comment {The following procedures are used to communicate with the master :} 2136 2137 ; procedure master_crlf start 2138 master_crlf: 2139 0051 master_crlf__variables__base equ global__variables__bank0+49 2140 0051 master_crlf__bytes__base equ master_crlf__variables__base+0 2141 0051 master_crlf__bits__base equ master_crlf__variables__base+0 2142 0000 master_crlf__total__bytes equ 0 2143 ; arguments_none 2144 ; This procedure will output a carriage - return line - feed 2145 ; to the master . 2146 ; call master_send {{ cr }} 2147 408 300d movlw 13 2148 409 00e2 movwf master_send__character 2149 40a 24a2 call master_send 2150 ; call master_send {{ lf }} 2151 40b 300a movlw 10 2152 40c 00e2 movwf master_send__character 2153 40d 24a2 call master_send 2154 ; procedure master_crlf end 2155 40e 3400 retlw 0 2156 2157 ; procedure master_fail start 2158 master_fail: 2159 0051 master_fail__variables__base equ global__variables__bank0+49 2160 0051 master_fail__bytes__base equ master_fail__variables__base+0 2161 0053 master_fail__bits__base equ master_fail__variables__base+2 2162 0002 master_fail__total__bytes equ 2 2163 0051 master_fail__test_name equ master_fail__bytes__base+0 2164 0052 master_fail__test_number equ master_fail__bytes__base+1 2165 ; This procedure will output ` fail ' followed by a carriage return 2166 ; and line feed . 2167 ; call master_string {{ fail_string }} 2168 40f 301e movlw LOW fail_string+1 2169 410 00e3 movwf master_string__message 2170 411 24a8 call master_string 2171 ; call master_string {{ test_name }} 2172 412 0851 movf master_fail__test_name,w 2173 413 00e3 movwf master_string__message 2174 414 24a8 call master_string 2175 ; call master_octal {{ test_number }} 2176 415 0852 movf master_fail__test_number,w 2177 416 00d5 movwf master_octal__number 2178 417 2429 call master_octal 2179 ; call master_crlf {{ }} 2180 418 2408 call master_crlf 2181 ; procedure master_fail end 2182 419 3400 retlw 0 2183 2184 ; procedure master_get start 2185 master_get: 2186 0053 master_get__variables__base equ global__variables__bank0+51 2187 0053 master_get__bytes__base equ master_get__variables__base+0 2188 0055 master_get__bits__base equ master_get__variables__base+2 2189 0002 master_get__total__bytes equ 2 2190 ; arguments_none 2191 0053 master_get__0return__byte equ master_get__bytes__base+0 2192 ; This procedure will get the next character from the master . 2193 0054 master_get__character equ master_get__bytes__base+1 2194 ; character := 0xfc 2195 41a 30fc movlw 252 2196 41b 00d4 movwf master_get__character 2197 ; `while character = 0xfc ...' start 2198 master_get__820while__continue: 2199 41c 30fc movlw 252 2200 41d 0254 subwf master_get__character,w 2201 ; expression=` character = 0xfc ' exp_delay=2 true_delay=5 false_delay=2 true_size=6 false_size=1 2202 41e 1d03 btfss z___byte,z___bit 2203 41f 2c26 goto master_get__820while__break 2204 ; character := get_byte {{ rx_master_mask }} 2205 420 3002 movlw 2 2206 421 00d9 movwf get_byte__mask 2207 422 244e call get_byte 2208 423 085a movf get_byte__0return__byte,w 2209 424 00d4 movwf master_get__character 2210 425 2c1c goto master_get__820while__continue 2211 ; if exp=` character = 0xfc ' false goto 2212 ; Other expression=` character = 0xfc ' delay=-1 2213 master_get__820while__break: 2214 ; `while character = 0xfc ...' end 2215 ; return character 2216 426 0854 movf master_get__character,w 2217 427 00d3 movwf master_get__0return__byte 2218 428 3400 retlw 0 2219 ; procedure master_get end 2220 2221 ; procedure master_octal start 2222 master_octal: 2223 0055 master_octal__variables__base equ global__variables__bank0+53 2224 0055 master_octal__bytes__base equ master_octal__variables__base+0 2225 0057 master_octal__bits__base equ master_octal__variables__base+2 2226 0002 master_octal__total__bytes equ 2 2227 0056 master_octal__833byte0 equ master_octal__bytes__base+1 2228 0056 master_octal__834byte0 equ master_octal__bytes__base+1 2229 0055 master_octal__number equ master_octal__bytes__base+0 2230 ; This procedure will output < number > in octal to the tx port . 2231 ; Output the character in octal : 2232 ; call master_send {{ {{ number >> 6 }} + 0c'0' }} 2233 429 0e55 swapf master_octal__number,w 2234 42a 00d6 movwf master_octal__833byte0 2235 42b 0cd6 rrf master_octal__833byte0,f 2236 42c 0c56 rrf master_octal__833byte0,w 2237 42d 3903 andlw 3 2238 42e 3e30 addlw 48 2239 42f 00e2 movwf master_send__character 2240 430 24a2 call master_send 2241 ; call master_send {{ {{ {{ number >> 3 }} & 7 }} + 0c'0' }} 2242 431 0c55 rrf master_octal__number,w 2243 432 00d6 movwf master_octal__834byte0 2244 433 0cd6 rrf master_octal__834byte0,f 2245 434 0c56 rrf master_octal__834byte0,w 2246 435 3907 andlw 7 2247 436 3e30 addlw 48 2248 437 00e2 movwf master_send__character 2249 438 24a2 call master_send 2250 ; call master_send {{ {{ number & 7 }} + 0c'0' }} 2251 439 3007 movlw 7 2252 43a 0555 andwf master_octal__number,w 2253 43b 3e30 addlw 48 2254 43c 00e2 movwf master_send__character 2255 43d 24a2 call master_send 2256 ; call master_send {{ sp }} 2257 43e 3020 movlw 32 2258 43f 00e2 movwf master_send__character 2259 440 24a2 call master_send 2260 ; procedure master_octal end 2261 441 3400 retlw 0 2262 2263 ; procedure slave_get start 2264 slave_get: 2265 0057 slave_get__variables__base equ global__variables__bank0+55 2266 0057 slave_get__bytes__base equ slave_get__variables__base+0 2267 0058 slave_get__bits__base equ slave_get__variables__base+1 2268 0001 slave_get__total__bytes equ 1 2269 ; arguments_none 2270 0057 slave_get__0return__byte equ slave_get__bytes__base+0 2271 ; This procedure will get a byte from the slave or return 0xfc 2272 ; if no byte is forthcoming . 2273 ; return get_byte {{ rx_slave_mask }} 2274 442 3020 movlw 32 2275 443 00d9 movwf get_byte__mask 2276 444 244e call get_byte 2277 445 085a movf get_byte__0return__byte,w 2278 446 00d7 movwf slave_get__0return__byte 2279 447 3400 retlw 0 2280 ; procedure slave_get end 2281 2282 ; procedure slave_send start 2283 slave_send: 2284 0058 slave_send__variables__base equ global__variables__bank0+56 2285 0058 slave_send__bytes__base equ slave_send__variables__base+0 2286 0059 slave_send__bits__base equ slave_send__variables__base+1 2287 0001 slave_send__total__bytes equ 1 2288 0058 slave_send__data equ slave_send__bytes__base+0 2289 ; This procedure will send one byte of < data > to the slave . 2290 ; call send_byte {{ data , tx_slave_mask }} 2291 448 0858 movf slave_send__data,w 2292 449 00de movwf send_byte__char 2293 44a 3010 movlw 16 2294 44b 00df movwf send_byte__mask 2295 44c 247c call send_byte 2296 ; procedure slave_send end 2297 44d 3400 retlw 0 2298 ; comment {The last procedures do character sending and receiving :} 2299 2300 ; procedure get_byte start 2301 get_byte: 2302 0059 get_byte__variables__base equ global__variables__bank0+57 2303 0059 get_byte__bytes__base equ get_byte__variables__base+0 2304 005e get_byte__bits__base equ get_byte__variables__base+5 2305 0005 get_byte__total__bytes equ 5 2306 005d get_byte__890byte1 equ get_byte__bytes__base+4 2307 0059 get_byte__mask equ get_byte__bytes__base+0 2308 005a get_byte__0return__byte equ get_byte__bytes__base+1 2309 ; Get an 8 - bit byte from < mask > bit of < portb > and return it . 2310 ; If no character shows up in a while 0xfc is returned . 2311 005b get_byte__count equ get_byte__bytes__base+2 2312 005c get_byte__char equ get_byte__bytes__base+3 2313 ; Wait until a start bit arrives : 2314 ; count := 0 2315 44e 01db clrf get_byte__count 2316 ; `while portb & mask != 0 ...' start 2317 get_byte__872while__continue: 2318 44f 0806 movf portb,w 2319 450 0559 andwf get_byte__mask,w 2320 ; expression=` portb & mask != 0 ' exp_delay=2 true_delay=1 false_delay=2 true_size=9 false_size=1 2321 451 1903 btfsc z___byte,z___bit 2322 452 2c5c goto get_byte__872while__break 2323 ; count := count - 1 2324 453 03db decf get_byte__count,f 2325 ; if { count = 0 } start 2326 454 085b movf get_byte__count,w 2327 ; expression=`{ count = 0 }' exp_delay=1 true_delay=3 false_delay=0 true_size=3 false_size=0 2328 455 1d03 btfss z___byte,z___bit 2329 456 2c5a goto label874__0end 2330 ; if { count = 0 } body start 2331 ; return 0xfc 2332 457 30fc movlw 252 2333 458 00da movwf get_byte__0return__byte 2334 459 3400 retlw 0 2335 ; if { count = 0 } body end 2336 label874__0end: 2337 ; if exp=` count = 0 ' empty false 2338 ; Other expression=`{ count = 0 }' delay=-1 2339 ; if { count = 0 } end 2340 ; call delay {{ }} 2341 45a 24bb call delay 2342 45b 2c4f goto get_byte__872while__continue 2343 ; if exp=` portb & mask != 0 ' false goto 2344 ; Other expression=` portb & mask != 0 ' delay=-1 2345 get_byte__872while__break: 2346 ; `while portb & mask != 0 ...' end 2347 ; Skip over the start bit : 2348 ; call delay {{ }} 2349 45c 24bb call delay 2350 ; call delay {{ }} 2351 45d 24bb call delay 2352 ; call delay {{ }} 2353 45e 24bb call delay 2354 ; Sample in the middle third of each data bit : 2355 ; 1 cycle : 2356 ; char := 0 2357 45f 01dc clrf get_byte__char 2358 ; 2 cylces for loop setup : 2359 ; 1 + 2 = 3 2360 ; nop extra_instructions_per_bit - 3 2361 ; Delay 9 cycles 2362 460 3002 movlw 2 2363 461 00dd movwf get_byte__890byte1 2364 get_byte__890delay0: 2365 462 0bdd decfsz get_byte__890byte1,f 2366 463 2c62 goto get_byte__890delay0 2367 464 0000 nop 2368 465 0000 nop 2369 ; `count_down count 8 ...' start 2370 466 3008 movlw 8 2371 467 00db movwf get_byte__count 2372 get_byte__891_loop: 2373 ; call delay {{ }} 2374 468 24bb call delay 2375 ; 2 cycles : 2376 ; char := char >> 1 2377 469 1003 bcf c___byte,c___bit 2378 46a 0cdc rrf get_byte__char,f 2379 ; 3 cycles : 2380 ; if { portb & mask != 0 } start 2381 46b 0806 movf portb,w 2382 46c 0559 andwf get_byte__mask,w 2383 ; expression=`{ portb & mask != 0 }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 2384 46d 1d03 btfss z___byte,z___bit 2385 ; if { portb & mask != 0 } body start 2386 ; char @ 7 := 1 2387 ; Select char @ 7 2388 005c get_byte__char__897select0 equ get_byte__char+0 2389 005c get_byte__char__897select0__byte equ get_byte__char+0 2390 0007 get_byte__char__897select0__bit equ 7 2391 46e 17dc bsf get_byte__char__897select0__byte,get_byte__char__897select0__bit 2392 ; if { portb & mask != 0 } body end 2393 ; if exp=` portb & mask != 0 ' false skip delay=4 2394 ; Other expression=`{ portb & mask != 0 }' delay=4 2395 ; if { portb & mask != 0 } end 2396 ; call delay {{ }} 2397 46f 24bb call delay 2398 ; call delay {{ }} 2399 470 24bb call delay 2400 ; 3 cycles at end of loop : 2401 ; 2 + 3 + 3 = 8 2402 ; nop extra_instructions_per_bit - 8 2403 ; Delay 4 cycles 2404 471 0000 nop 2405 472 0000 nop 2406 473 0000 nop 2407 474 0000 nop 2408 475 0bdb decfsz get_byte__count,f 2409 476 2c68 goto get_byte__891_loop 2410 get_byte__891_done: 2411 ; `count_down count 8 ...' end 2412 ; Skip over 2 / 3 of the stop bit : 2413 ; call delay {{ }} 2414 477 24bb call delay 2415 ; call delay {{ }} 2416 478 24bb call delay 2417 ; return char 2418 479 085c movf get_byte__char,w 2419 47a 00da movwf get_byte__0return__byte 2420 47b 3400 retlw 0 2421 ; procedure get_byte end 2422 2423 ; procedure send_byte start 2424 send_byte: 2425 005e send_byte__variables__base equ global__variables__bank0+62 2426 005e send_byte__bytes__base equ send_byte__variables__base+0 2427 0062 send_byte__bits__base equ send_byte__variables__base+4 2428 0004 send_byte__total__bytes equ 4 2429 005e send_byte__char equ send_byte__bytes__base+0 2430 005f send_byte__mask equ send_byte__bytes__base+1 2431 ; Send < char > to < mask > bit of < portb > . 2432 0060 send_byte__count equ send_byte__bytes__base+2 2433 0061 send_byte__mark equ send_byte__bytes__base+3 2434 ; Send the start bit : 2435 ; 3 cycles : 2436 ; mark := mask ^ space 2437 47c 30ff movlw 255 2438 47d 065f xorwf send_byte__mask,w 2439 47e 00e1 movwf send_byte__mark 2440 ; 1 cycles < mark is already in W > : 2441 ; portb := mark 2442 47f 0086 movwf portb 2443 ; call delay {{ }} 2444 480 24bb call delay 2445 ; call delay {{ }} 2446 481 24bb call delay 2447 ; call delay {{ }} 2448 482 24bb call delay 2449 ; 2 cylces for loop setup : 2450 ; 3 + 1 + 2 = 6 2451 ; nop extra_instructions_per_bit - 6 2452 ; Delay 6 cycles 2453 483 0000 nop 2454 484 0000 nop 2455 485 0000 nop 2456 486 0000 nop 2457 487 0000 nop 2458 488 0000 nop 2459 ; Send the data : 2460 ; `count_down count 8 ...' start 2461 489 3008 movlw 8 2462 48a 00e0 movwf send_byte__count 2463 send_byte__936_loop: 2464 ; 5 cylces : 2465 ; if { char @ 0 } start 2466 ; Alias variable for select char @ 0 2467 005e send_byte__char__938select0 equ send_byte__char+0 2468 005e send_byte__char__938select0__byte equ send_byte__char+0 2469 0000 send_byte__char__938select0__bit equ 0 2470 ; expression=`{ char @ 0 }' exp_delay=0 true_delay=1 false_delay=1 true_size=1 false_size=1 2471 48b 185e btfsc send_byte__char__938select0__byte,send_byte__char__938select0__bit 2472 ; if { char @ 0 } body start 2473 ; portb := space 2474 48c 30ff movlw 255 2475 ; 1 instructions found for sharing 2476 48d 1c5e btfss send_byte__char__938select0__byte,send_byte__char__938select0__bit 2477 ; else body start 2478 ; portb := mark 2479 48e 0861 movf send_byte__mark,w 2480 ; 1 instructions found for sharing 2481 ; if exp=` char @ 0 ' single true and false skip delay=4 2482 ; Other expression=`{ char @ 0 }' delay=4 2483 ; 1 shared instructions follow 2484 48f 0086 movwf portb 2485 ; if { char @ 0 } end 2486 ; 2 cycles : 2487 ; char := char >> 1 2488 490 1003 bcf c___byte,c___bit 2489 491 0cde rrf send_byte__char,f 2490 ; call delay {{ }} 2491 492 24bb call delay 2492 ; call delay {{ }} 2493 493 24bb call delay 2494 ; call delay {{ }} 2495 494 24bb call delay 2496 ; 3 cycles at end of loop : 2497 ; 5 + 2 + 3 = 10 2498 ; nop extra_instructions_per_bit - 10 2499 ; Delay 2 cycles 2500 495 0000 nop 2501 496 0000 nop 2502 497 0be0 decfsz send_byte__count,f 2503 498 2c8b goto send_byte__936_loop 2504 send_byte__936_done: 2505 ; `count_down count 8 ...' end 2506 ; Send the stop bit : 2507 ; 1 cycle to finish off previous loop : 2508 ; nop 1 2509 ; Delay 1 cycles 2510 499 0000 nop 2511 ; 2 cycles : 2512 ; portb := space 2513 49a 30ff movlw 255 2514 49b 0086 movwf portb 2515 ; call delay {{ }} 2516 49c 24bb call delay 2517 ; call delay {{ }} 2518 49d 24bb call delay 2519 ; call delay {{ }} 2520 49e 24bb call delay 2521 ; 4 cycles for call / return : 2522 ; 4 cycles for to arguments : 2523 ; 2 + 4 + 4 = 10 2524 ; nop extra_instructions_per_bit - 10 2525 ; Delay 2 cycles 2526 49f 0000 nop 2527 4a0 0000 nop 2528 ; procedure send_byte end 2529 4a1 3400 retlw 0 2530 2531 ; procedure master_send start 2532 master_send: 2533 0062 master_send__variables__base equ global__variables__bank0+66 2534 0062 master_send__bytes__base equ master_send__variables__base+0 2535 0063 master_send__bits__base equ master_send__variables__base+1 2536 0001 master_send__total__bytes equ 1 2537 0062 master_send__character equ master_send__bytes__base+0 2538 ; This procedure will output < character > to the master . 2539 ; call send_byte {{ character , tx_master_mask }} 2540 4a2 0862 movf master_send__character,w 2541 4a3 00de movwf send_byte__char 2542 4a4 3004 movlw 4 2543 4a5 00df movwf send_byte__mask 2544 4a6 247c call send_byte 2545 ; procedure master_send end 2546 4a7 3400 retlw 0 2547 2548 ; procedure master_string start 2549 master_string: 2550 0063 master_string__variables__base equ global__variables__bank0+67 2551 0063 master_string__bytes__base equ master_string__variables__base+0 2552 0066 master_string__bits__base equ master_string__variables__base+3 2553 0003 master_string__total__bytes equ 3 2554 0063 master_string__message equ master_string__bytes__base+0 2555 ; This procedure will output < message > to the master . 2556 0064 master_string__size equ master_string__bytes__base+1 2557 0065 master_string__index equ master_string__bytes__base+2 2558 ; index := 0 2559 4a8 01e5 clrf master_string__index 2560 ; `while index < message . size ...' start 2561 master_string__986while__continue: 2562 4a9 018a clrf pclath___register 2563 4aa 0863 movf master_string__message,w 2564 4ab 200e call string___fetch 2565 4ac 0265 subwf master_string__index,w 2566 ; expression=` index < message . size ' exp_delay=4 true_delay=7 false_delay=2 true_size=8 false_size=1 2567 4ad 1803 btfsc c___byte,c___bit 2568 4ae 2cb7 goto master_string__986while__break 2569 ; call master_send {{ message ~~ {{ index }} }} 2570 4af 0a65 incf master_string__index,w 2571 4b0 0763 addwf master_string__message,w 2572 4b1 018a clrf pclath___register 2573 4b2 200e call string___fetch 2574 4b3 00e2 movwf master_send__character 2575 4b4 24a2 call master_send 2576 ; index := index + 1 2577 4b5 0ae5 incf master_string__index,f 2578 4b6 2ca9 goto master_string__986while__continue 2579 ; if exp=` index < message . size ' false goto 2580 ; Other expression=` index < message . size ' delay=-1 2581 master_string__986while__break: 2582 ; `while index < message . size ...' end 2583 ; call master_send {{ sp }} 2584 4b7 3020 movlw 32 2585 4b8 00e2 movwf master_send__character 2586 4b9 24a2 call master_send 2587 ; procedure master_string end 2588 4ba 3400 retlw 0 2589 2590 ; procedure delay start 2591 ; optimize 0 2592 delay: 2593 0066 delay__variables__base equ global__variables__bank0+70 2594 0066 delay__bytes__base equ delay__variables__base+0 2595 0067 delay__bits__base equ delay__variables__base+1 2596 0001 delay__total__bytes equ 1 2597 0066 delay__993byte1 equ delay__bytes__base+0 2598 ; arguments_none 2599 ; uniform_delay delay_instructions 2600 ; Uniform delay remaining = 339 Accumulated Delay = 0 2601 ; Uniform delay remaining = 339 Accumulated Delay = 0 2602 ; Delay 1 third of a bit : 2603 ; Uniform delay remaining = 339 Accumulated Delay = 0 2604 ; Uniform delay remaining = 339 Accumulated Delay = 0 2605 ; Kick the dog : 2606 ; Uniform delay remaining = 339 Accumulated Delay = 0 2607 ; watch_dog_reset 2608 4bb 0064 clrwdt 2609 ; Uniform delay remaining = 338 Accumulated Delay = 1 2610 ; Uniform delay remaining = 338 Accumulated Delay = 1 2611 ; Soak up remaining 338 cycles 2612 ; Delay 338 cycles 2613 4bc 3070 movlw 112 2614 4bd 00e6 movwf delay__993byte1 2615 delay__993delay0: 2616 4be 0be6 decfsz delay__993byte1,f 2617 4bf 2cbe goto delay__993delay0 2618 4c0 0000 nop 2619 ; procedure delay end 2620 4c1 3400 retlw 0 2621 ; optimize 1 2622 2623 ; Register bank 0 used 71 bytes of 96 available bytes 2624 ; Register bank 1 used 0 bytes of 80 available bytes 2625 ; Register bank 2 used 0 bytes of 48 available bytes 2626 ; Register bank 3 used 0 bytes of 0 available bytes 2627 2628 end