  1                     radix dec
  2     0020    global__variables__bank0 equ 32
  3     00a0    global__variables__bank1 equ 160
  4     0120    global__variables__bank2 equ 288
  5     01f0    global__variables__bank3 equ 496
  6     0045    global__bit__variables__bank0 equ 69
  7     00a0    global__bit__variables__bank1 equ 160
  8     0120    global__bit__variables__bank2 equ 288
  9     01f0    global__bit__variables__bank3 equ 496
 10     0000    indf___register equ 0
 11     0002    pcl___register equ 2
 12     0003    c___byte equ 3
 13     0000    c___bit equ 0
 14     0003    z___byte equ 3
 15     0002    z___bit equ 2
 16     0003    rp0___byte equ 3
 17     0005    rp0___bit equ 5
 18     0003    rp1___byte equ 3
 19     0006    rp1___bit equ 6
 20     0003    irp___byte equ 3
 21     0007    irp___bit equ 7
 22     0085    trisa___register equ 0x85
 23     0086    trisb___register equ 0x86
 24     0004    fsr___register equ 4
 25     000a    pclath___register equ 10
 26                     org 0
 27             start:
 28 000 0000            nop
 29 001 0000            nop
 30 002 0000            nop
 31 003 2805            goto skip___interrupt
 32             interrupt___vector:
 33 004 0009            retfie
 34             skip___interrupt:
 35                     ; Initialize A/D system to allow digital I/O
 36 005 3007            movlw 7
 37 006 009f            movwf 31
 38                     ; Switch from register bank 0 to register bank 1 (which contains 159)
 39 007 1683            bsf rp0___byte,rp0___bit
 40                     ; Register bank is now 1
 41 008 019f            clrf 159
 42                     ; Initialize TRIS registers
 43 009 30eb            movlw 235
 44 00a 0086            movwf trisb___register
 45 00b 018a            clrf pclath___register
 46                     ; Switch from register bank 1 to register bank 0
 47 00c 1283            bcf rp0___byte,rp0___bit
 48                     ; Register bank is now 0
 49 00d 281c            goto main
 50                     ; comment #############################################################################
 51                     ; comment {}
 52                     ; comment {Copyright < c > 1999 - 2001 by Wayne C . Gramlich .}
 53                     ; comment {All rights reserved .}
 54                     ; comment {}
 55                     ; comment {Permission to use , copy , modify , distribute , and sell this software}
 56                     ; comment {for any purpose is hereby granted without fee provided that the above}
 57                     ; comment {copyright notice and this permission are retained . The author makes}
 58                     ; comment {no representations about the suitability of this software for any purpose .}
 59                     ; comment {It is provided { as is } without express or implied warranty .}
 60                     ; comment {}
 61                     ; comment {This is a test harness for developing Robobricks . Basically it allows}
 62                     ; comment {the user to type in an 8 - bit number in octal and send it to a RoboBrick .}
 63                     ; comment {Any resulting data is read back and printed in octal . All communication}
 64                     ; comment {occurs at 2400 baud . See}
 65                     ; comment {}
 66                     ; comment {http : / / web . gramlich . net / projects / robobricks / harness / index . html}
 67                     ; comment {}
 68                     ; comment {for more details .}
 69                     ; comment {}
 70                     ; comment #############################################################################
 71                     ;   processor pic16f628 cp = off cpd = off lvp = off bowden = off mclre = on pwrte = off wdte = off fosc = xt  
 72                     ; 16169=0x3f29 8199=0x2007
 73                     __config 16169
 74     2007    configuration___address equ 8199
 75                     ; comment {processor pic16f84 cp = off dp = off pwrte = disabled wdte = disabled fosc = xt}
 76                     ; comment {Some timing constants :}
 77                     ;   constant clock_rate 10000000  
 78     989680    clock_rate equ 10000000
 79                     ;   constant clock_ticks_per_instruction 4  
 80     0004    clock_ticks_per_instruction equ 4
 81                     ;   constant instructions_per_second clock_rate / clock_ticks_per_instruction  
 82     2625a0    instructions_per_second equ 2500000
 83                     ;   constant baud_rate 2400  
 84     0960    baud_rate equ 2400
 85                     ;   constant instructions_per_bit clock_rate / {{ clock_ticks_per_instruction * baud_rate }}  
 86     0411    instructions_per_bit equ 1041
 87                     ;   constant delays_per_bit 3  
 88     0003    delays_per_bit equ 3
 89                     ;   constant instructions_per_delay instructions_per_bit / delays_per_bit  
 90     015b    instructions_per_delay equ 347
 91                     ; comment {The null pulse that comes back from a clock pulse command is supposed to be}
 92                     ; comment {exactly 9 bits long . 9 bits at 2400 baud is 9 / 2400 = 3 . 75 mS . The number}
 93                     ; comment {iterations through the loop is 3 . 75 mS / < number of instructions per iteration . >}
 94                     ;   constant nine_bits_instructions {{ clock_rate * 9 }} / {{ clock_ticks_per_instruction * baud_rate }}  
 95     249f    nine_bits_instructions equ 9375
 96                     ;   constant instructions_per_iteration 7  
 97     0007    instructions_per_iteration equ 7
 98                     ;   constant iterations_for_nine_bits nine_bits_instructions / instructions_per_iteration  
 99     053b    iterations_for_nine_bits equ 1339
