  1                     radix dec
  2     000c    global__variables__bank0 equ 12
  3     00ff    global__variables__bank1 equ 255
  4     0040    global__bit__variables__bank0 equ 64
  5     00ff    global__bit__variables__bank1 equ 255
  6     0000    indf___register equ 0
  7     0002    pcl___register equ 2
  8     0003    c___byte equ 3
  9     0000    c___bit equ 0
 10     0003    z___byte equ 3
 11     0002    z___bit equ 2
 12     0003    rp0___byte equ 3
 13     0005    rp0___bit equ 5
 14     0003    rp1___byte equ 3
 15     0006    rp1___bit equ 6
 16     0003    irp___byte equ 3
 17     0007    irp___bit equ 7
 18     0085    trisa___register equ 0x85
 19     0086    trisb___register equ 0x86
 20     0004    fsr___register equ 4
 21     000a    pclath___register equ 10
 22                     org 0
 23             start:
 24 000 0000            nop
 25 001 0000            nop
 26 002 0000            nop
 27 003 2805            goto skip___interrupt
 28             interrupt___vector:
 29 004 0009            retfie
 30             skip___interrupt:
 31                     ; Initialize TRIS registers
 32 005 30e9            movlw 233
 33                     ; Switch from register bank 0 to register bank 1 (which contains trisa___register)
 34 006 1683            bsf rp0___byte,rp0___bit
 35                     ; Register bank is now 1
 36 007 0085            movwf trisa___register
 37 008 018a            clrf pclath___register
 38                     ; Switch from register bank 1 to register bank 0
 39 009 1283            bcf rp0___byte,rp0___bit
 40                     ; Register bank is now 0
 41 00a 284e            goto main
 42                     ; comment #############################################################################
 43                     ; comment {}
 44                     ; comment {Copyright < c > 1999 - 2001 by Wayne C . Gramlich .}
 45                     ; comment {All rights reserved .}
 46                     ; comment {}
 47                     ; comment {Permission to use , copy , modify , distribute , and sell this software}
 48                     ; comment {for any purpose is hereby granted without fee provided that the above}
 49                     ; comment {copyright notice and this permission are retained . The author makes}
 50                     ; comment {no representations about the suitability of this software for any purpose .}
 51                     ; comment {It is provided { as is } without express or implied warranty .}
 52                     ; comment {}
 53                     ; comment {This is a test harness for testing the LED10 RoboBrick . See :}
 54                     ; comment {}
 55                     ; comment {http : / / web . gramlich . net / projects / robobricks / led10 / index . html}
 56                     ; comment {}
 57                     ; comment {for more details .}
 58                     ; comment {}
 59                     ; comment #############################################################################
 60                     ;   processor pic16f84 cp = off dp = off pwrte = disabled wdte = enabled fosc = xt  
 61                     ; 16381=0x3ffd 8199=0x2007
 62                     __config 16381
 63     2007    configuration___address equ 8199
 64                     ;   constant clock_rate 4000000  
 65     3d0900    clock_rate equ 4000000
 66                     ;   constant instruction_rate clock_rate / 4  
 67     f4240    instruction_rate equ 1000000
 68                     ;   constant baud_rate 2400  
 69     0960    baud_rate equ 2400
 70                     ;   constant instructions_per_bit instruction_rate / baud_rate  
 71     01a0    instructions_per_bit equ 416
 72                     ;   constant delays_per_bit 3  
 73     0003    delays_per_bit equ 3
 74                     ;   constant instructions_per_delay instructions_per_bit / delays_per_bit  
 75     008a    instructions_per_delay equ 138
 76                     ; comment {The null pulse that comes back from a clock pulse command is supposed to be}
 77                     ; comment {9 bits long . At 4 Mhz = 1 instruction per microsecond , 9 bits is 9 / 2400 =}
 78                     ; comment {3 . 75 ms . The count loop below is 7 instruction long . 3 . 75 / . 007 = 536 = 0x217 .}
 79                     ; comment {So we want our timer loop to get as close to 0x217 as possible .}
 80                     ;   constant clock_fudge 0  
 81     0000    clock_fudge equ 0
 82                     ;   constant clock_target 0x12 + clock_fudge  
 83     0012    clock_target equ 18
 84                     ;   constant sp 32  
 85     0020    sp equ 32
 86                     ;   constant cr 13  
 87     000d    cr equ 13
 88                     ;   constant lf 10  
 89     000a    lf equ 10
 90                     ; comment {Some bit definitions :}
 91                     ;   constant rx_slave_bit 0  
 92     0000    rx_slave_bit equ 0
 93                     ;   constant tx_slave_bit 1  
 94     0001    tx_slave_bit equ 1
 95                     ;   constant tx_master_bit 2  
 96     0002    tx_master_bit equ 2
 97                     ;   constant rx_master_bit 3  
 98     0003    rx_master_bit equ 3
 99                     ;   constant rx_slave_mask 1 << rx_slave_bit  
100     0001    rx_slave_mask equ 1
101                     ;   constant tx_slave_mask 1 << tx_slave_bit  
102     0002    tx_slave_mask equ 2
103                     ;   constant rx_master_mask 1 << rx_master_bit  
104     0008    rx_master_mask equ 8
105                     ;   constant tx_master_mask 1 << tx_master_bit  
106     0004    tx_master_mask equ 4
107     0003    status equ 3
108                     ;   bind c status @ 0  
109     0003    c equ status+0
110     0003    c__byte equ status+0
111     0000    c__bit equ 0
112                     ;   bind z status @ 2  
113     0003    z equ status+0
114     0003    z__byte equ status+0
115     0002    z__bit equ 2
116     0005    porta equ 5
117     0005    tx_master_pin__byte equ 5
118     0002    tx_master_pin__bit equ 2
119     0005    rx_master_pin__byte equ 5
120     0003    rx_master_pin__bit equ 3
121     0005    tx_slave_pin__byte equ 5
122     0001    tx_slave_pin__bit equ 1
123     0005    rx_slave_pin__byte equ 5
124     0000    rx_slave_pin__bit equ 0
125     0005    heart__byte equ 5
126     0004    heart__bit equ 4
127                     ;   constant space 0xff  
128     00ff    space equ 255
129                     ;   constant buffer_size 3  
130     0003    buffer_size equ 3
131                     ; string_constants Start
132             string___fetch:
133 00b 0082            movwf pcl___register
134                     ;   bit_string = 0s'Bit'  
135     0000    bit_string___string equ 0
136             bit_string:
137 00c 0782            addwf pcl___register,f
138                     ; Length = 3
139 00d 3403            retlw 3
140                     ; `Bit'
141 00e 3442            retlw 66
142 00f 3469            retlw 105
143 010 3474            retlw 116
144                     ;   clock_string = 0s'Clk'  
145     0005    clock_string___string equ 5
146             clock_string:
147 011 0782            addwf pcl___register,f
148                     ; Length = 3
149 012 3403            retlw 3
150                     ; `Clk'
151 013 3443            retlw 67
152 014 346c            retlw 108
153 015 346b            retlw 107
154                     ;   common_string = 0s'Common'  
155     000a    common_string___string equ 10
156             common_string:
157 016 0782            addwf pcl___register,f
158                     ; Length = 6
159 017 3406            retlw 6
160                     ; `Common'
161 018 3443            retlw 67
162 019 346f            retlw 111
163 01a 346d            retlw 109
164 01b 346d            retlw 109
165 01c 346f            retlw 111
166 01d 346e            retlw 110
167                     ;   done_string = 0s'Done'  
168     0012    done_string___string equ 18
169             done_string:
170 01e 0782            addwf pcl___register,f
171                     ; Length = 4
172 01f 3404            retlw 4
173                     ; `Done'
174 020 3444            retlw 68
175 021 346f            retlw 111
176 022 346e            retlw 110
177 023 3465            retlw 101
178                     ;   fail_string = 0s'Fail'  
179     0018    fail_string___string equ 24
180             fail_string:
181 024 0782            addwf pcl___register,f
182                     ; Length = 4
183 025 3404            retlw 4
184                     ; `Fail'
185 026 3446            retlw 70
186 027 3461            retlw 97
187 028 3469            retlw 105
188 029 346c            retlw 108
189                     ;   hello_string = 0s'Shaft2_Test'  
190     001e    hello_string___string equ 30
191             hello_string:
192 02a 0782            addwf pcl___register,f
193                     ; Length = 11
194 02b 340b            retlw 11
195                     ; `Shaft2_Test'
196 02c 3453            retlw 83
197 02d 3468            retlw 104
198 02e 3461            retlw 97
199 02f 3466            retlw 102
200 030 3474            retlw 116
201 031 3432            retlw 50
202 032 345f            retlw 95
203 033 3454            retlw 84
204 034 3465            retlw 101
205 035 3473            retlw 115
206 036 3474            retlw 116
207                     ;   interrupt_string = 0s'Int'  
208     002b    interrupt_string___string equ 43
209             interrupt_string:
210 037 0782            addwf pcl___register,f
211                     ; Length = 3
212 038 3403            retlw 3
213                     ; `Int'
214 039 3449            retlw 73
215 03a 346e            retlw 110
216 03b 3474            retlw 116
217                     ;   patterns = 0 , 1 , 2 , 4 , 8 , 0x10 , 0x20 , 0x40 , 0x80 , 0xff , 0  
218     0030    patterns___string equ 48
219             patterns:
220 03c 0782            addwf pcl___register,f
221                     ; Length = 11
222 03d 340b            retlw 11
223                     ; 0
224 03e 3400            retlw 0
225                     ; 1
226 03f 3401            retlw 1
227                     ; 2
228 040 3402            retlw 2
229                     ; 4
230 041 3404            retlw 4
231                     ; 8
232 042 3408            retlw 8
233                     ; 0x10
234 043 3410            retlw 16
235                     ; 0x20
236 044 3420            retlw 32
237                     ; 0x40
238 045 3440            retlw 64
239                     ; 0x80
240 046 3480            retlw 128
241                     ; 0xff
242 047 34ff            retlw 255
243                     ; 0
244 048 3400            retlw 0
245                     ;   register_string = 0s'Reg'  
246     003d    register_string___string equ 61
247             register_string:
248 049 0782            addwf pcl___register,f
249                     ; Length = 3
250 04a 3403            retlw 3
251                     ; `Reg'
252 04b 3452            retlw 82
253 04c 3465            retlw 101
254 04d 3467            retlw 103
255                     ; string__constants End
256     000c    temp equ global__variables__bank0+0
257             
258                     ; procedure main start
259             main:
260     000d    main__variables__base equ global__variables__bank0+1
261     000d    main__bytes__base equ main__variables__base+0
262     0014    main__bits__base equ main__variables__base+7
263     0007    main__total__bytes equ 7
264     0013    main__108byte0 equ main__bytes__base+6
265     0013    main__136byte0 equ main__bytes__base+6
266                     ;   arguments_none  
267                     ; Read a byte .
268     000d    main__buffer equ main__bytes__base+0
269     0010    main__char equ main__bytes__base+3
270     0011    main__index equ main__bytes__base+4
271     0012    main__number equ main__bytes__base+5
272                     ; Print out a welcome message :
273                     ;   call master_crlf {{ }}  
274 04e 22e1            call master_crlf
275                     ;   call master_string {{ hello_string }}  
276 04f 302b            movlw LOW hello_string+1
277 050 00bc            movwf master_string__message
278 051 2364            call master_string
279                     ;   call master_crlf {{ }}  
280 052 22e1            call master_crlf
281                     ; Main loop
282                     ;   number := 0  
283 053 0192            clrf main__number
284                     ; loop_forever ... start
285             main__96loop__forever:
286                     ; Get a character :
287                     ;   tx_slave_pin := 1  
288 054 1485            bsf tx_slave_pin__byte,tx_slave_pin__bit
289                     ;   char := master_get {{ }}  
290 055 22f3            call master_get
291 056 082e            movf master_get__0return__byte,w
292 057 0090            movwf main__char
293                     ; Delay 2 / 3 ' s of bit make sure that get_byte is done .
294                     ;   call delay {{ }}  
295 058 2377            call delay
296                     ;   call delay {{ }}  
297 059 2377            call delay
298                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } start
299 05a 3030            movlw 48
300 05b 0210            subwf main__char,w
301                     ; expression=`0c'0' <= char' exp_delay=2 true_delay=-1  false_delay=1 true_size=129 false_size=1
302 05c 1c03            btfss c___byte,c___bit
303 05d 286e            goto and105__0false
304 05e 303a            movlw 58
305 05f 0210            subwf main__char,w
306                     ; expression=`char < {{ 0c'9' + 1 }}' exp_delay=2 true_delay=9  false_delay=-1 true_size=11 false_size=113
307 060 1803            btfsc c___byte,c___bit
308 061 286e            goto label105__1false
309             label105__1true:
310             and105__0true:
311                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body start
312                     ; Do a multiply by 8 then add in digit :
313                     ;   call master_send {{ char }}  
314 062 0810            movf main__char,w
315 063 00bb            movwf master_send__character
316 064 235e            call master_send
317                     ;   number := {{ number << 3 }} + char - 0c'0'  
318 065 0d12            rlf main__number,w
319 066 0093            movwf main__108byte0
320 067 0d93            rlf main__108byte0,f
321 068 0d13            rlf main__108byte0,w
322 069 39f8            andlw 248
323 06a 0710            addwf main__char,w
324 06b 3ed0            addlw 208
325 06c 0092            movwf main__number
326                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body end
327 06d 28df            goto label105__1end
328             label105__1false:
329             and105__0false:
330 06e 3073            movlw 115
331 06f 0210            subwf main__char,w
332                     ; expression=`{ char = 0c's' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=8 false_size=100
333 070 1d03            btfss z___byte,z___bit
334 071 287b            goto label109__0false
335             label109__0true:
336                     ; else_if { char = 0c's' } body start
337                     ; Send byte to brick , no wait :
338                     ; Echo command and send CRLF :
339                     ;   call master_send {{ char }}  
340 072 0810            movf main__char,w
341 073 00bb            movwf master_send__character
342 074 235e            call master_send
343                     ;   call master_crlf {{ }}  
344 075 22e1            call master_crlf
345                     ; Ship the byte down to the brick :
346                     ;   call slave_send {{ number }}  
347 076 0812            movf main__number,w
348 077 00b2            movwf slave_send__data
349 078 2318            call slave_send
350                     ;   number := 0  
351 079 0192            clrf main__number
352                     ; else_if { char = 0c's' } body end
353 07a 28df            goto label109__0end
354             label109__0false:
355 07b 3077            movlw 119
356 07c 0210            subwf main__char,w
357                     ; expression=`{ char = 0c'w' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=37 false_size=58
358 07d 1d03            btfss z___byte,z___bit
359 07e 28a5            goto label120__0false
360             label120__0true:
361                     ; else_if { char = 0c'w' } body start
362                     ; Send byte to brick , wait for results :
363                     ; Echo command and send CRLF :
364                     ;   call master_send {{ char }}  
365 07f 0810            movf main__char,w
366 080 00bb            movwf master_send__character
367 081 235e            call master_send
368                     ;   call master_crlf {{ }}  
369 082 22e1            call master_crlf
370                     ; Ship the byte down to the brick ...
371                     ;   call slave_send {{ number }}  
372 083 0812            movf main__number,w
373 084 00b2            movwf slave_send__data
374 085 2318            call slave_send
375                     ;   number := 0  
376 086 0192            clrf main__number
377                     ; call delay < >
378                     ; ... and wait for a response :
379                     ;   index := 0  
380 087 0191            clrf main__index
381                     ; `while  index < buffer_size  ...' start
382             main__135while__continue:
383 088 3003            movlw 3
384 089 0211            subwf main__index,w
385                     ; expression=` index < buffer_size ' exp_delay=2 true_delay=9  false_delay=2 true_size=10 false_size=1
386 08a 1803            btfsc c___byte,c___bit
387 08b 2896            goto main__135while__break
388                     ;   buffer ~~ {{ index }} := slave_get {{ }}  
389 08c 2312            call slave_get
390 08d 0831            movf slave_get__0return__byte,w
391 08e 0093            movwf main__136byte0
392 08f 300d            movlw LOW main__buffer
393 090 0711            addwf main__index,w
394 091 0084            movwf fsr___register
395 092 0813            movf main__136byte0,w
396 093 0080            movwf indf___register
397                     ;   index := index + 1  
398 094 0a91            incf main__index,f
399 095 2888            goto main__135while__continue
400                     ; if exp=` index < buffer_size ' false goto
401                     ; Other expression=` index < buffer_size ' delay=-1
402             main__135while__break:
403                     ; `while  index < buffer_size  ...' end
404                     ;   index := 0  
405 096 0191            clrf main__index
406                     ; `while  index < buffer_size  ...' start
407             main__141while__continue:
408 097 3003            movlw 3
409 098 0211            subwf main__index,w
410                     ; expression=` index < buffer_size ' exp_delay=2 true_delay=7  false_delay=2 true_size=8 false_size=1
411 099 1803            btfsc c___byte,c___bit
412 09a 28a3            goto main__141while__break
413                     ;   call master_octal {{ buffer ~~ {{ index }} }}  
414 09b 300d            movlw LOW main__buffer
415 09c 0711            addwf main__index,w
416 09d 0084            movwf fsr___register
417 09e 0800            movf indf___register,w
418 09f 00af            movwf master_octal__number
419 0a0 22f9            call master_octal
420                     ;   index := index + 1  
421 0a1 0a91            incf main__index,f
422 0a2 2897            goto main__141while__continue
423                     ; if exp=` index < buffer_size ' false goto
424                     ; Other expression=` index < buffer_size ' delay=-1
425             main__141while__break:
426                     ; `while  index < buffer_size  ...' end
427                     ; Terminate the output list
428                     ;   call master_crlf {{ }}  
429 0a3 22e1            call master_crlf
430                     ; else_if { char = 0c'w' } body end
431 0a4 28df            goto label120__0end
432             label120__0false:
433 0a5 3069            movlw 105
434 0a6 0210            subwf main__char,w
435                     ; expression=`{ char = 0c'i' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=12 false_size=41
436 0a7 1d03            btfss z___byte,z___bit
437 0a8 28b6            goto label148__0false
438             label148__0true:
439                     ; else_if { char = 0c'i' } body start
440                     ; Interrogate the slave RoboBrick :
441                     ;   call master_send {{ char }}  
442 0a9 0810            movf main__char,w
443 0aa 00bb            movwf master_send__character
444 0ab 235e            call master_send
445                     ;   call master_crlf {{ }}  
446 0ac 22e1            call master_crlf
447                     ; Initialize the id index :
448                     ;   call slave_send {{ 0xfd }}  
449 0ad 30fd            movlw 253
450 0ae 00b2            movwf slave_send__data
451 0af 2318            call slave_send
452                     ; Get the first 8 bytes :
453                     ;   call common_test_id_bytes8 {{ }}  
454 0b0 2254            call common_test_id_bytes8
455                     ; Get the next 8 bytes of random numbers :
456                     ;   call common_test_id_bytes8 {{ }}  
457 0b1 2254            call common_test_id_bytes8
458                     ; Get the next 8 bytes of random numbers :
459                     ;   call common_test_id_bytes8 {{ }}  
460 0b2 2254            call common_test_id_bytes8
461                     ; Get the slave brick name :
462                     ;   call common_test_id_string {{ }}  
463 0b3 225e            call common_test_id_string
464                     ; Get the vendor name :
465                     ;   call common_test_id_string {{ }}  
466 0b4 225e            call common_test_id_string
467                     ; else_if { char = 0c'i' } body end
468 0b5 28df            goto label148__0end
469             label148__0false:
470 0b6 3074            movlw 116
471 0b7 0210            subwf main__char,w
472                     ; expression=`{ char = 0c't' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=5 false_size=31
473 0b8 1d03            btfss z___byte,z___bit
474 0b9 28c0            goto label171__0false
475             label171__0true:
476                     ; else_if { char = 0c't' } body start
477                     ; Do testing :
478                     ;   call master_send {{ char }}  
479 0ba 0810            movf main__char,w
480 0bb 00bb            movwf master_send__character
481 0bc 235e            call master_send
482                     ;   call master_crlf {{ }}  
483 0bd 22e1            call master_crlf
484                     ;   call test {{ }}  
485 0be 2156            call test
486                     ; else_if { char = 0c't' } body end
487 0bf 28df            goto label171__0end
488             label171__0false:
489 0c0 3063            movlw 99
490 0c1 0210            subwf main__char,w
491                     ; expression=`{ char = 0c'c' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=7 false_size=19
492 0c2 1d03            btfss z___byte,z___bit
493 0c3 28cc            goto label176__0false
494             label176__0true:
495                     ; else_if { char = 0c'c' } body start
496                     ;   call master_send {{ char }}  
497 0c4 0810            movf main__char,w
498 0c5 00bb            movwf master_send__character
499 0c6 235e            call master_send
500                     ;   call master_crlf {{ }}  
501 0c7 22e1            call master_crlf
502                     ;   call clock_adjust {{ number }}  
503 0c8 0812            movf main__number,w
504 0c9 0094            movwf clock_adjust__target
505 0ca 20e0            call clock_adjust
506                     ; else_if { char = 0c'c' } body end
507 0cb 28df            goto label176__0end
508             label176__0false:
509 0cc 30fc            movlw 252
510 0cd 0210            subwf main__char,w
511                     ; expression=`{ char != 0xfc }' exp_delay=2 true_delay=-1  false_delay=0 true_size=15 false_size=0
512 0ce 1903            btfsc z___byte,z___bit
513 0cf 28df            goto label181__0end
514                     ; else_if { char != 0xfc } body start
515                     ; Just echo back the current number :
516                     ;   call master_send {{ 0c'<' }}  
517 0d0 303c            movlw 60
518 0d1 00bb            movwf master_send__character
519 0d2 235e            call master_send
520                     ;   call master_octal {{ char }}  
521 0d3 0810            movf main__char,w
522 0d4 00af            movwf master_octal__number
523 0d5 22f9            call master_octal
524                     ;   call master_send {{ 0c'>' }}  
525 0d6 303e            movlw 62
526 0d7 00bb            movwf master_send__character
527 0d8 235e            call master_send
528                     ; Send a carriage - return line - feed :
529                     ;   call master_crlf {{ }}  
530 0d9 22e1            call master_crlf
531                     ; Output the character in octal :
532                     ;   call master_octal {{ number }}  
533 0da 0812            movf main__number,w
534 0db 00af            movwf master_octal__number
535 0dc 22f9            call master_octal
536                     ; Send a carriage - return line - feed :
537                     ;   call master_crlf {{ }}  
538 0dd 22e1            call master_crlf
539                     ; Reset number
540                     ;   number := 0  
541 0de 0192            clrf main__number
542                     ; else_if { char != 0xfc } body end
543             label181__0end:
544                     ; if exp=` char != 0xfc ' empty false
545                     ; Other expression=`{ char != 0xfc }' delay=-1
546                     ; if exp=` char = 0c'c' ' generic
547             label176__0end:
548                     ; Other expression=`{ char = 0c'c' }' delay=-1
549                     ; if exp=` char = 0c't' ' generic
550             label171__0end:
551                     ; Other expression=`{ char = 0c't' }' delay=-1
552                     ; if exp=` char = 0c'i' ' generic
553             label148__0end:
554                     ; Other expression=`{ char = 0c'i' }' delay=-1
555                     ; if exp=` char = 0c'w' ' generic
556             label120__0end:
557                     ; Other expression=`{ char = 0c'w' }' delay=-1
558                     ; if exp=` char = 0c's' ' generic
559             label109__0end:
560                     ; Other expression=`{ char = 0c's' }' delay=-1
561                     ; if exp=`char < {{ 0c'9' + 1 }}' generic
562             label105__1end:
563                     ; Other expression=`char < {{ 0c'9' + 1 }}' delay=-1
564                     ; if exp=`0c'0' <= char' false goto
565                     ; Other expression=`0c'0' <= char' delay=-1
566             and105__0end:
567                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } end
568 0df 2854            goto main__96loop__forever
569                     ; loop_forever ... end
570                     ; procedure main end
571             
572                     ; procedure clock_adjust start
573             clock_adjust:
574     0014    clock_adjust__variables__base equ global__variables__bank0+8
575     0014    clock_adjust__bytes__base equ clock_adjust__variables__base+0
576     001b    clock_adjust__bits__base equ clock_adjust__variables__base+7
577     0007    clock_adjust__total__bytes equ 7
578     001a    clock_adjust__271byte0 equ clock_adjust__bytes__base+6
579     0014    clock_adjust__target equ clock_adjust__bytes__base+0
580                     ; This procedure will adjust the clock to the slave .
581     0015    clock_adjust__count equ clock_adjust__bytes__base+1
582     0016    clock_adjust__error equ clock_adjust__bytes__base+2
583     0017    clock_adjust__error_minimum equ clock_adjust__bytes__base+3
584     0018    clock_adjust__high equ clock_adjust__bytes__base+4
585     0019    clock_adjust__low equ clock_adjust__bytes__base+5
586                     ;   call master_string {{ clock_string }}  
587 0e0 3012            movlw LOW clock_string+1
588 0e1 00bc            movwf master_string__message
589 0e2 2364            call master_string
590                     ;   call master_crlf {{ }}  
591 0e3 22e1            call master_crlf
592                     ; if { target = 0 } start
593 0e4 0814            movf clock_adjust__target,w
594                     ; expression=`{ target = 0 }' exp_delay=1 true_delay=2  false_delay=0 true_size=2 false_size=0
595 0e5 1d03            btfss z___byte,z___bit
596 0e6 28e9            goto label218__0end
597                     ; if { target = 0 } body start
598                     ;   target := clock_target  
599 0e7 3012            movlw 18
600 0e8 0094            movwf clock_adjust__target
601                     ; if { target = 0 } body end
602             label218__0end:
603                     ; if exp=` target = 0 ' empty false
604                     ; Other expression=`{ target = 0 }' delay=-1
605                     ; if { target = 0 } end
606                     ;   count := 4  
607 0e9 3004            movlw 4
608 0ea 0095            movwf clock_adjust__count
609                     ;   error := 0xff  
610 0eb 30ff            movlw 255
611 0ec 0096            movwf clock_adjust__error
612                     ;   error_minimum := 0xf0  
613 0ed 30f0            movlw 240
614 0ee 0097            movwf clock_adjust__error_minimum
615                     ; loop_forever ... start
616             clock_adjust__225loop__forever:
617                     ; Print out the clock value :
618                     ;   call master_send {{ 0c'C' }}  
619 0ef 3043            movlw 67
620 0f0 00bb            movwf master_send__character
621 0f1 235e            call master_send
622                     ;   call slave_send {{ 0xfa }}  
623 0f2 30fa            movlw 250
624 0f3 00b2            movwf slave_send__data
625 0f4 2318            call slave_send
626                     ;   call master_octal {{ slave_get {{ }} }}  
627 0f5 2312            call slave_get
628 0f6 0831            movf slave_get__0return__byte,w
629 0f7 00af            movwf master_octal__number
630 0f8 22f9            call master_octal
631                     ; Ask for a timing byte :
632                     ;   call slave_send {{ 0xfb }}  
633 0f9 30fb            movlw 251
634 0fa 00b2            movwf slave_send__data
635 0fb 2318            call slave_send
636                     ;   low := 0  
637 0fc 0199            clrf clock_adjust__low
638                     ;   high := 0  
639 0fd 0198            clrf clock_adjust__high
640                     ; `while rx_slave_pin ...' start
641             clock_adjust__236while__continue:
642                     ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=2 true_size=1 false_size=1
643 0fe 1805            btfsc rx_slave_pin__byte,rx_slave_pin__bit
644                     ; Do nothing :
645 0ff 28fe            goto clock_adjust__236while__continue
646 100 2901            goto clock_adjust__236while__break
647                     ; if exp=`rx_slave_pin' true goto small true
648             clock_adjust__236while__break:
649                     ; `while rx_slave_pin ...' end
650                     ; `while  ! rx_slave_pin  ...' start
651             clock_adjust__239while__continue:
652                     ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=5 true_size=1 false_size=4
653 101 1805            btfsc rx_slave_pin__byte,rx_slave_pin__bit
654 102 2907            goto clock_adjust__239while__break
655                     ;   low := low + 1  
656 103 0a99            incf clock_adjust__low,f
657                     ; if { z } start
658                     ; expression=`{ z }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
659 104 1903            btfsc z__byte,z__bit
660                     ; if { z } body start
661                     ;   high := high + 1  
662 105 0a98            incf clock_adjust__high,f
663                     ; if { z } body end
664                     ; if exp=`z' false skip delay=2
665                     ; Other expression=`{ z }' delay=2
666                     ; if { z } end
667 106 2901            goto clock_adjust__239while__continue
668                     ; if exp=`rx_slave_pin' true goto
669                     ; Other expression=`rx_slave_pin' delay=-1
670             clock_adjust__239while__break:
671                     ; `while  ! rx_slave_pin  ...' end
672                     ; Print out high and low :
673                     ;   call master_send {{ 0c'H' }}  
674 107 3048            movlw 72
675 108 00bb            movwf master_send__character
676 109 235e            call master_send
677                     ;   call master_octal {{ high }}  
678 10a 0818            movf clock_adjust__high,w
679 10b 00af            movwf master_octal__number
680 10c 22f9            call master_octal
681                     ;   call master_send {{ 0c'L' }}  
682 10d 304c            movlw 76
683 10e 00bb            movwf master_send__character
684 10f 235e            call master_send
685                     ;   call master_octal {{ low }}  
686 110 0819            movf clock_adjust__low,w
687 111 00af            movwf master_octal__number
688 112 22f9            call master_octal
689                     ; If high is less than 2 , things are probably pretty broken .
690                     ; We ' ll try a little fix here , but we are probably pretty
691                     ; screwed up .
692                     ; if { high < 2 } start
693 113 3002            movlw 2
694 114 0218            subwf clock_adjust__high,w
695                     ; expression=`{ high < 2 }' exp_delay=2 true_delay=1  false_delay=0 true_size=1 false_size=0
696 115 1c03            btfss c___byte,c___bit
697                     ; if { high < 2 } body start
698                     ;   low := 0  
699 116 0199            clrf clock_adjust__low
700                     ; if { high < 2 } body end
701                     ; if exp=` high < 2 ' false skip delay=4
702                     ; Other expression=`{ high < 2 }' delay=4
703                     ; if { high < 2 } end
704                     ; High is now free ; stuff a command in it now .
705                     ; Now think about adjusting clock .
706                     ; if { low > clock_target } start
707 117 3013            movlw 19
708 118 0219            subwf clock_adjust__low,w
709                     ; expression=`{ low > clock_target }' exp_delay=2 true_delay=5  false_delay=-1 true_size=5 false_size=15
710 119 1803            btfsc c___byte,c___bit
711 11a 292b            goto label261__0true
712             label261__0false:
713 11b 3012            movlw 18
714 11c 0219            subwf clock_adjust__low,w
715                     ; expression=`{ low < clock_target }' exp_delay=2 true_delay=7  false_delay=3 true_size=7 false_size=3
716 11d 1c03            btfss c___byte,c___bit
717 11e 2923            goto label268__0true
718             label268__0false:
719                     ; else body start
720                     ; call master_send < 0c'x' >
721                     ;   high := 0  
722 11f 0198            clrf clock_adjust__high
723                     ;   error := 0  
724 120 0196            clrf clock_adjust__error
725                     ;   error_minimum := 0  
726 121 0197            clrf clock_adjust__error_minimum
727                     ; else body end
728 122 292a            goto label268__0end
729             label268__0true:
730                     ; else_if { low < clock_target } body start
731                     ; call master_send < 0c'-' >
732                     ; Slave clock is too fast < i . e . pulse too short . >
733                     ;   error := clock_target - low  
734 123 3012            movlw 18
735 124 009a            movwf clock_adjust__271byte0
736 125 0819            movf clock_adjust__low,w
737 126 021a            subwf clock_adjust__271byte0,w
738 127 0096            movwf clock_adjust__error
739                     ; Decrement clock :
740                     ;   high := 0xf8  
741 128 30f8            movlw 248
742 129 0098            movwf clock_adjust__high
743                     ; call slave_send < 0xf8 >
744                     ; else_if { low < clock_target } body end
745                     ; if exp=` low < clock_target ' generic
746             label268__0end:
747                     ; Other expression=`{ low < clock_target }' delay=-1
748 12a 2930            goto label261__0end
749             label261__0true:
750                     ; if { low > clock_target } body start
751                     ; call master_send < 0c'+' >
752                     ; Slave clock is too slow < i . e . pulse too long . >
753                     ;   error := low - clock_target  
754 12b 30ee            movlw 238
755 12c 0719            addwf clock_adjust__low,w
756 12d 0096            movwf clock_adjust__error
757                     ; Increment clock :
758                     ;   high := 0xf9  
759 12e 30f9            movlw 249
760 12f 0098            movwf clock_adjust__high
761                     ; call slave_send < 0xf9 >
762                     ; if { low > clock_target } body end
763                     ; if exp=` low > clock_target ' generic
764             label261__0end:
765                     ; Other expression=`{ low > clock_target }' delay=-1
766                     ; if { low > clock_target } end
767                     ; Print out the error and error minimum :
768                     ;   call master_send {{ 0c'E' }}  
769 130 3045            movlw 69
770 131 00bb            movwf master_send__character
771 132 235e            call master_send
772                     ;   call master_octal {{ error }}  
773 133 0816            movf clock_adjust__error,w
774 134 00af            movwf master_octal__number
775 135 22f9            call master_octal
776                     ;   call master_send {{ 0c'M' }}  
777 136 304d            movlw 77
778 137 00bb            movwf master_send__character
779 138 235e            call master_send
780                     ;   call master_octal {{ error_minimum }}  
781 139 0817            movf clock_adjust__error_minimum,w
782 13a 00af            movwf master_octal__number
783 13b 22f9            call master_octal
784                     ; if { error = error_minimum } start
785 13c 0816            movf clock_adjust__error,w
786 13d 0217            subwf clock_adjust__error_minimum,w
787                     ; expression=`{ error = error_minimum }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=2 false_size=14
788 13e 1d03            btfss z___byte,z___bit
789 13f 2943            goto label288__0false
790             label288__0true:
791                     ; if { error = error_minimum } body start
792                     ;   call master_crlf {{ }}  
793 140 22e1            call master_crlf
794                     ;   return  
795 141 3400            retlw 0
796                     ; if { error = error_minimum } body end
797 142 2951            goto label288__0end
798             label288__0false:
799 143 0817            movf clock_adjust__error_minimum,w
800 144 0216            subwf clock_adjust__error,w
801                     ; expression=`{ error < error_minimum }' exp_delay=2 true_delay=3  false_delay=-1 true_size=3 false_size=6
802 145 1c03            btfss c___byte,c___bit
803 146 294e            goto label291__0true
804             label291__0false:
805                     ; else body start
806                     ;   count := count - 1  
807 147 0395            decf clock_adjust__count,f
808                     ; if { z } start
809                     ; expression=`{ z }' exp_delay=0 true_delay=3  false_delay=0 true_size=3 false_size=0
810 148 1d03            btfss z__byte,z__bit
811 149 294d            goto label296__0end
812                     ; if { z } body start
813                     ;   error_minimum := error_minimum + 1  
814 14a 0a97            incf clock_adjust__error_minimum,f
815                     ;   count := 4  
816 14b 3004            movlw 4
817 14c 0095            movwf clock_adjust__count
818                     ; if { z } body end
819             label296__0end:
820                     ; if exp=`z' empty false
821                     ; Other expression=`{ z }' delay=-1
822                     ; if { z } end
823                     ; else body end
824 14d 2951            goto label291__0end
825             label291__0true:
826                     ; else_if { error < error_minimum } body start
827                     ;   error_minimum := error  
828 14e 0816            movf clock_adjust__error,w
829 14f 0097            movwf clock_adjust__error_minimum
830                     ;   error := error + 1  
831 150 0a96            incf clock_adjust__error,f
832                     ; else_if { error < error_minimum } body end
833                     ; if exp=` error < error_minimum ' generic
834             label291__0end:
835                     ; Other expression=`{ error < error_minimum }' delay=-1
836                     ; if exp=` error = error_minimum ' generic
837             label288__0end:
838                     ; Other expression=`{ error = error_minimum }' delay=-1
839                     ; if { error = error_minimum } end
840                     ; Now adjust the clock :
841                     ;   call slave_send {{ high }}  
842 151 0818            movf clock_adjust__high,w
843 152 00b2            movwf slave_send__data
844 153 2318            call slave_send
845                     ;   call master_crlf {{ }}  
846 154 22e1            call master_crlf
847 155 28ef            goto clock_adjust__225loop__forever
848                     ; loop_forever ... end
849                     ; procedure clock_adjust end
850             
851                     ; procedure test start
852             test:
853     001b    test__variables__base equ global__variables__bank0+15
854     001b    test__bytes__base equ test__variables__base+0
855     001b    test__bits__base equ test__variables__base+0
856     0000    test__total__bytes equ 0
857                     ;   arguments_none  
858                     ; This procedure will test the Shaft2 RoboBrick :
859                     ; Adjust the clock :
860                     ; call clock_adjust < 0 >
861                     ; Verify that the common commands are working :
862                     ;   call common_test {{ }}  
863 156 21d4            call common_test
864                     ; Verify that we can interrupt :
865                     ; call test_interrupt_setup < 0 >
866                     ; call test_interrupt_setup < 1 >
867                     ; call interrupt_test < >
868                     ; Test some shaft inputs :
869                     ;   call test_shaft {{ 0 , 0x10 , 0 }}  
870 157 019d            clrf test_shaft__high
871 158 3010            movlw 16
872 159 009e            movwf test_shaft__low
873 15a 019f            clrf test_shaft__shaft
874 15b 21a9            call test_shaft
875                     ;   call test_shaft {{ 0 , 0x10 , 1 }}  
876 15c 019d            clrf test_shaft__high
877 15d 3010            movlw 16
878 15e 009e            movwf test_shaft__low
879 15f 3001            movlw 1
880 160 009f            movwf test_shaft__shaft
881 161 21a9            call test_shaft
882                     ; Now test interrupt ranges :
883                     ;   call test_interrupt {{ 0 }}  
884 162 019c            clrf test_interrupt__shaft
885 163 218c            call test_interrupt
886                     ;   call test_interrupt {{ 1 }}  
887 164 3001            movlw 1
888 165 009c            movwf test_interrupt__shaft
889 166 218c            call test_interrupt
890                     ; Let ' s go test some registers :
891                     ;   call master_string {{ register_string }}  
892 167 304a            movlw LOW register_string+1
893 168 00bc            movwf master_string__message
894 169 2364            call master_string
895                     ;   call master_crlf {{ }}  
896 16a 22e1            call master_crlf
897                     ; call test_byte_register < 6 , 2 , 0x30 >
898                     ; call test_byte_register < 7 , 3 , 0x31 >
899                     ; call test_byte_register < 0x18 , 0x19 , 0x32 >
900                     ; call test_word_register < 4 , 0 , 0x34 >
901                     ; call test_word_register < 5 , 1 , 0x36 >
902                     ; call test_word_register < 0x10 , 0x14 , 0x38 >
903                     ; call test_word_register < 0x12 , 0x16 , 0x3a >
904                     ; Announce we are done :
905                     ;   call master_string {{ done_string }}  
906 16b 301f            movlw LOW done_string+1
907 16c 00bc            movwf master_string__message
908 16d 2364            call master_string
909                     ;   call master_crlf {{ }}  
910 16e 22e1            call master_crlf
911                     ; procedure test end
912 16f 3400            retlw 0
913             
914                     ; procedure test_interrupt_setup start
915             test_interrupt_setup:
916     001b    test_interrupt_setup__variables__base equ global__variables__bank0+15
917     001b    test_interrupt_setup__bytes__base equ test_interrupt_setup__variables__base+0
918     001c    test_interrupt_setup__bits__base equ test_interrupt_setup__variables__base+1
919     0001    test_interrupt_setup__total__bytes equ 1
920     001b    test_interrupt_setup__shaft equ test_interrupt_setup__bytes__base+0
921                     ; This procedure will set up the registers for shaft to be interrupt safe .
922                     ; Set low threshold :
923                     ;   call slave_send {{ 0x12 | shaft }}  
924 170 3012            movlw 18
925 171 041b            iorwf test_interrupt_setup__shaft,w
926 172 00b2            movwf slave_send__data
927 173 2318            call slave_send
928                     ;   call slave_send {{ 0 }}  
929 174 01b2            clrf slave_send__data
930 175 2318            call slave_send
931                     ;   call slave_send {{ 0x10 }}  
932 176 3010            movlw 16
933 177 00b2            movwf slave_send__data
934 178 2318            call slave_send
935                     ; Set high threshold :
936                     ;   call slave_send {{ 0x10 | shaft }}  
937 179 3010            movlw 16
938 17a 041b            iorwf test_interrupt_setup__shaft,w
939 17b 00b2            movwf slave_send__data
940 17c 2318            call slave_send
941                     ;   call slave_send {{ 0 }}  
942 17d 01b2            clrf slave_send__data
943 17e 2318            call slave_send
944                     ;   call slave_send {{ 0x30 }}  
945 17f 3030            movlw 48
946 180 00b2            movwf slave_send__data
947 181 2318            call slave_send
948                     ; Set the shaft to the middle :
949                     ;   call slave_send {{ 4 | shaft }}  
950 182 3004            movlw 4
951 183 041b            iorwf test_interrupt_setup__shaft,w
952 184 00b2            movwf slave_send__data
953 185 2318            call slave_send
954                     ;   call slave_send {{ 0 }}  
955 186 01b2            clrf slave_send__data
956 187 2318            call slave_send
957                     ;   call slave_send {{ 0x20 }}  
958 188 3020            movlw 32
959 189 00b2            movwf slave_send__data
960 18a 2318            call slave_send
961                     ; procedure test_interrupt_setup end
962 18b 3400            retlw 0
963             
964                     ; procedure test_interrupt start
965             test_interrupt:
966     001c    test_interrupt__variables__base equ global__variables__bank0+16
967     001c    test_interrupt__bytes__base equ test_interrupt__variables__base+0
968     001d    test_interrupt__bits__base equ test_interrupt__variables__base+1
969     0001    test_interrupt__total__bytes equ 1
970     001c    test_interrupt__shaft equ test_interrupt__bytes__base+0
971                     ; This procedure will test interrupts shaft .
972                     ;   call test_interrupt_setup {{ 0 }}  
973 18c 019b            clrf test_interrupt_setup__shaft
974 18d 2170            call test_interrupt_setup
975                     ;   call test_interrupt_setup {{ 1 }}  
976 18e 3001            movlw 1
977 18f 009b            movwf test_interrupt_setup__shaft
978 190 2170            call test_interrupt_setup
979                     ; Now enable interrupts :
980                     ;   call slave_send {{ 0xf2 }}  
981 191 30f2            movlw 242
982 192 00b2            movwf slave_send__data
983 193 2318            call slave_send
984                     ; Let people know what is going on :
985                     ;   call master_octal {{ shaft }}  
986 194 081c            movf test_interrupt__shaft,w
987 195 00af            movwf master_octal__number
988 196 22f9            call master_octal
989                     ;   call master_send {{ 0c':' }}  
990 197 303a            movlw 58
991 198 00bb            movwf master_send__character
992 199 235e            call master_send
993                     ;   call master_octal {{ 0x10 }}  
994 19a 3010            movlw 16
995 19b 00af            movwf master_octal__number
996 19c 22f9            call master_octal
997                     ;   call master_send {{ 0c'?' }}  
998 19d 303f            movlw 63
999 19e 00bb            movwf master_send__character
1000 19f 235e            call master_send
1001                     ;   call master_octal {{ 0x30 }}  
1002 1a0 3030            movlw 48
1003 1a1 00af            movwf master_octal__number
1004 1a2 22f9            call master_octal
1005                     ; Now wait for interrupt :
1006                     ; `while rx_slave_pin ...' start
1007             test_interrupt__392while__continue:
1008                     ; expression=`rx_slave_pin' exp_delay=0 true_delay=1  false_delay=2 true_size=2 false_size=1
1009 1a3 1c05            btfss rx_slave_pin__byte,rx_slave_pin__bit
1010 1a4 29a7            goto test_interrupt__392while__break
1011                     ;   call delay {{ }}  
1012 1a5 2377            call delay
1013 1a6 29a3            goto test_interrupt__392while__continue
1014                     ; if exp=`rx_slave_pin' false goto
1015                     ; Other expression=`rx_slave_pin' delay=-1
1016             test_interrupt__392while__break:
1017                     ; `while rx_slave_pin ...' end
1018                     ;   call master_crlf {{ }}  
1019 1a7 22e1            call master_crlf
1020                     ; procedure test_interrupt end
1021 1a8 3400            retlw 0
1022             
1023                     ; procedure test_shaft start
1024             test_shaft:
1025     001d    test_shaft__variables__base equ global__variables__bank0+17
1026     001d    test_shaft__bytes__base equ test_shaft__variables__base+0
1027     0022    test_shaft__bits__base equ test_shaft__variables__base+5
1028     0005    test_shaft__total__bytes equ 5
1029     001d    test_shaft__high equ test_shaft__bytes__base+0
1030     001e    test_shaft__low equ test_shaft__bytes__base+1
1031     001f    test_shaft__shaft equ test_shaft__bytes__base+2
1032                     ; This procedure will verify that the shaft can be positioned to < high > and < low > .
1033     0020    test_shaft__current_high equ test_shaft__bytes__base+3
1034     0021    test_shaft__current_low equ test_shaft__bytes__base+4
1035                     ; Let the user know what we are shooting for :
1036                     ;   call master_octal {{ high }}  
1037 1a9 081d            movf test_shaft__high,w
1038 1aa 00af            movwf master_octal__number
1039 1ab 22f9            call master_octal
1040                     ;   call master_octal {{ low }}  
1041 1ac 081e            movf test_shaft__low,w
1042 1ad 00af            movwf master_octal__number
1043 1ae 22f9            call master_octal
1044                     ;   call master_send {{ 0c':' }}  
1045 1af 303a            movlw 58
1046 1b0 00bb            movwf master_send__character
1047 1b1 235e            call master_send
1048                     ;   call master_crlf {{ }}  
1049 1b2 22e1            call master_crlf
1050                     ;   current_high := high + 1  
1051 1b3 0a1d            incf test_shaft__high,w
1052 1b4 00a0            movwf test_shaft__current_high
1053                     ;   current_low := low + 1  
1054 1b5 0a1e            incf test_shaft__low,w
1055 1b6 00a1            movwf test_shaft__current_low
1056                     ; `while  high != current_high || low != current_low  ...' start
1057             test_shaft__418while__continue:
1058 1b7 081d            movf test_shaft__high,w
1059 1b8 0220            subwf test_shaft__current_high,w
1060                     ; expression=`high != current_high' exp_delay=2 true_delay=10  false_delay=-1 true_size=1 false_size=23
1061 1b9 1d03            btfss z___byte,z___bit
1062 1ba 29bf            goto or418__0true
1063 1bb 081e            movf test_shaft__low,w
1064 1bc 0221            subwf test_shaft__current_low,w
1065                     ; expression=`low != current_low' exp_delay=2 true_delay=8  false_delay=2 true_size=19 false_size=1
1066 1bd 1903            btfsc z___byte,z___bit
1067             or418__0false:
1068 1be 29d2            goto test_shaft__418while__break
1069             or418__0true:
1070                     ;   call slave_send {{ shaft }}  
1071 1bf 081f            movf test_shaft__shaft,w
1072 1c0 00b2            movwf slave_send__data
1073 1c1 2318            call slave_send
1074                     ;   current_high := slave_get {{ }}  
1075 1c2 2312            call slave_get
1076 1c3 0831            movf slave_get__0return__byte,w
1077 1c4 00a0            movwf test_shaft__current_high
1078                     ;   current_low := slave_get {{ }}  
1079 1c5 2312            call slave_get
1080 1c6 0831            movf slave_get__0return__byte,w
1081 1c7 00a1            movwf test_shaft__current_low
1082                     ;   call master_octal {{ current_high }}  
1083 1c8 0820            movf test_shaft__current_high,w
1084 1c9 00af            movwf master_octal__number
1085 1ca 22f9            call master_octal
1086                     ;   call master_octal {{ current_low }}  
1087 1cb 0821            movf test_shaft__current_low,w
1088 1cc 00af            movwf master_octal__number
1089 1cd 22f9            call master_octal
1090                     ;   call master_send {{ cr }}  
1091 1ce 300d            movlw 13
1092 1cf 00bb            movwf master_send__character
1093 1d0 235e            call master_send
1094 1d1 29b7            goto test_shaft__418while__continue
1095                     ; if exp=`low != current_low' false goto
1096                     ; Other expression=`low != current_low' delay=-1
1097                     ; if exp=`high != current_high' true goto
1098                     ; Other expression=`high != current_high' delay=-1
1099             or418__0end:
1100             test_shaft__418while__break:
1101                     ; `while  high != current_high || low != current_low  ...' end
1102                     ;   call master_crlf {{ }}  
1103 1d2 22e1            call master_crlf
1104                     ; procedure test_shaft end
1105 1d3 3400            retlw 0
1106                     ; comment {procedure test_byte_register <}
1107                     ; comment {argument set_command byte}
1108                     ; comment {argument read_command byte}
1109                     ; comment {argument error byte}
1110                     ; comment returns_nothing
1111                     ; comment {}
1112                     ; comment {# This procedure will test the ability to set and read back a byte register :}
1113                     ; comment {}
1114                     ; comment {variable index byte}
1115                     ; comment {variable pattern byte}
1116                     ; comment {}
1117                     ; comment {index := 0}
1118                     ; comment {while < index < patterns . size > <}
1119                     ; comment {pattern := patterns < index >}
1120                     ; comment {call slave_send < set_command >}
1121                     ; comment {call slave_send < pattern >}
1122                     ; comment {}
1123                     ; comment {call slave_send < read_command >}
1124                     ; comment {temp := slave_get < >}
1125                     ; comment {if < temp != pattern > <}
1126                     ; comment {call master_octal < pattern >}
1127                     ; comment {call master_octal < temp >}
1128                     ; comment {call master_fail < register_string , error >}
1129                     ; comment >
1130                     ; comment {index := index + 1}
1131                     ; comment >
1132                     ; comment >
1133                     ; comment {procedure test_word_register <}
1134                     ; comment {argument set_command byte}
1135                     ; comment {argument read_command byte}
1136                     ; comment {argument error byte}
1137                     ; comment returns_nothing
1138                     ; comment {}
1139                     ; comment {# This procedure will test the ability to set and read back a word register :}
1140                     ; comment {}
1141                     ; comment {variable low byte}
1142                     ; comment {variable low_index byte}
1143                     ; comment {variable high byte}
1144                     ; comment {variable high_index byte}
1145                     ; comment {}
1146                     ; comment {high_index := 0}
1147                     ; comment {while < high_index < patterns . size > <}
1148                     ; comment {high := patterns < high_index >}
1149                     ; comment {low_index := 0}
1150                     ; comment {while < low_index < patterns . size > <}
1151                     ; comment {low := patterns < low_index >}
1152                     ; comment {}
1153                     ; comment {# Set the register :}
1154                     ; comment {call slave_send < set_command >}
1155                     ; comment {call slave_send < high >}
1156                     ; comment {call slave_send < low >}
1157                     ; comment {}
1158                     ; comment {# Verify its contents :}
1159                     ; comment {call slave_send < read_command >}
1160                     ; comment {temp := slave_get < >}
1161                     ; comment {if < temp != high > <}
1162                     ; comment {call master_octal < high >}
1163                     ; comment {call master_octal < temp >}
1164                     ; comment {call master_fail < register_string , error >}
1165                     ; comment >
1166                     ; comment {temp := slave_get < >}
1167                     ; comment {if < temp != low > <}
1168                     ; comment {call master_octal < low >}
1169                     ; comment {call master_octal < temp >}
1170                     ; comment {call master_fail < register_string , error | 1 >}
1171                     ; comment >
1172                     ; comment {low_index := low_index + 1}
1173                     ; comment >
1174                     ; comment {high_index := high_index + 1}
1175                     ; comment >
1176                     ; comment >
1177                     ; comment {The procedures below are used to test the common shared commands :}
1178             
1179                     ; procedure common_test start
1180             common_test:
1181     0022    common_test__variables__base equ global__variables__bank0+22
1182     0022    common_test__bytes__base equ common_test__variables__base+0
1183     0024    common_test__bits__base equ common_test__variables__base+2
1184     0002    common_test__total__bytes equ 2
1185     0023    common_test__547byte0 equ common_test__bytes__base+1
1186                     ;   arguments_none  
1187                     ; This procedure will verify that the common shared commands work .
1188     0022    common_test__actual equ common_test__bytes__base+0
1189                     ; Print the ID information :
1190                     ; ID reset :
1191                     ;   call slave_send {{ 0xfd }}  
1192 1d4 30fd            movlw 253
1193 1d5 00b2            movwf slave_send__data
1194 1d6 2318            call slave_send
1195                     ; Read the fixed bytes :
1196                     ;   call common_test_id_match {{ 1 , 0xc0 }}  
1197 1d7 3001            movlw 1
1198 1d8 00a4            movwf common_test_id_match__desired
1199 1d9 30c0            movlw 192
1200 1da 00a5            movwf common_test_id_match__test_number
1201 1db 2249            call common_test_id_match
1202                     ;   call common_test_id_match {{ 0 , 0xc1 }}  
1203 1dc 01a4            clrf common_test_id_match__desired
1204 1dd 30c1            movlw 193
1205 1de 00a5            movwf common_test_id_match__test_number
1206 1df 2249            call common_test_id_match
1207                     ;   call common_test_id_match {{ 16 , 0xc2 }}  
1208 1e0 3010            movlw 16
1209 1e1 00a4            movwf common_test_id_match__desired
1210 1e2 30c2            movlw 194
1211 1e3 00a5            movwf common_test_id_match__test_number
1212 1e4 2249            call common_test_id_match
1213                     ;   call common_test_id_match {{ 0 , 0xc3 }}  
1214 1e5 01a4            clrf common_test_id_match__desired
1215 1e6 30c3            movlw 195
1216 1e7 00a5            movwf common_test_id_match__test_number
1217 1e8 2249            call common_test_id_match
1218                     ;   call common_test_id_match {{ 0 , 0xc4 }}  
1219 1e9 01a4            clrf common_test_id_match__desired
1220 1ea 30c4            movlw 196
1221 1eb 00a5            movwf common_test_id_match__test_number
1222 1ec 2249            call common_test_id_match
1223                     ;   call common_test_id_match {{ 0 , 0xc5 }}  
1224 1ed 01a4            clrf common_test_id_match__desired
1225 1ee 30c5            movlw 197
1226 1ef 00a5            movwf common_test_id_match__test_number
1227 1f0 2249            call common_test_id_match
1228                     ;   call common_test_id_match {{ 0 , 0xc6 }}  
1229 1f1 01a4            clrf common_test_id_match__desired
1230 1f2 30c6            movlw 198
1231 1f3 00a5            movwf common_test_id_match__test_number
1232 1f4 2249            call common_test_id_match
1233                     ;   call common_test_id_match {{ 0 , 0xc7 }}  
1234 1f5 01a4            clrf common_test_id_match__desired
1235 1f6 30c7            movlw 199
1236 1f7 00a5            movwf common_test_id_match__test_number
1237 1f8 2249            call common_test_id_match
1238                     ;   call master_crlf {{ }}  
1239 1f9 22e1            call master_crlf
1240                     ;   call common_test_id_bytes8 {{ }}  
1241 1fa 2254            call common_test_id_bytes8
1242                     ;   call common_test_id_bytes8 {{ }}  
1243 1fb 2254            call common_test_id_bytes8
1244                     ; Read the brick name :
1245                     ;   call common_test_id_string {{ }}  
1246 1fc 225e            call common_test_id_string
1247                     ; Read the vendor name :
1248                     ;   call common_test_id_string {{ }}  
1249 1fd 225e            call common_test_id_string
1250                     ; Verfify that we don ' t read off the end of the id and crash :
1251                     ;   call common_test_id_next {{ }}  
1252 1fe 2269            call common_test_id_next
1253 1ff 0828            movf common_test_id_next__0return__byte,w
1254                     ; Reset id :
1255                     ;   call slave_send {{ 0xfd }}  
1256 200 30fd            movlw 253
1257 201 00b2            movwf slave_send__data
1258 202 2318            call slave_send
1259                     ; Verify that we are still alive :
1260                     ;   call common_test_id_match {{ 1 , 0xc8 }}  
1261 203 3001            movlw 1
1262 204 00a4            movwf common_test_id_match__desired
1263 205 30c8            movlw 200
1264 206 00a5            movwf common_test_id_match__test_number
1265 207 2249            call common_test_id_match
1266                     ; Read glitch :
1267                     ; Clear glitch register :
1268                     ;   call slave_send {{ 0xfe }}  
1269 208 30fe            movlw 254
1270 209 00b2            movwf slave_send__data
1271 20a 2318            call slave_send
1272                     ;   actual := slave_get {{ }}  
1273 20b 2312            call slave_get
1274 20c 0831            movf slave_get__0return__byte,w
1275 20d 00a2            movwf common_test__actual
1276                     ; Send a couple of glitches :
1277                     ;   call slave_send {{ 0xff }}  
1278 20e 30ff            movlw 255
1279 20f 00b2            movwf slave_send__data
1280 210 2318            call slave_send
1281                     ;   call slave_send {{ 0xff }}  
1282 211 30ff            movlw 255
1283 212 00b2            movwf slave_send__data
1284 213 2318            call slave_send
1285                     ; Read the glitch register :
1286                     ;   call slave_send {{ 0xfe }}  
1287 214 30fe            movlw 254
1288 215 00b2            movwf slave_send__data
1289 216 2318            call slave_send
1290                     ; if { slave_get {{ }} != 2 } start
1291 217 2312            call slave_get
1292 218 0831            movf slave_get__0return__byte,w
1293 219 00a3            movwf common_test__547byte0
1294 21a 3002            movlw 2
1295 21b 0223            subwf common_test__547byte0,w
1296                     ; expression=`{ slave_get {{ }} != 2 }' exp_delay=3 true_delay=3  false_delay=0 true_size=5 false_size=0
1297 21c 1903            btfsc z___byte,z___bit
1298 21d 2a23            goto label547__1end
1299                     ; if { slave_get {{ }} != 2 } body start
1300                     ;   call master_fail {{ common_string , 0xc9 }}  
1301 21e 3017            movlw LOW common_string+1
1302 21f 00ac            movwf master_fail__test_name
1303 220 30c9            movlw 201
1304 221 00ad            movwf master_fail__test_number
1305 222 22e8            call master_fail
1306                     ; if { slave_get {{ }} != 2 } body end
1307             label547__1end:
1308                     ; if exp=` slave_get ## {{ }} != 2 ' empty false
1309                     ; Other expression=`{ slave_get {{ }} != 2 }' delay=-1
1310                     ; if { slave_get {{ }} != 2 } end
1311                     ; Do a clock pulse :
1312                     ;   call slave_send {{ 0xfb }}  
1313 223 30fb            movlw 251
1314 224 00b2            movwf slave_send__data
1315 225 2318            call slave_send
1316                     ; if { slave_get {{ }} != 0 } start
1317 226 2312            call slave_get
1318 227 0831            movf slave_get__0return__byte,w
1319                     ; expression=`{ slave_get {{ }} != 0 }' exp_delay=0 true_delay=3  false_delay=0 true_size=5 false_size=0
1320 228 1903            btfsc z___byte,z___bit
1321 229 2a2f            goto label553__0end
1322                     ; if { slave_get {{ }} != 0 } body start
1323                     ;   call master_fail {{ common_string , 0xca }}  
1324 22a 3017            movlw LOW common_string+1
1325 22b 00ac            movwf master_fail__test_name
1326 22c 30ca            movlw 202
1327 22d 00ad            movwf master_fail__test_number
1328 22e 22e8            call master_fail
1329                     ; if { slave_get {{ }} != 0 } body end
1330             label553__0end:
1331                     ; if exp=` slave_get ## {{ }} != 0 ' empty false
1332                     ; Other expression=`{ slave_get {{ }} != 0 }' delay=-1
1333                     ; if { slave_get {{ }} != 0 } end
1334                     ; Read clock :
1335                     ;   call slave_send {{ 0xfa }}  
1336 22f 30fa            movlw 250
1337 230 00b2            movwf slave_send__data
1338 231 2318            call slave_send
1339                     ;   actual := slave_get {{ }}  
1340 232 2312            call slave_get
1341 233 0831            movf slave_get__0return__byte,w
1342 234 00a2            movwf common_test__actual
1343                     ; Increment :
1344                     ;   call slave_send {{ 0xf9 }}  
1345 235 30f9            movlw 249
1346 236 00b2            movwf slave_send__data
1347 237 2318            call slave_send
1348                     ; Decrement :
1349                     ;   call slave_send {{ 0xf8 }}  
1350 238 30f8            movlw 248
1351 239 00b2            movwf slave_send__data
1352 23a 2318            call slave_send
1353                     ; Read clock again :
1354                     ;   call slave_send {{ 0xfa }}  
1355 23b 30fa            movlw 250
1356 23c 00b2            movwf slave_send__data
1357 23d 2318            call slave_send
1358                     ; if { actual != slave_get {{ }} } start
1359 23e 2312            call slave_get
1360 23f 0831            movf slave_get__0return__byte,w
1361 240 0222            subwf common_test__actual,w
1362                     ; expression=`{ actual != slave_get {{ }} }' exp_delay=1 true_delay=3  false_delay=0 true_size=5 false_size=0
1363 241 1903            btfsc z___byte,z___bit
1364 242 2a48            goto label565__0end
1365                     ; if { actual != slave_get {{ }} } body start
1366                     ;   call master_fail {{ common_string , 0xcb }}  
1367 243 3017            movlw LOW common_string+1
1368 244 00ac            movwf master_fail__test_name
1369 245 30cb            movlw 203
1370 246 00ad            movwf master_fail__test_number
1371 247 22e8            call master_fail
1372                     ; if { actual != slave_get {{ }} } body end
1373             label565__0end:
1374                     ; if exp=` actual != slave_get ## {{ }} ' empty false
1375                     ; Other expression=`{ actual != slave_get {{ }} }' delay=-1
1376                     ; if { actual != slave_get {{ }} } end
1377                     ; procedure common_test end
1378 248 3400            retlw 0
1379             
1380                     ; procedure common_test_id_match start
1381             common_test_id_match:
1382     0024    common_test_id_match__variables__base equ global__variables__bank0+24
1383     0024    common_test_id_match__bytes__base equ common_test_id_match__variables__base+0
1384     0026    common_test_id_match__bits__base equ common_test_id_match__variables__base+2
1385     0002    common_test_id_match__total__bytes equ 2
1386     0024    common_test_id_match__desired equ common_test_id_match__bytes__base+0
1387     0025    common_test_id_match__test_number equ common_test_id_match__bytes__base+1
1388                     ; This procedure will verify that the next byte in the id is < desired > .
1389                     ; if { desired != common_test_id_next {{ }} } start
1390 249 2269            call common_test_id_next
1391 24a 0828            movf common_test_id_next__0return__byte,w
1392 24b 0224            subwf common_test_id_match__desired,w
1393                     ; expression=`{ desired != common_test_id_next {{ }} }' exp_delay=1 true_delay=3  false_delay=0 true_size=5 false_size=0
1394 24c 1903            btfsc z___byte,z___bit
1395 24d 2a53            goto label577__0end
1396                     ; if { desired != common_test_id_next {{ }} } body start
1397                     ;   call master_fail {{ common_string , test_number }}  
1398 24e 3017            movlw LOW common_string+1
1399 24f 00ac            movwf master_fail__test_name
1400 250 0825            movf common_test_id_match__test_number,w
1401 251 00ad            movwf master_fail__test_number
1402 252 22e8            call master_fail
1403                     ; if { desired != common_test_id_next {{ }} } body end
1404             label577__0end:
1405                     ; if exp=` desired != common_test_id_next ## {{ }} ' empty false
1406                     ; Other expression=`{ desired != common_test_id_next {{ }} }' delay=-1
1407                     ; if { desired != common_test_id_next {{ }} } end
1408                     ; procedure common_test_id_match end
1409 253 3400            retlw 0
1410             
1411                     ; procedure common_test_id_bytes8 start
1412             common_test_id_bytes8:
1413     0026    common_test_id_bytes8__variables__base equ global__variables__bank0+26
1414     0026    common_test_id_bytes8__bytes__base equ common_test_id_bytes8__variables__base+0
1415     0027    common_test_id_bytes8__bits__base equ common_test_id_bytes8__variables__base+1
1416     0001    common_test_id_bytes8__total__bytes equ 1
1417                     ;   arguments_none  
1418                     ; This procedure will print out the next 8 bytes of the id in octal .
1419     0026    common_test_id_bytes8__count equ common_test_id_bytes8__bytes__base+0
1420                     ; `count_down count 8 ...' start
1421 254 3008            movlw 8
1422 255 00a6            movwf common_test_id_bytes8__count
1423             common_test_id_bytes8__590_loop:
1424                     ;   call master_octal {{ common_test_id_next {{ }} }}  
1425 256 2269            call common_test_id_next
1426 257 0828            movf common_test_id_next__0return__byte,w
1427 258 00af            movwf master_octal__number
1428 259 22f9            call master_octal
1429 25a 0ba6            decfsz common_test_id_bytes8__count,f
1430 25b 2a56            goto common_test_id_bytes8__590_loop
1431             common_test_id_bytes8__590_done:
1432                     ; `count_down count 8 ...' end
1433                     ;   call master_crlf {{ }}  
1434 25c 22e1            call master_crlf
1435                     ; procedure common_test_id_bytes8 end
1436 25d 3400            retlw 0
1437             
1438                     ; procedure common_test_id_string start
1439             common_test_id_string:
1440     0027    common_test_id_string__variables__base equ global__variables__bank0+27
1441     0027    common_test_id_string__bytes__base equ common_test_id_string__variables__base+0
1442     0028    common_test_id_string__bits__base equ common_test_id_string__variables__base+1
1443     0001    common_test_id_string__total__bytes equ 1
1444                     ;   arguments_none  
1445                     ; This procedure will print out the next id string .
1446     0027    common_test_id_string__count equ common_test_id_string__bytes__base+0
1447                     ; `count_down count  common_test_id_next ## {{ }}  ...' start
1448 25e 2269            call common_test_id_next
1449 25f 0828            movf common_test_id_next__0return__byte,w
1450 260 00a7            movwf common_test_id_string__count
1451             common_test_id_string__604_loop:
1452                     ;   call master_send {{ common_test_id_next {{ }} }}  
1453 261 2269            call common_test_id_next
1454 262 0828            movf common_test_id_next__0return__byte,w
1455 263 00bb            movwf master_send__character
1456 264 235e            call master_send
1457 265 0ba7            decfsz common_test_id_string__count,f
1458 266 2a61            goto common_test_id_string__604_loop
1459             common_test_id_string__604_done:
1460                     ; `count_down count  common_test_id_next ## {{ }}  ...' end
1461                     ;   call master_crlf {{ }}  
1462 267 22e1            call master_crlf
1463                     ; procedure common_test_id_string end
1464 268 3400            retlw 0
1465             
1466                     ; procedure common_test_id_next start
1467             common_test_id_next:
1468     0028    common_test_id_next__variables__base equ global__variables__bank0+28
1469     0028    common_test_id_next__bytes__base equ common_test_id_next__variables__base+0
1470     0029    common_test_id_next__bits__base equ common_test_id_next__variables__base+1
1471     0001    common_test_id_next__total__bytes equ 1
1472                     ;   arguments_none  
1473     0028    common_test_id_next__0return__byte equ common_test_id_next__bytes__base+0
1474                     ; This procedure returns the next byte from the identification string .
1475                     ;   call slave_send {{ 0xfc }}  
1476 269 30fc            movlw 252
1477 26a 00b2            movwf slave_send__data
1478 26b 2318            call slave_send
1479                     ;   return slave_get {{ }}  
1480 26c 2312            call slave_get
1481 26d 0831            movf slave_get__0return__byte,w
1482 26e 00a8            movwf common_test_id_next__0return__byte
1483 26f 3400            retlw 0
1484                     ; procedure common_test_id_next end
1485                     ; comment {The procedures below are used to test the shared interrupt commands :}
1486             
1487                     ; procedure interrupt_test start
1488             interrupt_test:
1489     0029    interrupt_test__variables__base equ global__variables__bank0+29
1490     0029    interrupt_test__bytes__base equ interrupt_test__variables__base+0
1491     002a    interrupt_test__bits__base equ interrupt_test__variables__base+1
1492     0001    interrupt_test__total__bytes equ 1
1493                     ;   arguments_none  
1494                     ; This procedure tests the common shared interrupt commands .
1495     0029    interrupt_test__counter equ interrupt_test__bytes__base+0
1496                     ; Clear interrupt bits :
1497                     ;   call slave_send {{ 0xf0 }}  
1498 270 30f0            movlw 240
1499 271 00b2            movwf slave_send__data
1500 272 2318            call slave_send
1501                     ;   call interrupt_read {{ 0 , 0xd0 }}  
1502 273 01aa            clrf interrupt_read__desired
1503 274 30d0            movlw 208
1504 275 00ab            movwf interrupt_read__test_number
1505 276 22cf            call interrupt_read
1506                     ; Set / clear interrupt pending bit only :
1507                     ;   call slave_send {{ 0xf5 }}  
1508 277 30f5            movlw 245
1509 278 00b2            movwf slave_send__data
1510 279 2318            call slave_send
1511                     ;   call interrupt_read {{ 1 , 0xd1 }}  
1512 27a 3001            movlw 1
1513 27b 00aa            movwf interrupt_read__desired
1514 27c 30d1            movlw 209
1515 27d 00ab            movwf interrupt_read__test_number
1516 27e 22cf            call interrupt_read
1517                     ;   call slave_send {{ 0xf4 }}  
1518 27f 30f4            movlw 244
1519 280 00b2            movwf slave_send__data
1520 281 2318            call slave_send
1521                     ;   call interrupt_read {{ 0 , 0xd2 }}  
1522 282 01aa            clrf interrupt_read__desired
1523 283 30d2            movlw 210
1524 284 00ab            movwf interrupt_read__test_number
1525 285 22cf            call interrupt_read
1526                     ;   call slave_send {{ 0xf1 }}  
1527 286 30f1            movlw 241
1528 287 00b2            movwf slave_send__data
1529 288 2318            call slave_send
1530                     ;   call interrupt_read {{ 1 , 0xd3 }}  
1531 289 3001            movlw 1
1532 28a 00aa            movwf interrupt_read__desired
1533 28b 30d3            movlw 211
1534 28c 00ab            movwf interrupt_read__test_number
1535 28d 22cf            call interrupt_read
1536                     ;   call slave_send {{ 0xf0 }}  
1537 28e 30f0            movlw 240
1538 28f 00b2            movwf slave_send__data
1539 290 2318            call slave_send
1540                     ;   call interrupt_read {{ 0 , 0xd4 }}  
1541 291 01aa            clrf interrupt_read__desired
1542 292 30d4            movlw 212
1543 293 00ab            movwf interrupt_read__test_number
1544 294 22cf            call interrupt_read
1545                     ; Set / clear interrupt enable bit only :
1546                     ;   call slave_send {{ 0xf7 }}  
1547 295 30f7            movlw 247
1548 296 00b2            movwf slave_send__data
1549 297 2318            call slave_send
1550                     ;   call interrupt_read {{ 2 , 0xd5 }}  
1551 298 3002            movlw 2
1552 299 00aa            movwf interrupt_read__desired
1553 29a 30d5            movlw 213
1554 29b 00ab            movwf interrupt_read__test_number
1555 29c 22cf            call interrupt_read
1556                     ;   call slave_send {{ 0xf6 }}  
1557 29d 30f6            movlw 246
1558 29e 00b2            movwf slave_send__data
1559 29f 2318            call slave_send
1560                     ;   call interrupt_read {{ 0 , 0xd6 }}  
1561 2a0 01aa            clrf interrupt_read__desired
1562 2a1 30d6            movlw 214
1563 2a2 00ab            movwf interrupt_read__test_number
1564 2a3 22cf            call interrupt_read
1565                     ;   call slave_send {{ 0xf2 }}  
1566 2a4 30f2            movlw 242
1567 2a5 00b2            movwf slave_send__data
1568 2a6 2318            call slave_send
1569                     ;   call interrupt_read {{ 2 , 0xd7 }}  
1570 2a7 3002            movlw 2
1571 2a8 00aa            movwf interrupt_read__desired
1572 2a9 30d7            movlw 215
1573 2aa 00ab            movwf interrupt_read__test_number
1574 2ab 22cf            call interrupt_read
1575                     ;   call slave_send {{ 0xf0 }}  
1576 2ac 30f0            movlw 240
1577 2ad 00b2            movwf slave_send__data
1578 2ae 2318            call slave_send
1579                     ;   call interrupt_read {{ 0 , 0xd8 }}  
1580 2af 01aa            clrf interrupt_read__desired
1581 2b0 30d8            movlw 216
1582 2b1 00ab            movwf interrupt_read__test_number
1583 2b2 22cf            call interrupt_read
1584                     ; Now set both the interrupt enable and pending bit .
1585                     ; This must trigger an interrupt .
1586                     ;   call slave_send {{ 0xf3 }}  
1587 2b3 30f3            movlw 243
1588 2b4 00b2            movwf slave_send__data
1589 2b5 2318            call slave_send
1590                     ; `count_down counter 3 ...' start
1591 2b6 3003            movlw 3
1592 2b7 00a9            movwf interrupt_test__counter
1593             interrupt_test__658_loop:
1594                     ;   call delay {{ }}  
1595 2b8 2377            call delay
1596 2b9 0ba9            decfsz interrupt_test__counter,f
1597 2ba 2ab8            goto interrupt_test__658_loop
1598             interrupt_test__658_done:
1599                     ; `count_down counter 3 ...' end
1600                     ; if { rx_slave_pin } start
1601                     ; expression=`{ rx_slave_pin }' exp_delay=0 true_delay=3  false_delay=0 true_size=5 false_size=0
1602 2bb 1c05            btfss rx_slave_pin__byte,rx_slave_pin__bit
1603 2bc 2ac2            goto label661__0end
1604                     ; if { rx_slave_pin } body start
1605                     ; No interrupt detected :
1606                     ;   call master_fail {{ interrupt_string , 0xd9 }}  
1607 2bd 3038            movlw LOW interrupt_string+1
1608 2be 00ac            movwf master_fail__test_name
1609 2bf 30d9            movlw 217
1610 2c0 00ad            movwf master_fail__test_number
1611 2c1 22e8            call master_fail
1612                     ; if { rx_slave_pin } body end
1613             label661__0end:
1614                     ; if exp=`rx_slave_pin' empty false
1615                     ; Other expression=`{ rx_slave_pin }' delay=-1
1616                     ; if { rx_slave_pin } end
1617                     ; Read the interrupt enable bit is cleared as a side effect
1618                     ; of reading the bit .
1619                     ;   call interrupt_read {{ 1 , 0xda }}  
1620 2c2 3001            movlw 1
1621 2c3 00aa            movwf interrupt_read__desired
1622 2c4 30da            movlw 218
1623 2c5 00ab            movwf interrupt_read__test_number
1624 2c6 22cf            call interrupt_read
1625                     ; Clear the interrupt pending bit :
1626                     ;   call slave_send {{ 0xf0 }}  
1627 2c7 30f0            movlw 240
1628 2c8 00b2            movwf slave_send__data
1629 2c9 2318            call slave_send
1630                     ;   call interrupt_read {{ 0 , 0xdb }}  
1631 2ca 01aa            clrf interrupt_read__desired
1632 2cb 30db            movlw 219
1633 2cc 00ab            movwf interrupt_read__test_number
1634 2cd 22cf            call interrupt_read
1635                     ; procedure interrupt_test end
1636 2ce 3400            retlw 0
1637             
1638                     ; procedure interrupt_read start
1639             interrupt_read:
1640     002a    interrupt_read__variables__base equ global__variables__bank0+30
1641     002a    interrupt_read__bytes__base equ interrupt_read__variables__base+0
1642     002c    interrupt_read__bits__base equ interrupt_read__variables__base+2
1643     0002    interrupt_read__total__bytes equ 2
1644     002a    interrupt_read__desired equ interrupt_read__bytes__base+0
1645     002b    interrupt_read__test_number equ interrupt_read__bytes__base+1
1646                     ; This procedure will verify that the interrupt bits match < desired > .
1647                     ;   call slave_send {{ 0xef }}  
1648 2cf 30ef            movlw 239
1649 2d0 00b2            movwf slave_send__data
1650 2d1 2318            call slave_send
1651                     ;   temp := slave_get {{ }}  
1652 2d2 2312            call slave_get
1653 2d3 0831            movf slave_get__0return__byte,w
1654 2d4 008c            movwf temp
1655                     ; if { temp != desired } start
1656 2d5 022a            subwf interrupt_read__desired,w
1657                     ; expression=`{ temp != desired }' exp_delay=2 true_delay=4  false_delay=0 true_size=8 false_size=0
1658 2d6 1903            btfsc z___byte,z___bit
1659 2d7 2ae0            goto label683__0end
1660                     ; if { temp != desired } body start
1661                     ;   call master_octal {{ temp }}  
1662 2d8 080c            movf temp,w
1663 2d9 00af            movwf master_octal__number
1664 2da 22f9            call master_octal
1665                     ;   call master_fail {{ interrupt_string , test_number }}  
1666 2db 3038            movlw LOW interrupt_string+1
1667 2dc 00ac            movwf master_fail__test_name
1668 2dd 082b            movf interrupt_read__test_number,w
1669 2de 00ad            movwf master_fail__test_number
1670 2df 22e8            call master_fail
1671                     ; if { temp != desired } body end
1672             label683__0end:
1673                     ; if exp=` temp != desired ' empty false
1674                     ; Other expression=`{ temp != desired }' delay=-1
1675                     ; if { temp != desired } end
1676                     ; procedure interrupt_read end
1677 2e0 3400            retlw 0
1678                     ; comment {The following procedures are used to communicate with the master :}
1679             
1680                     ; procedure master_crlf start
1681             master_crlf:
1682     002c    master_crlf__variables__base equ global__variables__bank0+32
1683     002c    master_crlf__bytes__base equ master_crlf__variables__base+0
1684     002c    master_crlf__bits__base equ master_crlf__variables__base+0
1685     0000    master_crlf__total__bytes equ 0
1686                     ;   arguments_none  
1687                     ; This procedure will output a carriage - return line - feed
1688                     ; to the master .
1689                     ;   call master_send {{ cr }}  
1690 2e1 300d            movlw 13
1691 2e2 00bb            movwf master_send__character
1692 2e3 235e            call master_send
1693                     ;   call master_send {{ lf }}  
1694 2e4 300a            movlw 10
1695 2e5 00bb            movwf master_send__character
1696 2e6 235e            call master_send
1697                     ; procedure master_crlf end
1698 2e7 3400            retlw 0
1699             
1700                     ; procedure master_fail start
1701             master_fail:
1702     002c    master_fail__variables__base equ global__variables__bank0+32
1703     002c    master_fail__bytes__base equ master_fail__variables__base+0
1704     002e    master_fail__bits__base equ master_fail__variables__base+2
1705     0002    master_fail__total__bytes equ 2
1706     002c    master_fail__test_name equ master_fail__bytes__base+0
1707     002d    master_fail__test_number equ master_fail__bytes__base+1
1708                     ; This procedure will output ` fail ' followed by a carriage return
1709                     ; and line feed .
1710                     ;   call master_string {{ fail_string }}  
1711 2e8 3025            movlw LOW fail_string+1
1712 2e9 00bc            movwf master_string__message
1713 2ea 2364            call master_string
1714                     ;   call master_string {{ test_name }}  
1715 2eb 082c            movf master_fail__test_name,w
1716 2ec 00bc            movwf master_string__message
1717 2ed 2364            call master_string
1718                     ;   call master_octal {{ test_number }}  
1719 2ee 082d            movf master_fail__test_number,w
1720 2ef 00af            movwf master_octal__number
1721 2f0 22f9            call master_octal
1722                     ;   call master_crlf {{ }}  
1723 2f1 22e1            call master_crlf
1724                     ; procedure master_fail end
1725 2f2 3400            retlw 0
1726             
1727                     ; procedure master_get start
1728             master_get:
1729     002e    master_get__variables__base equ global__variables__bank0+34
1730     002e    master_get__bytes__base equ master_get__variables__base+0
1731     002f    master_get__bits__base equ master_get__variables__base+1
1732     0001    master_get__total__bytes equ 1
1733                     ;   arguments_none  
1734     002e    master_get__0return__byte equ master_get__bytes__base+0
1735                     ; This procedure will get the next byte or return 0xfc if
1736                     ; no byte is forthcoming .
1737                     ;   return get_byte {{ rx_master_mask }}  
1738 2f3 3008            movlw 8
1739 2f4 00b3            movwf get_byte__mask
1740 2f5 231e            call get_byte
1741 2f6 0834            movf get_byte__0return__byte,w
1742 2f7 00ae            movwf master_get__0return__byte
1743 2f8 3400            retlw 0
1744                     ; procedure master_get end
1745             
1746                     ; procedure master_octal start
1747             master_octal:
1748     002f    master_octal__variables__base equ global__variables__bank0+35
1749     002f    master_octal__bytes__base equ master_octal__variables__base+0
1750     0031    master_octal__bits__base equ master_octal__variables__base+2
1751     0002    master_octal__total__bytes equ 2
1752     0030    master_octal__733byte0 equ master_octal__bytes__base+1
1753     0030    master_octal__734byte0 equ master_octal__bytes__base+1
1754     002f    master_octal__number equ master_octal__bytes__base+0
1755                     ; This procedure will output < number > in octal to the tx port .
1756                     ; Output the character in octal :
1757                     ;   call master_send {{ {{ number >> 6 }} + 0c'0' }}  
1758 2f9 0e2f            swapf master_octal__number,w
1759 2fa 00b0            movwf master_octal__733byte0
1760 2fb 0cb0            rrf master_octal__733byte0,f
1761 2fc 0c30            rrf master_octal__733byte0,w
1762 2fd 3903            andlw 3
1763 2fe 3e30            addlw 48
1764 2ff 00bb            movwf master_send__character
1765 300 235e            call master_send
1766                     ;   call master_send {{ {{ {{ number >> 3 }} & 7 }} + 0c'0' }}  
1767 301 0c2f            rrf master_octal__number,w
1768 302 00b0            movwf master_octal__734byte0
1769 303 0cb0            rrf master_octal__734byte0,f
1770 304 0c30            rrf master_octal__734byte0,w
1771 305 3907            andlw 7
1772 306 3e30            addlw 48
1773 307 00bb            movwf master_send__character
1774 308 235e            call master_send
1775                     ;   call master_send {{ {{ number & 7 }} + 0c'0' }}  
1776 309 3007            movlw 7
1777 30a 052f            andwf master_octal__number,w
1778 30b 3e30            addlw 48
1779 30c 00bb            movwf master_send__character
1780 30d 235e            call master_send
1781                     ;   call master_send {{ sp }}  
1782 30e 3020            movlw 32
1783 30f 00bb            movwf master_send__character
1784 310 235e            call master_send
1785                     ; procedure master_octal end
1786 311 3400            retlw 0
1787             
1788                     ; procedure slave_get start
1789             slave_get:
1790     0031    slave_get__variables__base equ global__variables__bank0+37
1791     0031    slave_get__bytes__base equ slave_get__variables__base+0
1792     0032    slave_get__bits__base equ slave_get__variables__base+1
1793     0001    slave_get__total__bytes equ 1
1794                     ;   arguments_none  
1795     0031    slave_get__0return__byte equ slave_get__bytes__base+0
1796                     ; This procedure will get a byte from the slave or return 0xfc
1797                     ; if no byte is forthcoming .
1798                     ;   return get_byte {{ rx_slave_mask }}  
1799 312 3001            movlw 1
1800 313 00b3            movwf get_byte__mask
1801 314 231e            call get_byte
1802 315 0834            movf get_byte__0return__byte,w
1803 316 00b1            movwf slave_get__0return__byte
1804 317 3400            retlw 0
1805                     ; procedure slave_get end
1806             
1807                     ; procedure slave_send start
1808             slave_send:
1809     0032    slave_send__variables__base equ global__variables__bank0+38
1810     0032    slave_send__bytes__base equ slave_send__variables__base+0
1811     0033    slave_send__bits__base equ slave_send__variables__base+1
1812     0001    slave_send__total__bytes equ 1
1813     0032    slave_send__data equ slave_send__bytes__base+0
1814                     ; This procedure will send one byte of < data > to the slave .
1815                     ;   call send_byte {{ data , tx_slave_mask }}  
1816 318 0832            movf slave_send__data,w
1817 319 00b7            movwf send_byte__char
1818 31a 3002            movlw 2
1819 31b 00b8            movwf send_byte__mask
1820 31c 2343            call send_byte
1821                     ; procedure slave_send end
1822 31d 3400            retlw 0
1823                     ; comment {The last procedures do character sending and receiving :}
1824             
1825                     ; procedure get_byte start
1826             get_byte:
1827     0033    get_byte__variables__base equ global__variables__bank0+39
1828     0033    get_byte__bytes__base equ get_byte__variables__base+0
1829     0037    get_byte__bits__base equ get_byte__variables__base+4
1830     0004    get_byte__total__bytes equ 4
1831     0033    get_byte__mask equ get_byte__bytes__base+0
1832     0034    get_byte__0return__byte equ get_byte__bytes__base+1
1833                     ; Get an 8 - bit byte from < mask > bit of < porta > and return it .
1834                     ; If no character shows up in a while 0xfc is returned .
1835     0035    get_byte__count equ get_byte__bytes__base+2
1836     0036    get_byte__char equ get_byte__bytes__base+3
1837                     ; Wait until a start bit arrives :
1838                     ;   count := 0  
1839 31e 01b5            clrf get_byte__count
1840                     ; `while  porta & mask != 0  ...' start
1841             get_byte__772while__continue:
1842 31f 0805            movf porta,w
1843 320 0533            andwf get_byte__mask,w
1844                     ; expression=` porta & mask != 0 ' exp_delay=2 true_delay=1  false_delay=2 true_size=9 false_size=1
1845 321 1903            btfsc z___byte,z___bit
1846 322 2b2c            goto get_byte__772while__break
1847                     ;   count := count - 1  
1848 323 03b5            decf get_byte__count,f
1849                     ; if { count = 0 } start
1850 324 0835            movf get_byte__count,w
1851                     ; expression=`{ count = 0 }' exp_delay=1 true_delay=3  false_delay=0 true_size=3 false_size=0
1852 325 1d03            btfss z___byte,z___bit
1853 326 2b2a            goto label774__0end
1854                     ; if { count = 0 } body start
1855                     ;   return 0xfc  
1856 327 30fc            movlw 252
1857 328 00b4            movwf get_byte__0return__byte
1858 329 3400            retlw 0
1859                     ; if { count = 0 } body end
1860             label774__0end:
1861                     ; if exp=` count = 0 ' empty false
1862                     ; Other expression=`{ count = 0 }' delay=-1
1863                     ; if { count = 0 } end
1864                     ;   call delay {{ }}  
1865 32a 2377            call delay
1866 32b 2b1f            goto get_byte__772while__continue
1867                     ; if exp=` porta & mask != 0 ' false goto
1868                     ; Other expression=` porta & mask != 0 ' delay=-1
1869             get_byte__772while__break:
1870                     ; `while  porta & mask != 0  ...' end
1871                     ; Skip over the start bit :
1872                     ;   call delay {{ }}  
1873 32c 2377            call delay
1874                     ;   call delay {{ }}  
1875 32d 2377            call delay
1876                     ;   call delay {{ }}  
1877 32e 2377            call delay
1878                     ; Sample in the middle third of each data bit :
1879                     ;   char := 0  
1880 32f 01b6            clrf get_byte__char
1881                     ; `count_down count 8 ...' start
1882 330 3008            movlw 8
1883 331 00b5            movwf get_byte__count
1884             get_byte__787_loop:
1885                     ;   call delay {{ }}  
1886 332 2377            call delay
1887                     ;   char := char >> 1  
1888 333 1003            bcf c___byte,c___bit
1889 334 0cb6            rrf get_byte__char,f
1890                     ; if { porta & mask != 0 } start
1891 335 0805            movf porta,w
1892 336 0533            andwf get_byte__mask,w
1893                     ; expression=`{ porta & mask != 0 }' exp_delay=2 true_delay=2  false_delay=0 true_size=2 false_size=0
1894 337 1903            btfsc z___byte,z___bit
1895 338 2b3b            goto label790__0end
1896                     ; if { porta & mask != 0 } body start
1897                     ;   char := char | 0x80  
1898 339 3080            movlw 128
1899 33a 04b6            iorwf get_byte__char,f
1900                     ; if { porta & mask != 0 } body end
1901             label790__0end:
1902                     ; if exp=` porta & mask != 0 ' empty false
1903                     ; Other expression=`{ porta & mask != 0 }' delay=-1
1904                     ; if { porta & mask != 0 } end
1905                     ;   call delay {{ }}  
1906 33b 2377            call delay
1907                     ;   call delay {{ }}  
1908 33c 2377            call delay
1909 33d 0bb5            decfsz get_byte__count,f
1910 33e 2b32            goto get_byte__787_loop
1911             get_byte__787_done:
1912                     ; `count_down count 8 ...' end
1913                     ; Skip over 1 / 3 of the stop bit :
1914                     ;   call delay {{ }}  
1915 33f 2377            call delay
1916                     ;   return char  
1917 340 0836            movf get_byte__char,w
1918 341 00b4            movwf get_byte__0return__byte
1919 342 3400            retlw 0
1920                     ; procedure get_byte end
1921             
1922                     ; procedure send_byte start
1923             send_byte:
1924     0037    send_byte__variables__base equ global__variables__bank0+43
1925     0037    send_byte__bytes__base equ send_byte__variables__base+0
1926     003b    send_byte__bits__base equ send_byte__variables__base+4
1927     0004    send_byte__total__bytes equ 4
1928     0037    send_byte__char equ send_byte__bytes__base+0
1929     0038    send_byte__mask equ send_byte__bytes__base+1
1930                     ; Send < char > to < mask > bit of < porta > .
1931     0039    send_byte__count equ send_byte__bytes__base+2
1932     003a    send_byte__mark equ send_byte__bytes__base+3
1933                     ; Send the start bit :
1934                     ;   mark := mask ^ space  
1935 343 30ff            movlw 255
1936 344 0638            xorwf send_byte__mask,w
1937 345 00ba            movwf send_byte__mark
1938                     ;   porta := mark  
1939 346 0085            movwf porta
1940                     ;   call delay {{ }}  
1941 347 2377            call delay
1942                     ;   call delay {{ }}  
1943 348 2377            call delay
1944                     ;   call delay {{ }}  
1945 349 2377            call delay
1946                     ; Send the data :
1947                     ; `count_down count 8 ...' start
1948 34a 3008            movlw 8
1949 34b 00b9            movwf send_byte__count
1950             send_byte__822_loop:
1951                     ; if { char @ 0 } start
1952                     ; Alias variable for select char @ 0
1953     0037    send_byte__char__823select0 equ send_byte__char+0
1954     0037    send_byte__char__823select0__byte equ send_byte__char+0
1955     0000    send_byte__char__823select0__bit equ 0
1956                     ; expression=`{ char @ 0 }' exp_delay=0 true_delay=1  false_delay=1 true_size=1 false_size=1
1957 34c 1837            btfsc send_byte__char__823select0__byte,send_byte__char__823select0__bit
1958                     ; if { char @ 0 } body start
1959                     ;   porta := space  
1960 34d 30ff            movlw 255
1961                     ; 1 instructions found for sharing
1962 34e 1c37            btfss send_byte__char__823select0__byte,send_byte__char__823select0__bit
1963                     ; else body start
1964                     ;   porta := mark  
1965 34f 083a            movf send_byte__mark,w
1966                     ; 1 instructions found for sharing
1967                     ; if exp=` char @ 0 ' single true and false skip delay=4
1968                     ; Other expression=`{ char @ 0 }' delay=4
1969                     ; 1 shared instructions follow
1970 350 0085            movwf porta
1971                     ; if { char @ 0 } end
1972                     ;   char := char >> 1  
1973 351 1003            bcf c___byte,c___bit
1974 352 0cb7            rrf send_byte__char,f
1975                     ;   call delay {{ }}  
1976 353 2377            call delay
1977                     ;   call delay {{ }}  
1978 354 2377            call delay
1979                     ;   call delay {{ }}  
1980 355 2377            call delay
1981 356 0bb9            decfsz send_byte__count,f
1982 357 2b4c            goto send_byte__822_loop
1983             send_byte__822_done:
1984                     ; `count_down count 8 ...' end
1985                     ; Send the stop bit :
1986                     ;   porta := space  
1987 358 30ff            movlw 255
1988 359 0085            movwf porta
1989                     ;   call delay {{ }}  
1990 35a 2377            call delay
1991                     ;   call delay {{ }}  
1992 35b 2377            call delay
1993                     ;   call delay {{ }}  
1994 35c 2377            call delay
1995                     ; procedure send_byte end
1996 35d 3400            retlw 0
1997             
1998                     ; procedure master_send start
1999             master_send:
2000     003b    master_send__variables__base equ global__variables__bank0+47
2001     003b    master_send__bytes__base equ master_send__variables__base+0
2002     003c    master_send__bits__base equ master_send__variables__base+1
2003     0001    master_send__total__bytes equ 1
2004     003b    master_send__character equ master_send__bytes__base+0
2005                     ; This procedure will output < character > to the master .
2006                     ;   call send_byte {{ character , tx_master_mask }}  
2007 35e 083b            movf master_send__character,w
2008 35f 00b7            movwf send_byte__char
2009 360 3004            movlw 4
2010 361 00b8            movwf send_byte__mask
2011 362 2343            call send_byte
2012                     ; procedure master_send end
2013 363 3400            retlw 0
2014             
2015                     ; procedure master_string start
2016             master_string:
2017     003c    master_string__variables__base equ global__variables__bank0+48
2018     003c    master_string__bytes__base equ master_string__variables__base+0
2019     003f    master_string__bits__base equ master_string__variables__base+3
2020     0003    master_string__total__bytes equ 3
2021     003c    master_string__message equ master_string__bytes__base+0
2022                     ; This procedure will output < message > to the master .
2023     003d    master_string__size equ master_string__bytes__base+1
2024     003e    master_string__index equ master_string__bytes__base+2
2025                     ;   index := 0  
2026 364 01be            clrf master_string__index
2027                     ; `while  index < message . size  ...' start
2028             master_string__860while__continue:
2029 365 018a            clrf pclath___register
2030 366 083c            movf master_string__message,w
2031 367 200b            call string___fetch
2032 368 023e            subwf master_string__index,w
2033                     ; expression=` index < message . size ' exp_delay=4 true_delay=7  false_delay=2 true_size=8 false_size=1
2034 369 1803            btfsc c___byte,c___bit
2035 36a 2b73            goto master_string__860while__break
2036                     ;   call master_send {{ message ~~ {{ index }} }}  
2037 36b 0a3e            incf master_string__index,w
2038 36c 073c            addwf master_string__message,w
2039 36d 018a            clrf pclath___register
2040 36e 200b            call string___fetch
2041 36f 00bb            movwf master_send__character
2042 370 235e            call master_send
2043                     ;   index := index + 1  
2044 371 0abe            incf master_string__index,f
2045 372 2b65            goto master_string__860while__continue
2046                     ; if exp=` index < message . size ' false goto
2047                     ; Other expression=` index < message . size ' delay=-1
2048             master_string__860while__break:
2049                     ; `while  index < message . size  ...' end
2050                     ;   call master_send {{ sp }}  
2051 373 3020            movlw 32
2052 374 00bb            movwf master_send__character
2053 375 235e            call master_send
2054                     ; procedure master_string end
2055 376 3400            retlw 0
2056             
2057                     ; procedure delay start
2058                     ; optimize 0
2059             delay:
2060     003f    delay__variables__base equ global__variables__bank0+51
2061     003f    delay__bytes__base equ delay__variables__base+0
2062     0040    delay__bits__base equ delay__variables__base+1
2063     0001    delay__total__bytes equ 1
2064     003f    delay__867byte1 equ delay__bytes__base+0
2065                     ;   arguments_none  
2066                     ;   uniform_delay instructions_per_delay  
2067                     ; Uniform delay remaining = 134 Accumulated Delay = 0
2068                     ; Uniform delay remaining = 134 Accumulated Delay = 0
2069                     ; Delay 1 third of a bit :
2070                     ; Uniform delay remaining = 134 Accumulated Delay = 0
2071                     ;   watch_dog_reset  
2072 377 0064            clrwdt
2073                     ; Uniform delay remaining = 133 Accumulated Delay = 1
2074                     ; Uniform delay remaining = 133 Accumulated Delay = 1
2075                     ; Soak up remaining 133 cycles
2076                     ; Delay 133 cycles
2077 378 302c            movlw 44
2078 379 00bf            movwf delay__867byte1
2079             delay__867delay0:
2080 37a 0bbf            decfsz delay__867byte1,f
2081 37b 2b7a            goto delay__867delay0
2082                     ; procedure delay end
2083 37c 3400            retlw 0
2084                     ; optimize 1
2085             
2086                     ; Register bank 0 used 52 bytes of 68 available bytes
2087                     ; Register bank 1 used 0 bytes of 0 available bytes
2088             
2089                     end