100                     ;   constant iterations_high iterations_for_nine_bits / 256  
101     0005    iterations_high equ 5
102                     ;   constant iterations_low iterations_for_nine_bits - {{ iterations_high * 256 }}  
103     003b    iterations_low equ 59
104                     ; comment {Some character definitions :}
105                     ;   constant sp 32  
106     0020    sp equ 32
107                     ;   constant cr 13  
108     000d    cr equ 13
109                     ;   constant lf 10  
110     000a    lf equ 10
111                     ; comment {Some bit definitions < see schematic > :}
112                     ;   constant rx_slave_bit 5  
113     0005    rx_slave_bit equ 5
114                     ;   constant tx_slave_bit 4  
115     0004    tx_slave_bit equ 4
116                     ;   constant rx_master_bit 1  
117     0001    rx_master_bit equ 1
118                     ;   constant tx_master_bit 2  
119     0002    tx_master_bit equ 2
120                     ;   constant rx_slave_mask 1 << rx_slave_bit  
121     0020    rx_slave_mask equ 32
122                     ;   constant tx_slave_mask 1 << tx_slave_bit  
123     0010    tx_slave_mask equ 16
124                     ;   constant rx_master_mask 1 << rx_master_bit  
125     0002    rx_master_mask equ 2
126                     ;   constant tx_master_mask 1 << tx_master_bit  
127     0004    tx_master_mask equ 4
128                     ; comment {Some port and pin definitions :}
129     0005    porta equ 5
130     0006    portb equ 6
131     0006    tx_master_pin__byte equ 6
132     0002    tx_master_pin__bit equ 2
133     0006    rx_master_pin__byte equ 6
134     0001    rx_master_pin__bit equ 1
135     0006    tx_slave_pin__byte equ 6
136     0004    tx_slave_pin__bit equ 4
137     0006    rx_slave_pin__byte equ 6
138     0005    rx_slave_pin__bit equ 5
139                     ; comment {Some register and bit declarations :}
140     0003    status equ 3
141                     ;   bind c status @ 0  
142     0003    c equ status+0
143     0003    c__byte equ status+0
144     0000    c__bit equ 0
145                     ;   bind z status @ 2  
146     0003    z equ status+0
147     0003    z__byte equ status+0
148     0002    z__bit equ 2
149                     ; comment {Some miscellaneous declarations :}
150                     ;   constant space 0xff  
151     00ff    space equ 255
152                     ;   constant buffer_size 5  
153     0005    buffer_size equ 5
154                     ; string_constants Start
155             string___fetch:
156 00e 0082            movwf pcl___register
157                     ;   hello = 0s'Harness-B' , cr , lf  
158     0000    hello___string equ 0
159             hello:
160 00f 0782            addwf pcl___register,f
161                     ; Length = 11
162 010 340b            retlw 11
163                     ; `Harness-B'
164 011 3448            retlw 72
165 012 3461            retlw 97
166 013 3472            retlw 114
167 014 346e            retlw 110
168 015 3465            retlw 101
169 016 3473            retlw 115
170 017 3473            retlw 115
171 018 342d            retlw 45
172 019 3442            retlw 66
173                     ; cr
174 01a 340d            retlw 13
175                     ; lf
176 01b 340a            retlw 10
177                     ; string__constants End
178             
179                     ; procedure main start
180             main:
181     0020    main__variables__base equ global__variables__bank0+0
182     0020    main__bytes__base equ main__variables__base+0
183     002a    main__bits__base equ main__variables__base+10
184     000a    main__total__bytes equ 10
185     0029    main__149byte0 equ main__bytes__base+9
186     0029    main__121byte0 equ main__bytes__base+9
187                     ;   arguments_none  
188                     ; The main procedure prints out a hello message followed by
189                     ; command loop . The commands are :
190                     ; 
191                     ; Ns - Send N < in octal > to RoboBrick < no reply expected >
192                     ; Nw - Send N < in octal > to RoboBrick and print reply bytes
193                     ; in octal . Octal 376 means no byte .
194                     ; i - Interrogate the RoboBrick ' s identification information
195                     ; c - Perform a clock adjust sequence .
196     0020    main__char equ main__bytes__base+0
197     0021    main__number equ main__bytes__base+1
198     0022    main__count equ main__bytes__base+2
199     0023    main__index equ main__bytes__base+3
200     0024    main__buffer equ main__bytes__base+4
201                     ; Print out a welcome message :
202                     ;   index := 0  
203 01c 01a3            clrf main__index
204                     ; `while  index < hello . size  ...' start
205             main__101while__continue:
206 01d 300b            movlw 11
207 01e 0223            subwf main__index,w
208                     ; expression=` index < hello . size ' exp_delay=2 true_delay=9  false_delay=2 true_size=10 false_size=1
209 01f 1803            btfsc c___byte,c___bit
210 020 282a            goto main__101while__break
211                     ;   char := hello ~~ {{ index }}  
212 021 0a23            incf main__index,w
213 022 018a            clrf pclath___register
214 023 200f            call hello
215 024 00a0            movwf main__char
216                     ;   call master_send {{ char , tx_master_mask }}  
217 025 00b4            movwf master_send__character
218 026 3004            movlw 4
219 027 2144            call master_send
220                     ;   index := index + 1  
221 028 0aa3            incf main__index,f
222 029 281d            goto main__101while__continue
223                     ; if exp=` index < hello . size ' false goto
224                     ; Other expression=` index < hello . size ' delay=-1
225             main__101while__break:
226                     ; `while  index < hello . size  ...' end
227                     ; Main loop
228                     ;   number := 0  
229 02a 01a1            clrf main__number
230                     ; loop_forever ... start
231             main__109loop__forever:
232                     ; Get a character :
233                     ;   tx_slave_pin := 1  
234 02b 1606            bsf tx_slave_pin__byte,tx_slave_pin__bit
235                     ;   char := master_get {{ }}  
236 02c 213e            call master_get
237 02d 0833            movf master_get__0return__byte,w
238 02e 00a0            movwf main__char
239                     ; Delay 2 / 3 ' s of bit make sure that get_byte is done .
240                     ;   call delay {{ }}  
241 02f 21cd            call delay
242                     ;   call delay {{ }}  
243 030 21cd            call delay
244                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } start
245 031 3030            movlw 48
246 032 0220            subwf main__char,w
247                     ; expression=`0c'0' <= char' exp_delay=2 true_delay=-1  false_delay=1 true_size=114 false_size=1
248 033 1c03            btfss c___byte,c___bit
249 034 2845            goto and118__0false
250 035 303a            movlw 58
251 036 0220            subwf main__char,w
252                     ; expression=`char < {{ 0c'9' + 1 }}' exp_delay=2 true_delay=9  false_delay=-1 true_size=11 false_size=98
253 037 1803            btfsc c___byte,c___bit
254 038 2845            goto label118__1false
255             label118__1true:
256             and118__0true:
257                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body start
258                     ; Do a multiply by 8 then add in digit :
259                     ;   call master_send {{ char }}  
260 039 0820            movf main__char,w
261 03a 00b4            movwf master_send__character
262 03b 2144            call master_send
263                     ;   number := {{ number << 3 }} + char - 0c'0'  
264 03c 0d21            rlf main__number,w
265 03d 00a9            movwf main__121byte0
266 03e 0da9            rlf main__121byte0,f
267 03f 0d29            rlf main__121byte0,w
268 040 39f8            andlw 248
269 041 0720            addwf main__char,w
270 042 3ed0            addlw 208
271 043 00a1            movwf main__number
272                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body end
273 044 28a7            goto label118__1end
274             label118__1false:
275             and118__0false:
276 045 3073            movlw 115
277 046 0220            subwf main__char,w
278                     ; expression=`{ char = 0c's' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=8 false_size=85
279 047 1d03            btfss z___byte,z___bit
280 048 2852            goto label122__0false
281             label122__0true:
282                     ; else_if { char = 0c's' } body start
283                     ; Send byte to brick , no wait :
284                     ; Echo command and send CRLF :
285                     ;   call master_send {{ char }}  
286 049 0820            movf main__char,w
287 04a 00b4            movwf master_send__character
288 04b 2144            call master_send
289                     ;   call master_crlf {{ }}  
290 04c 2137            call master_crlf
291                     ; Ship the byte down to the brick :
292                     ;   call slave_send {{ number }}  
293 04d 0821            movf main__number,w
294 04e 00bb            movwf slave_send__data
295 04f 2189            call slave_send
296                     ;   number := 0  
297 050 01a1            clrf main__number
298                     ; else_if { char = 0c's' } body end
299 051 28a7            goto label122__0end
300             label122__0false:
301 052 3077            movlw 119
302 053 0220            subwf main__char,w
303                     ; expression=`{ char = 0c'w' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=39 false_size=41
304 054 1d03            btfss z___byte,z___bit
305 055 287e            goto label133__0false
306             label133__0true:
307                     ; else_if { char = 0c'w' } body start
308                     ; Send byte to brick , wait for results :
309                     ; Echo command and send CRLF :
310                     ;   call master_send {{ char }}  
311 056 0820            movf main__char,w
312 057 00b4            movwf master_send__character
313 058 2144            call master_send
314                     ;   call master_crlf {{ }}  
315 059 2137            call master_crlf
316                     ; Ship the byte down to the brick ...
317                     ;   call slave_send {{ number }}  
318 05a 0821            movf main__number,w
319 05b 00bb            movwf slave_send__data
320 05c 2189            call slave_send
321                     ;   number := 0  
322 05d 01a1            clrf main__number
323                     ; call delay < >
324                     ; ... and wait for a response :
325                     ;   index := 0  
326 05e 01a3            clrf main__index
327                     ; `while  index < buffer_size  ...' start
328             main__148while__continue:
329 05f 3005            movlw 5
330 060 0223            subwf main__index,w
331                     ; expression=` index < buffer_size ' exp_delay=2 true_delay=10  false_delay=2 true_size=11 false_size=1
332 061 1803            btfsc c___byte,c___bit
333 062 286e            goto main__148while__break
334                     ;   buffer ~~ {{ index }} := slave_get {{ }}  
335 063 2163            call slave_get
336 064 0837            movf slave_get__0return__byte,w
337 065 00a9            movwf main__149byte0
338 066 3024            movlw LOW main__buffer
339 067 0723            addwf main__index,w
340 068 0084            movwf fsr___register
341 069 0829            movf main__149byte0,w
342 06a 1383            bcf irp___register,irp___bit
343 06b 0080            movwf indf___register
344                     ;   index := index + 1  
345 06c 0aa3            incf main__index,f
346 06d 285f            goto main__148while__continue
347                     ; if exp=` index < buffer_size ' false goto
348                     ; Other expression=` index < buffer_size ' delay=-1
349             main__148while__break:
350                     ; `while  index < buffer_size  ...' end
351                     ;   index := 0  
352 06e 01a3            clrf main__index
353                     ; `while  index < buffer_size  ...' start
354             main__154while__continue:
355 06f 3005            movlw 5
356 070 0223            subwf main__index,w
357                     ; expression=` index < buffer_size ' exp_delay=2 true_delay=8  false_delay=2 true_size=9 false_size=1
358 071 1803            btfsc c___byte,c___bit
359 072 287c            goto main__154while__break
360                     ;   call master_octal {{ buffer ~~ {{ index }} }}  
361 073 3024            movlw LOW main__buffer
362 074 0723            addwf main__index,w
363 075 0084            movwf fsr___register
364 076 1383            bcf irp___register,irp___bit
365 077 0800            movf indf___register,w
366 078 00b5            movwf master_octal__number
367 079 214a            call master_octal
368                     ;   index := index + 1  
369 07a 0aa3            incf main__index,f
370 07b 286f            goto main__154while__continue
371                     ; if exp=` index < buffer_size ' false goto
372                     ; Other expression=` index < buffer_size ' delay=-1
373             main__154while__break:
374                     ; `while  index < buffer_size  ...' end
375                     ; Terminate the output list
376                     ;   call master_crlf {{ }}  
377 07c 2137            call master_crlf
378                     ; else_if { char = 0c'w' } body end
379 07d 28a7            goto label133__0end
380             label133__0false:
381 07e 3069            movlw 105
382 07f 0220            subwf main__char,w
383                     ; expression=`{ char = 0c'i' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=8 false_size=28
384 080 1d03            btfss z___byte,z___bit
385 081 288b            goto label161__0false
386             label161__0true:
387                     ; else_if { char = 0c'i' } body start
388                     ; Interrogate the slave RoboBrick :
389                     ; Initialize the id index :
390                     ;   call slave_send {{ 0xfd }}  
391 082 30fd            movlw 253
392 083 00bb            movwf slave_send__data
393 084 2189            call slave_send
394                     ; Get the first 8 bytes :
395                     ;   call slave_id8 {{ }}  
396 085 2169            call slave_id8
397                     ; Get the next 8 bytes of random numbers :
398                     ;   call slave_id8 {{ }}  
399 086 2169            call slave_id8
400                     ; Get the next 8 bytes of random numbers :
401                     ;   call slave_id8 {{ }}  
402 087 2169            call slave_id8
403                     ; Get the slave brick name :
404                     ;   call slave_id_string {{ }}  
405 088 217a            call slave_id_string
406                     ; Get the vendor name :
407                     ;   call slave_id_string {{ }}  
408 089 217a            call slave_id_string
409                     ; else_if { char = 0c'i' } body end
410 08a 28a7            goto label161__0end
411             label161__0false:
412 08b 3063            movlw 99
413 08c 0220            subwf main__char,w
414                     ; expression=`{ char = 0c'c' }' exp_delay=2 true_delay=2  false_delay=-1 true_size=4 false_size=19
415 08d 1903            btfsc z___byte,z___bit
416 08e 28a3            goto label181__0true
417             label181__0false:
418 08f 30fc            movlw 252
419 090 0220            subwf main__char,w
420                     ; expression=`{ char != 0xfc }' exp_delay=2 true_delay=-1  false_delay=0 true_size=15 false_size=0
421 091 1903            btfsc z___byte,z___bit
422 092 28a2            goto label184__0end
423                     ; else_if { char != 0xfc } body start
424                     ; Just echo back the current number :
425                     ;   call master_send {{ 0c'<' }}  
426 093 303c            movlw 60
427 094 00b4            movwf master_send__character
428 095 2144            call master_send
429                     ;   call master_octal {{ char }}  
430 096 0820            movf main__char,w
431 097 00b5            movwf master_octal__number
432 098 214a            call master_octal
433                     ;   call master_send {{ 0c'>' }}  
434 099 303e            movlw 62
435 09a 00b4            movwf master_send__character
436 09b 2144            call master_send
437                     ; Send a carriage - return line - feed :
438                     ;   call master_crlf {{ }}  
439 09c 2137            call master_crlf
440                     ; Output the character in octal :
441                     ;   call master_octal {{ number }}  
442 09d 0821            movf main__number,w
443 09e 00b5            movwf master_octal__number
444 09f 214a            call master_octal
445                     ; Send a carriage - return line - feed :
446                     ;   call master_crlf {{ }}  
447 0a0 2137            call master_crlf
448                     ; Reset number
449                     ;   number := 0  
450 0a1 01a1            clrf main__number
451                     ; else_if { char != 0xfc } body end
452             label184__0end:
453                     ; if exp=` char != 0xfc ' empty false
454                     ; Other expression=`{ char != 0xfc }' delay=-1
455 0a2 28a7            goto label181__0end
456             label181__0true:
457                     ; else_if { char = 0c'c' } body start
458                     ;   call clock_adjust {{ number }}  
459 0a3 0821            movf main__number,w
460 0a4 00aa            movwf clock_adjust__adjust
461 0a5 20a8            call clock_adjust
462                     ;   number := 0  
463 0a6 01a1            clrf main__number
464                     ; else_if { char = 0c'c' } body end
465                     ; if exp=` char = 0c'c' ' generic
466             label181__0end:
467                     ; Other expression=`{ char = 0c'c' }' delay=-1
468                     ; if exp=` char = 0c'i' ' generic
469             label161__0end:
470                     ; Other expression=`{ char = 0c'i' }' delay=-1
471                     ; if exp=` char = 0c'w' ' generic
472             label133__0end:
473                     ; Other expression=`{ char = 0c'w' }' delay=-1
474                     ; if exp=` char = 0c's' ' generic
475             label122__0end:
476                     ; Other expression=`{ char = 0c's' }' delay=-1
477                     ; if exp=`char < {{ 0c'9' + 1 }}' generic
478             label118__1end:
479                     ; Other expression=`char < {{ 0c'9' + 1 }}' delay=-1
480                     ; if exp=`0c'0' <= char' false goto
481                     ; Other expression=`0c'0' <= char' delay=-1
482             and118__0end:
483                     ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } end
484 0a7 282b            goto main__109loop__forever
485                     ; loop_forever ... end
486                     ; procedure main end
487             
488                     ; procedure clock_adjust start
489             clock_adjust:
490     002a    clock_adjust__variables__base equ global__variables__bank0+10
491     002a    clock_adjust__bytes__base equ clock_adjust__variables__base+0
492     0033    clock_adjust__bits__base equ clock_adjust__variables__base+9
493     0009    clock_adjust__total__bytes equ 9
494     0032    clock_adjust__220byte0 equ clock_adjust__bytes__base+8
495     0032    clock_adjust__262byte0 equ clock_adjust__bytes__base+8
496     0032    clock_adjust__272byte0 equ clock_adjust__bytes__base+8
497     0032    clock_adjust__276byte0 equ clock_adjust__bytes__base+8
498     002a    clock_adjust__adjust equ clock_adjust__bytes__base+0
499                     ; This procedure will adjust the clock to the slave .
500     002b    clock_adjust__command equ clock_adjust__bytes__base+1
501     002c    clock_adjust__count equ clock_adjust__bytes__base+2
502     002d    clock_adjust__error equ clock_adjust__bytes__base+3
503     002e    clock_adjust__error_minimum equ clock_adjust__bytes__base+4
504     002f    clock_adjust__high equ clock_adjust__bytes__base+5
505     0030    clock_adjust__low equ clock_adjust__bytes__base+6
506     0031    clock_adjust__target equ clock_adjust__bytes__base+7
507                     ;   target := iterations_low - adjust  
508 0a8 303b            movlw 59
509 0a9 00b2            movwf clock_adjust__220byte0
510 0aa 082a            movf clock_adjust__adjust,w
511 0ab 0232            subwf clock_adjust__220byte0,w
512 0ac 00b1            movwf clock_adjust__target
513                     ;   count := 4  
514 0ad 3004            movlw 4
515 0ae 00ac            movwf clock_adjust__count
516                     ;   error := 0xff  
517 0af 30ff            movlw 255
518 0b0 00ad            movwf clock_adjust__error
519                     ;   error_minimum := 0xf0  
520 0b1 30f0            movlw 240
521 0b2 00ae            movwf clock_adjust__error_minimum
522                     ; Print out the target :
523                     ;   call master_send {{ 0c'T' }}  
524 0b3 3054            movlw 84
525 0b4 00b4            movwf master_send__character
526 0b5 2144            call master_send
527                     ;   call master_octal {{ iterations_high }}  
528 0b6 3005            movlw 5
529 0b7 00b5            movwf master_octal__number
530 0b8 214a            call master_octal
531                     ;   call master_octal {{ target }}  
532 0b9 0831            movf clock_adjust__target,w
533 0ba 00b5            movwf master_octal__number
534 0bb 214a            call master_octal
535                     ;   call master_crlf {{ }}  
536 0bc 2137            call master_crlf
537                     ; loop_forever ... start
538             clock_adjust__231loop__forever:
539                     ; Print out the clock value :
540                     ;   call master_send {{ 0c'C' }}  
541 0bd 3043            movlw 67
542 0be 00b4            movwf master_send__character
543 0bf 2144            call master_send
544                     ;   call slave_send {{ 0xfa }}  
545 0c0 30fa            movlw 250
546 0c1 00bb            movwf slave_send__data
547 0c2 2189            call slave_send
548                     ;   call master_octal {{ slave_get {{ }} }}  
549 0c3 2163            call slave_get
550 0c4 0837            movf slave_get__0return__byte,w
551 0c5 00b5            movwf master_octal__number
552 0c6 214a            call master_octal
553                     ; Ask for a timing byte :
554                     ;   call slave_send {{ 0xfb }}  
555 0c7 30fb            movlw 251
556 0c8 00bb            movwf slave_send__data
557 0c9 2189            call slave_send
558                     ;   low := 0  
559 0ca 01b0            clrf clock_adjust__low
560                     ;   high := 0  
561 0cb 01af            clrf clock_adjust__high
562                     ; `while rx_slave_pin ...' start
563             clock_adjust__242while__continue:
564                     ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=2 true_size=1 false_size=1
565 0cc 1a86            btfsc rx_slave_pin__byte,rx_slave_pin__bit
566                     ; Do nothing :
567 0cd 28cc            goto clock_adjust__242while__continue
568 0ce 28cf            goto clock_adjust__242while__break
569                     ; if exp=`rx_slave_pin' true goto small true
570             clock_adjust__242while__break:
571                     ; `while rx_slave_pin ...' end
572                     ; `while  ! rx_slave_pin  ...' start
573             clock_adjust__245while__continue:
574                     ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=5 true_size=1 false_size=4
575 0cf 1a86            btfsc rx_slave_pin__byte,rx_slave_pin__bit
576 0d0 28d5            goto clock_adjust__245while__break
577                     ;   low := low + 1  
578 0d1 0ab0            incf clock_adjust__low,f
579                     ; if { z } start
580                     ; expression=`{ z }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
581 0d2 1903            btfsc z__byte,z__bit
582                     ; if { z } body start
583                     ;   high := high + 1  
584 0d3 0aaf            incf clock_adjust__high,f
585                     ; if { z } body end
586                     ; if exp=`z' false skip delay=2
587                     ; Other expression=`{ z }' delay=2
588                     ; if { z } end
589 0d4 28cf            goto clock_adjust__245while__continue
590                     ; if exp=`rx_slave_pin' true goto
591                     ; Other expression=`rx_slave_pin' delay=-1
592             clock_adjust__245while__break:
593                     ; `while  ! rx_slave_pin  ...' end
594                     ; Print out high and low :
595                     ;   call master_send {{ 0c'H' }}  
596 0d5 3048            movlw 72
597 0d6 00b4            movwf master_send__character
598 0d7 2144            call master_send
599                     ;   call master_octal {{ high }}  
600 0d8 082f            movf clock_adjust__high,w
601 0d9 00b5            movwf master_octal__number
602 0da 214a            call master_octal
603                     ;   call master_send {{ 0c'L' }}  
604 0db 304c            movlw 76
605 0dc 00b4            movwf master_send__character
606 0dd 2144            call master_send
607                     ;   call master_octal {{ low }}  
608 0de 0830            movf clock_adjust__low,w
609 0df 00b5            movwf master_octal__number
610 0e0 214a            call master_octal
611                     ; Now think about adjusting clock .
612                     ; if { high > iterations_high } start
613 0e1 3006            movlw 6
614 0e2 022f            subwf clock_adjust__high,w
615                     ; expression=`{ high > iterations_high }' exp_delay=2 true_delay=7  false_delay=-1 true_size=7 false_size=36
616 0e3 1803            btfsc c___byte,c___bit
617 0e4 290a            goto label259__0true
618             label259__0false:
619 0e5 3005            movlw 5
620 0e6 022f            subwf clock_adjust__high,w
621                     ; expression=`{ high < iterations_high }' exp_delay=2 true_delay=4  false_delay=-1 true_size=4 false_size=27
622 0e7 1c03            btfss c___byte,c___bit
623 0e8 2905            goto label263__0true
624             label263__0false:
625                     ; else body start
626                     ; The high 8 - bits are equal :
627                     ; if { low > target } start
628 0e9 0830            movf clock_adjust__low,w
629 0ea 0231            subwf clock_adjust__target,w
630                     ; expression=`{ low > target }' exp_delay=2 true_delay=7  false_delay=-1 true_size=7 false_size=15
631 0eb 1c03            btfss c___byte,c___bit
632 0ec 28fd            goto label269__0true
633             label269__0false:
634 0ed 0831            movf clock_adjust__target,w
635 0ee 0230            subwf clock_adjust__low,w
636                     ; expression=`{ low < target }' exp_delay=2 true_delay=7  false_delay=3 true_size=7 false_size=3
637 0ef 1c03            btfss c___byte,c___bit
638 0f0 28f5            goto label273__0true
639             label273__0false:
640                     ; else body start
641                     ; Exact match ; we are done :
642                     ;   command := 0  
643 0f1 01ab            clrf clock_adjust__command
644                     ;   error := 0  
645 0f2 01ad            clrf clock_adjust__error
646                     ;   error_minimum := 0  
647 0f3 01ae            clrf clock_adjust__error_minimum
648                     ; else body end
649 0f4 28fc            goto label273__0end
650             label273__0true:
651                     ; else_if { low < target } body start
652                     ; Clock pulse is too short ; slave clock is too fast :
653                     ;   command := 0xf8  
654 0f5 30f8            movlw 248
655 0f6 00ab            movwf clock_adjust__command
656                     ;   error := target - low  
657 0f7 0831            movf clock_adjust__target,w
658 0f8 00b2            movwf clock_adjust__276byte0
659 0f9 0830            movf clock_adjust__low,w
660 0fa 0232            subwf clock_adjust__276byte0,w
661 0fb 00ad            movwf clock_adjust__error
662                     ; else_if { low < target } body end
663                     ; if exp=` low < target ' generic
664             label273__0end:
665                     ; Other expression=`{ low < target }' delay=-1
666 0fc 2904            goto label269__0end
667             label269__0true:
668                     ; if { low > target } body start
669                     ; Clock pulse is too long ; slave clock is too slow :
670                     ;   command := 0xf9  
671 0fd 30f9            movlw 249
672 0fe 00ab            movwf clock_adjust__command
673                     ;   error := low - target  
674 0ff 0830            movf clock_adjust__low,w
675 100 00b2            movwf clock_adjust__272byte0
676 101 0831            movf clock_adjust__target,w
677 102 0232            subwf clock_adjust__272byte0,w
678 103 00ad            movwf clock_adjust__error
679                     ; if { low > target } body end
680                     ; if exp=` low > target ' generic
681             label269__0end:
682                     ; Other expression=`{ low > target }' delay=-1
683                     ; if { low > target } end
684                     ; else body end
685 104 2909            goto label263__0end
686             label263__0true:
687                     ; else_if { high < iterations_high } body start
688                     ; Clock pulse is too short ; slave clock is too fast :
689                     ;   command := 0xf8  
690 105 30f8            movlw 248
691 106 00ab            movwf clock_adjust__command
692                     ;   error := target  
693 107 0831            movf clock_adjust__target,w
694 108 00ad            movwf clock_adjust__error
695                     ; else_if { high < iterations_high } body end
696                     ; if exp=` high < iterations_high ' generic
697             label263__0end:
698                     ; Other expression=`{ high < iterations_high }' delay=-1
699 109 2911            goto label259__0end
700             label259__0true:
701                     ; if { high > iterations_high } body start
702                     ; Clock pulse is too long ; slave clock is too slow :
703                     ;   command := 0xf9  
704 10a 30f9            movlw 249
705 10b 00ab            movwf clock_adjust__command
706                     ;   error := 0xff - target  
707 10c 30ff            movlw 255
708 10d 00b2            movwf clock_adjust__262byte0
709 10e 0831            movf clock_adjust__target,w
710 10f 0232            subwf clock_adjust__262byte0,w
711 110 00ad            movwf clock_adjust__error
712                     ; if { high > iterations_high } body end
713                     ; if exp=` high > iterations_high ' generic
714             label259__0end:
715                     ; Other expression=`{ high > iterations_high }' delay=-1
716                     ; if { high > iterations_high } end
717                     ; Print out the error and error minimum :
718                     ;   call master_send {{ 0c'E' }}  
719 111 3045            movlw 69
720 112 00b4            movwf master_send__character
721 113 2144            call master_send
722                     ;   call master_octal {{ error }}  
723 114 082d            movf clock_adjust__error,w
724 115 00b5            movwf master_octal__number
725 116 214a            call master_octal
726                     ;   call master_send {{ 0c'M' }}  
727 117 304d            movlw 77
728 118 00b4            movwf master_send__character
729 119 2144            call master_send
730                     ;   call master_octal {{ error_minimum }}  
731 11a 082e            movf clock_adjust__error_minimum,w
732 11b 00b5            movwf master_octal__number
733 11c 214a            call master_octal
734                     ; if { error = error_minimum } start
735 11d 082d            movf clock_adjust__error,w
736 11e 022e            subwf clock_adjust__error_minimum,w
737                     ; expression=`{ error = error_minimum }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=2 false_size=14
738 11f 1d03            btfss z___byte,z___bit
739 120 2924            goto label291__0false
740             label291__0true:
741                     ; if { error = error_minimum } body start
742                     ;   call master_crlf {{ }}  
743 121 2137            call master_crlf
744                     ;   return  
745 122 3400            retlw 0
746                     ; if { error = error_minimum } body end
747 123 2932            goto label291__0end
748             label291__0false:
749 124 082e            movf clock_adjust__error_minimum,w
750 125 022d            subwf clock_adjust__error,w
751                     ; expression=`{ error < error_minimum }' exp_delay=2 true_delay=3  false_delay=-1 true_size=3 false_size=6
752 126 1c03            btfss c___byte,c___bit
753 127 292f            goto label294__0true
754             label294__0false:
755                     ; else body start
756                     ;   count := count - 1  
757 128 03ac            decf clock_adjust__count,f
758                     ; if { z } start
759                     ; expression=`{ z }' exp_delay=0 true_delay=3  false_delay=0 true_size=3 false_size=0
760 129 1d03            btfss z__byte,z__bit
761 12a 292e            goto label299__0end
762                     ; if { z } body start
763                     ;   error_minimum := error_minimum + 1  
764 12b 0aae            incf clock_adjust__error_minimum,f
765                     ;   count := 4  
766 12c 3004            movlw 4
767 12d 00ac            movwf clock_adjust__count
768                     ; if { z } body end
769             label299__0end:
770                     ; if exp=`z' empty false
771                     ; Other expression=`{ z }' delay=-1
772                     ; if { z } end
773                     ; else body end
774 12e 2932            goto label294__0end
775             label294__0true:
776                     ; else_if { error < error_minimum } body start
777                     ;   error_minimum := error  
778 12f 082d            movf clock_adjust__error,w
779 130 00ae            movwf clock_adjust__error_minimum
780                     ;   error := error + 1  
781 131 0aad            incf clock_adjust__error,f
782                     ; else_if { error < error_minimum } body end
783                     ; if exp=` error < error_minimum ' generic
784             label294__0end:
785                     ; Other expression=`{ error < error_minimum }' delay=-1
786                     ; if exp=` error = error_minimum ' generic
787             label291__0end:
788                     ; Other expression=`{ error = error_minimum }' delay=-1
789                     ; if { error = error_minimum } end
790                     ; Now adjust the clock :
791                     ;   call slave_send {{ command }}  
792 132 082b            movf clock_adjust__command,w
793 133 00bb            movwf slave_send__data
794 134 2189            call slave_send
795                     ;   call master_crlf {{ }}  
796 135 2137            call master_crlf
797 136 28bd            goto clock_adjust__231loop__forever
798                     ; loop_forever ... end
799                     ; procedure clock_adjust end
800             
801                     ; procedure master_crlf start
802             master_crlf:
803     0033    master_crlf__variables__base equ global__variables__bank0+19
804     0033    master_crlf__bytes__base equ master_crlf__variables__base+0
805     0033    master_crlf__bits__base equ master_crlf__variables__base+0
806     0000    master_crlf__total__bytes equ 0
807                     ;   arguments_none  
808                     ; This procedure will output a carriage - return line - feed
809                     ; to the master .
810                     ;   call master_send {{ cr }}  
811 137 300d            movlw 13
812 138 00b4            movwf master_send__character
813 139 2144            call master_send
814                     ;   call master_send {{ lf }}  
815 13a 300a            movlw 10
816 13b 00b4            movwf master_send__character
817 13c 2144            call master_send
818                     ; procedure master_crlf end
819 13d 3400            retlw 0
820             
821                     ; procedure master_get start
822             master_get:
823     0033    master_get__variables__base equ global__variables__bank0+19
824     0033    master_get__bytes__base equ master_get__variables__base+0
825     0034    master_get__bits__base equ master_get__variables__base+1
826     0001    master_get__total__bytes equ 1
827                     ;   arguments_none  
828     0033    master_get__0return__byte equ master_get__bytes__base+0
829                     ; This procedure will get the next byte or return 0xfc if
830                     ; no byte is forthcoming .
831                     ;   return get_byte {{ rx_master_mask }}  
832 13e 3002            movlw 2
833 13f 00bc            movwf get_byte__mask
834 140 218f            call get_byte
835 141 083d            movf get_byte__0return__byte,w
836 142 00b3            movwf master_get__0return__byte
837 143 3400            retlw 0
838                     ; procedure master_get end
839             
840                     ; procedure master_send start
841             master_send:
842     0034    master_send__variables__base equ global__variables__bank0+20
843     0034    master_send__bytes__base equ master_send__variables__base+0
844     0035    master_send__bits__base equ master_send__variables__base+1
845     0001    master_send__total__bytes equ 1
846     0034    master_send__character equ master_send__bytes__base+0
847                     ; This procedure will output < character > to the master .
848                     ;   call send_byte {{ character , tx_master_mask }}  
849 144 0834            movf master_send__character,w
850 145 00c0            movwf send_byte__char
851 146 3004            movlw 4
852 147 00c1            movwf send_byte__mask
853 148 21b2            call send_byte
854                     ; procedure master_send end
855 149 3400            retlw 0
856             
857                     ; procedure master_octal start
858             master_octal:
859     0035    master_octal__variables__base equ global__variables__bank0+21
860     0035    master_octal__bytes__base equ master_octal__variables__base+0
861     0037    master_octal__bits__base equ master_octal__variables__base+2
862     0002    master_octal__total__bytes equ 2
863     0036    master_octal__350byte0 equ master_octal__bytes__base+1
864     0036    master_octal__349byte0 equ master_octal__bytes__base+1
865     0035    master_octal__number equ master_octal__bytes__base+0
866                     ; This procedure will output < number > in octal to the tx port .
867                     ; Output the character in octal :
868                     ;   call master_send {{ {{ number >> 6 }} + 0c'0' }}  
869 14a 0e35            swapf master_octal__number,w
870 14b 00b6            movwf master_octal__349byte0
871 14c 0cb6            rrf master_octal__349byte0,f
872 14d 0c36            rrf master_octal__349byte0,w
873 14e 3903            andlw 3
874 14f 3e30            addlw 48
875 150 00b4            movwf master_send__character
876 151 2144            call master_send
877                     ;   call master_send {{ {{ {{ number >> 3 }} & 7 }} + 0c'0' }}  
878 152 0c35            rrf master_octal__number,w
879 153 00b6            movwf master_octal__350byte0
880 154 0cb6            rrf master_octal__350byte0,f
881 155 0c36            rrf master_octal__350byte0,w
882 156 3907            andlw 7
883 157 3e30            addlw 48
884 158 00b4            movwf master_send__character
885 159 2144            call master_send
886                     ;   call master_send {{ {{ number & 7 }} + 0c'0' }}  
887 15a 3007            movlw 7
888 15b 0535            andwf master_octal__number,w
889 15c 3e30            addlw 48
890 15d 00b4            movwf master_send__character
891 15e 2144            call master_send
892                     ;   call master_send {{ sp }}  
893 15f 3020            movlw 32
894 160 00b4            movwf master_send__character
895 161 2144            call master_send
896                     ; procedure master_octal end
897 162 3400            retlw 0
898             
899                     ; procedure slave_get start
900             slave_get:
901     0037    slave_get__variables__base equ global__variables__bank0+23
902     0037    slave_get__bytes__base equ slave_get__variables__base+0
903     0038    slave_get__bits__base equ slave_get__variables__base+1
904     0001    slave_get__total__bytes equ 1
905                     ;   arguments_none  
906     0037    slave_get__0return__byte equ slave_get__bytes__base+0
907                     ; This procedure will get a byte from the slave or return 0xfc
908                     ; if no byte is forthcoming .
909                     ;   return get_byte {{ rx_slave_mask }}  
910 163 3020            movlw 32
911 164 00bc            movwf get_byte__mask
912 165 218f            call get_byte
913 166 083d            movf get_byte__0return__byte,w
914 167 00b7            movwf slave_get__0return__byte
915 168 3400            retlw 0
916                     ; procedure slave_get end
917             
918                     ; procedure slave_id8 start
919             slave_id8:
920     0038    slave_id8__variables__base equ global__variables__bank0+24
921     0038    slave_id8__bytes__base equ slave_id8__variables__base+0
922     0039    slave_id8__bits__base equ slave_id8__variables__base+1
923     0001    slave_id8__total__bytes equ 1
924                     ;   arguments_none  
925                     ; This procedure will print out the next 8 bytes of data from
926                     ; the slave RoboBrick id bytes .
927     0038    slave_id8__counter equ slave_id8__bytes__base+0
928                     ; `count_down counter 8 ...' start
929 169 3008            movlw 8
930 16a 00b8            movwf slave_id8__counter
931             slave_id8__374_loop:
932                     ;   call master_octal {{ slave_id_next {{ }} }}  
933 16b 2173            call slave_id_next
934 16c 0839            movf slave_id_next__0return__byte,w
935 16d 00b5            movwf master_octal__number
936 16e 214a            call master_octal
937 16f 0bb8            decfsz slave_id8__counter,f
938 170 296b            goto slave_id8__374_loop
939             slave_id8__374_done:
940                     ; `count_down counter 8 ...' end
941                     ;   call master_crlf {{ }}  
942 171 2137            call master_crlf
943                     ; procedure slave_id8 end
944 172 3400            retlw 0
945             
946                     ; procedure slave_id_next start
947             slave_id_next:
948     0039    slave_id_next__variables__base equ global__variables__bank0+25
949     0039    slave_id_next__bytes__base equ slave_id_next__variables__base+0
950     003a    slave_id_next__bits__base equ slave_id_next__variables__base+1
951     0001    slave_id_next__total__bytes equ 1
952                     ;   arguments_none  
953     0039    slave_id_next__0return__byte equ slave_id_next__bytes__base+0
954                     ; This procedure will return the next byte from the id bytes .
955                     ;   call slave_send {{ 0xfc }}  
956 173 30fc            movlw 252
957 174 00bb            movwf slave_send__data
958 175 2189            call slave_send
959                     ;   return slave_get {{ }}  
960 176 2163            call slave_get
961 177 0837            movf slave_get__0return__byte,w
962 178 00b9            movwf slave_id_next__0return__byte
963 179 3400            retlw 0
964                     ; procedure slave_id_next end
965             
966                     ; procedure slave_id_string start
967             slave_id_string:
968     003a    slave_id_string__variables__base equ global__variables__bank0+26
969     003a    slave_id_string__bytes__base equ slave_id_string__variables__base+0
970     003b    slave_id_string__bits__base equ slave_id_string__variables__base+1
971     0001    slave_id_string__total__bytes equ 1
972                     ;   arguments_none  
973                     ; This procedure will return the string for the id bytes .
974     003a    slave_id_string__size equ slave_id_string__bytes__base+0
975                     ;   size := slave_id_next {{ }}  
976 17a 2173            call slave_id_next
977 17b 0839            movf slave_id_next__0return__byte,w
978 17c 00ba            movwf slave_id_string__size
979                     ;   call master_octal {{ size }}  
980 17d 00b5            movwf master_octal__number
981 17e 214a            call master_octal
982                     ; `count_down size size ...' start
983 17f 083a            movf slave_id_string__size,w
984 180 00ba            movwf slave_id_string__size
985             slave_id_string__400_loop:
986                     ;   call master_send {{ slave_id_next {{ }} }}  
987 181 2173            call slave_id_next
988 182 0839            movf slave_id_next__0return__byte,w
989 183 00b4            movwf master_send__character
990 184 2144            call master_send
991 185 0bba            decfsz slave_id_string__size,f
992 186 2981            goto slave_id_string__400_loop
993             slave_id_string__400_done:
994                     ; `count_down size size ...' end
995                     ;   call master_crlf {{ }}  
996 187 2137            call master_crlf
997                     ; procedure slave_id_string end
998 188 3400            retlw 0
999             
1000                     ; procedure slave_send start
1001             slave_send:
1002     003b    slave_send__variables__base equ global__variables__bank0+27
1003     003b    slave_send__bytes__base equ slave_send__variables__base+0
1004     003c    slave_send__bits__base equ slave_send__variables__base+1
1005     0001    slave_send__total__bytes equ 1
1006     003b    slave_send__data equ slave_send__bytes__base+0
1007                     ; This procedure will send one byte of < data > to the slave .
1008                     ;   call send_byte {{ data , tx_slave_mask }}  
1009 189 083b            movf slave_send__data,w
1010 18a 00c0            movwf send_byte__char
1011 18b 3010            movlw 16
1012 18c 00c1            movwf send_byte__mask
1013 18d 21b2            call send_byte
1014                     ; procedure slave_send end
1015 18e 3400            retlw 0
1016             
1017                     ; procedure get_byte start
1018             get_byte:
1019     003c    get_byte__variables__base equ global__variables__bank0+28
1020     003c    get_byte__bytes__base equ get_byte__variables__base+0
1021     0040    get_byte__bits__base equ get_byte__variables__base+4
1022     0004    get_byte__total__bytes equ 4
1023     003c    get_byte__mask equ get_byte__bytes__base+0
1024     003d    get_byte__0return__byte equ get_byte__bytes__base+1
1025                     ; Get an 8 - bit byte from < mask > bit of < porta > and return it .
1026                     ; If no character shows up in a while 0xfc is returned .
1027     003e    get_byte__count equ get_byte__bytes__base+2
1028     003f    get_byte__char equ get_byte__bytes__base+3
1029                     ; Wait until a start bit arrives :
1030                     ;   count := 0  
1031 18f 01be            clrf get_byte__count
1032                     ; `while  portb & mask != 0  ...' start
1033             get_byte__427while__continue:
1034 190 0806            movf portb,w
1035 191 053c            andwf get_byte__mask,w
1036                     ; expression=` portb & mask != 0 ' exp_delay=2 true_delay=1  false_delay=2 true_size=9 false_size=1
1037 192 1903            btfsc z___byte,z___bit
1038 193 299d            goto get_byte__427while__break
1039                     ;   count := count - 1  
1040 194 03be            decf get_byte__count,f
1041                     ; if { count = 0 } start
1042 195 083e            movf get_byte__count,w
1043                     ; expression=`{ count = 0 }' exp_delay=1 true_delay=3  false_delay=0 true_size=3 false_size=0
1044 196 1d03            btfss z___byte,z___bit
1045 197 299b            goto label429__0end
1046                     ; if { count = 0 } body start
1047                     ;   return 0xfc  
1048 198 30fc            movlw 252
1049 199 00bd            movwf get_byte__0return__byte
1050 19a 3400            retlw 0
1051                     ; if { count = 0 } body end
1052             label429__0end:
1053                     ; if exp=` count = 0 ' empty false
1054                     ; Other expression=`{ count = 0 }' delay=-1
1055                     ; if { count = 0 } end
1056                     ;   call delay {{ }}  
1057 19b 21cd            call delay
1058 19c 2990            goto get_byte__427while__continue
1059                     ; if exp=` portb & mask != 0 ' false goto
1060                     ; Other expression=` portb & mask != 0 ' delay=-1
1061             get_byte__427while__break:
1062                     ; `while  portb & mask != 0  ...' end
1063                     ; Skip over the start bit :
1064                     ;   call delay {{ }}  
1065 19d 21cd            call delay
1066                     ;   call delay {{ }}  
1067 19e 21cd            call delay
1068                     ;   call delay {{ }}  
1069 19f 21cd            call delay
1070                     ; Sample in the middle third of each data bit :
1071                     ;   char := 0  
1072 1a0 01bf            clrf get_byte__char
1073                     ; `count_down count 8 ...' start
1074 1a1 3008            movlw 8
1075 1a2 00be            movwf get_byte__count
1076             get_byte__442_loop:
1077                     ;   call delay {{ }}  
1078 1a3 21cd            call delay
1079                     ;   char := char >> 1  
1080 1a4 1003            bcf c___byte,c___bit
1081 1a5 0cbf            rrf get_byte__char,f
1082                     ; if { portb & mask != 0 } start
1083 1a6 0806            movf portb,w
1084 1a7 053c            andwf get_byte__mask,w
1085                     ; expression=`{ portb & mask != 0 }' exp_delay=2 true_delay=1  false_delay=0 true_size=1 false_size=0
1086 1a8 1d03            btfss z___byte,z___bit
1087                     ; if { portb & mask != 0 } body start
1088                     ; char := char | 0x80
1089                     ;   char @ 7 := 1  
1090                     ; Select char @ 7
1091     003f    get_byte__char__447select0 equ get_byte__char+0
1092     003f    get_byte__char__447select0__byte equ get_byte__char+0
1093     0007    get_byte__char__447select0__bit equ 7
1094 1a9 17bf            bsf get_byte__char__447select0__byte,get_byte__char__447select0__bit
1095                     ; if { portb & mask != 0 } body end
1096                     ; if exp=` portb & mask != 0 ' false skip delay=4
1097                     ; Other expression=`{ portb & mask != 0 }' delay=4
1098                     ; if { portb & mask != 0 } end
1099                     ;   call delay {{ }}  
1100 1aa 21cd            call delay
1101                     ;   call delay {{ }}  
1102 1ab 21cd            call delay
1103 1ac 0bbe            decfsz get_byte__count,f
1104 1ad 29a3            goto get_byte__442_loop
1105             get_byte__442_done:
1106                     ; `count_down count 8 ...' end
1107                     ; Skip over 1 / 3 of the stop bit :
1108                     ;   call delay {{ }}  
1109 1ae 21cd            call delay
1110                     ;   return char  
1111 1af 083f            movf get_byte__char,w
1112 1b0 00bd            movwf get_byte__0return__byte
1113 1b1 3400            retlw 0
1114                     ; procedure get_byte end
1115             
1116                     ; procedure send_byte start
1117             send_byte:
1118     0040    send_byte__variables__base equ global__variables__bank0+32
1119     0040    send_byte__bytes__base equ send_byte__variables__base+0
1120     0044    send_byte__bits__base equ send_byte__variables__base+4
1121     0004    send_byte__total__bytes equ 4
1122     0040    send_byte__char equ send_byte__bytes__base+0
1123     0041    send_byte__mask equ send_byte__bytes__base+1
1124                     ; Send < char > to < mask > bit of < porta > .
1125     0042    send_byte__count equ send_byte__bytes__base+2
1126     0043    send_byte__mark equ send_byte__bytes__base+3
1127                     ; Send the start bit :
1128                     ;   mark := mask ^ space  
1129 1b2 30ff            movlw 255
1130 1b3 0641            xorwf send_byte__mask,w
1131 1b4 00c3            movwf send_byte__mark
1132                     ;   portb := mark  
1133 1b5 0086            movwf portb
1134                     ;   call delay {{ }}  
1135 1b6 21cd            call delay
1136                     ;   call delay {{ }}  
1137 1b7 21cd            call delay
1138                     ;   call delay {{ }}  
1139 1b8 21cd            call delay
1140                     ; Send the data :
1141                     ; `count_down count 8 ...' start
1142 1b9 3008            movlw 8
1143 1ba 00c2            movwf send_byte__count
1144             send_byte__477_loop:
1145                     ; if { char @ 0 } start
1146                     ; Alias variable for select char @ 0
1147     0040    send_byte__char__478select0 equ send_byte__char+0
1148     0040    send_byte__char__478select0__byte equ send_byte__char+0
1149     0000    send_byte__char__478select0__bit equ 0
1150                     ; expression=`{ char @ 0 }' exp_delay=0 true_delay=1  false_delay=1 true_size=1 false_size=1
1151 1bb 1840            btfsc send_byte__char__478select0__byte,send_byte__char__478select0__bit
1152                     ; if { char @ 0 } body start
1153                     ;   portb := space  
1154 1bc 30ff            movlw 255
1155                     ; 1 instructions found for sharing
1156 1bd 1c40            btfss send_byte__char__478select0__byte,send_byte__char__478select0__bit
1157                     ; else body start
1158                     ;   portb := mark  
1159 1be 0843            movf send_byte__mark,w
1160                     ; 1 instructions found for sharing
1161                     ; if exp=` char @ 0 ' single true and false skip delay=4
1162                     ; Other expression=`{ char @ 0 }' delay=4
1163                     ; 1 shared instructions follow
1164 1bf 0086            movwf portb
1165                     ; if { char @ 0 } end
1166                     ;   char := char >> 1  
1167 1c0 1003            bcf c___byte,c___bit
1168 1c1 0cc0            rrf send_byte__char,f
1169                     ;   call delay {{ }}  
1170 1c2 21cd            call delay
1171                     ;   call delay {{ }}  
1172 1c3 21cd            call delay
1173                     ;   call delay {{ }}  
1174 1c4 21cd            call delay
1175 1c5 0bc2            decfsz send_byte__count,f
1176 1c6 29bb            goto send_byte__477_loop
1177             send_byte__477_done:
1178                     ; `count_down count 8 ...' end
1179                     ; Send the stop bit :
1180                     ;   portb := space  
1181 1c7 30ff            movlw 255
1182 1c8 0086            movwf portb
1183                     ;   call delay {{ }}  
1184 1c9 21cd            call delay
1185                     ;   call delay {{ }}  
1186 1ca 21cd            call delay
1187                     ;   call delay {{ }}  
1188 1cb 21cd            call delay
1189                     ; procedure send_byte end
1190 1cc 3400            retlw 0
1191             
1192                     ; procedure delay start
1193                     ; optimize 0
1194             delay:
1195     0044    delay__variables__base equ global__variables__bank0+36
1196     0044    delay__bytes__base equ delay__variables__base+0
1197     0045    delay__bits__base equ delay__variables__base+1
1198     0001    delay__total__bytes equ 1
1199     0044    delay__496byte1 equ delay__bytes__base+0
1200                     ;   arguments_none  
1201                     ;   uniform_delay instructions_per_delay  
1202                     ; Uniform delay remaining = 343 Accumulated Delay = 0
1203                     ; Uniform delay remaining = 343 Accumulated Delay = 0
1204                     ; Delay 1 third of a bit :
1205                     ; Uniform delay remaining = 343 Accumulated Delay = 0
1206                     ; Uniform delay remaining = 343 Accumulated Delay = 0
1207                     ; Soak up remaining 343 cycles
1208                     ; Delay 343 cycles
1209 1cd 3072            movlw 114
1210 1ce 00c4            movwf delay__496byte1
1211             delay__496delay0:
1212 1cf 0bc4            decfsz delay__496byte1,f
1213 1d0 29cf            goto delay__496delay0
1214                     ; procedure delay end
1215 1d1 3400            retlw 0
1216                     ; optimize 1
1217             
1218                     ; Register bank 0 used 37 bytes of 96 available bytes
1219                     ; Register bank 1 used 0 bytes of 80 available bytes
1220                     ; Register bank 2 used 0 bytes of 48 available bytes
1221                     ; Register bank 3 used 0 bytes of 0 available bytes
1222             
1223                     end

