        radix dec
global__variables__bank0 equ 32
global__variables__bank1 equ 160
global__variables__bank2 equ 288
global__variables__bank3 equ 496
global__bit__variables__bank0 equ 99
global__bit__variables__bank1 equ 160
global__bit__variables__bank2 equ 288
global__bit__variables__bank3 equ 496
indf___register equ 0
pcl___register equ 2
c___byte equ 3
c___bit equ 0
z___byte equ 3
z___bit equ 2
rp0___byte equ 3
rp0___bit equ 5
rp1___byte equ 3
rp1___bit equ 6
irp___byte equ 3
irp___bit equ 7
trisa___register equ 0x85
trisb___register equ 0x86
fsr___register equ 4
pclath___register equ 10
        org 0
start:
        nop
        nop
        nop
        goto skip___interrupt
interrupt___vector:
        retfie
skip___interrupt:
        ; Initialize A/D system to allow digital I/O
        movlw 7
        movwf 31
        ; Switch from register bank 0 to register bank 1 (which contains 159)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        clrf 159
        ; Initialize TRIS registers
        movlw 235
        movwf trisb___register
        clrf pclath___register
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        goto main
        ; comment #############################################################################
        ; comment {}
        ; comment {Copyright < c > 2001 by Wayne C . Gramlich .}
        ; comment {All rights reserved .}
        ; comment {}
        ; comment {Permission to use , copy , modify , distribute , and sell this software}
        ; comment {for any purpose is hereby granted without fee provided that the above}
        ; comment {copyright notice and this permission are retained . The author makes}
        ; comment {no representations about the suitability of this software for any purpose .}
        ; comment {It is provided { as is } without express or implied warranty .}
        ; comment {}
        ; comment {This is a test harness for testing the AnalogIn4 RoboBrick . See :}
        ; comment {}
        ; comment {http : / / web . gramlich . net / projects / robobricks / analogin4 / index . html}
        ; comment {}
        ; comment {for more details .}
        ; comment {}
        ; comment #############################################################################
        ;   processor pic16f628 cp = off cpd = off lvp = off bowden = off mclre = on pwrte = off wdte = off fosc = xt  
        ; 16169=0x3f29 8199=0x2007
        __config 16169
configuration___address equ 8199
        ;   constant clock_rate 10000000  
clock_rate equ 10000000
        ;   constant clock_ticks_per_instruction 4  
clock_ticks_per_instruction equ 4
        ;   constant instructions_per_second clock_rate / clock_ticks_per_instruction  
instructions_per_second equ 2500000
        ;   constant baud_rate 2400  
baud_rate equ 2400
        ;   constant instructions_per_bit clock_rate / {{ clock_ticks_per_instruction * baud_rate }}  
instructions_per_bit equ 1041
        ;   constant delays_per_bit 3  
delays_per_bit equ 3
        ;   constant instructions_per_delay instructions_per_bit / delays_per_bit  
instructions_per_delay equ 347
        ;   constant extra_instructions_per_bit 12  
extra_instructions_per_bit equ 12
        ;   constant extra_instructions_per_delay extra_instructions_per_bit / delays_per_bit  
extra_instructions_per_delay equ 4
        ;   constant delay_instructions instructions_per_delay - extra_instructions_per_delay  
delay_instructions equ 343
        ; comment {The null pulse that comes back from a clock pulse command is supposed to be}
        ; comment {exactly 9 bits long . 9 bits at 2400 baud is 9 / 2400 = 3 . 75 mS . The number}
        ; comment {iterations through the loop is 3 . 75 mS / < number of instructions per iteration . >}
        ;   constant nine_bits_instructions {{ clock_rate * 9 }} / {{ clock_ticks_per_instruction * baud_rate }}  
nine_bits_instructions equ 9375
        ;   constant instructions_per_iteration 7  
instructions_per_iteration equ 7
        ;   constant iterations_for_nine_bits nine_bits_instructions / instructions_per_iteration  
iterations_for_nine_bits equ 1339
        ;   constant iterations_high iterations_for_nine_bits / 256  
iterations_high equ 5
        ;   constant iterations_low iterations_for_nine_bits - {{ iterations_high * 256 }}  
iterations_low equ 59
        ; comment {Some character constants :}
        ;   constant sp 32  
sp equ 32
        ;   constant cr 13  
cr equ 13
        ;   constant lf 10  
lf equ 10
        ; comment {Some bit definitions :}
        ;   constant rx_slave_bit 5  
rx_slave_bit equ 5
        ;   constant tx_slave_bit 4  
tx_slave_bit equ 4
        ;   constant rx_master_bit 1  
rx_master_bit equ 1
        ;   constant tx_master_bit 2  
tx_master_bit equ 2
        ;   constant rx_slave_mask 1 << rx_slave_bit  
rx_slave_mask equ 32
        ;   constant tx_slave_mask 1 << tx_slave_bit  
tx_slave_mask equ 16
        ;   constant rx_master_mask 1 << rx_master_bit  
rx_master_mask equ 2
        ;   constant tx_master_mask 1 << tx_master_bit  
tx_master_mask equ 4
        ; comment {Some register definitions :}
status equ 3
        ;   bind c status @ 0  
c equ status+0
c__byte equ status+0
c__bit equ 0
        ;   bind z status @ 2  
z equ status+0
z__byte equ status+0
z__bit equ 2
        ; comment {Some port and pin definitions :}
        ; comment {port porta a unused none}
portb equ 6
tx_master_pin__byte equ 6
tx_master_pin__bit equ 2
rx_master_pin__byte equ 6
rx_master_pin__bit equ 1
tx_slave_pin__byte equ 6
tx_slave_pin__bit equ 4
rx_slave_pin__byte equ 6
rx_slave_pin__bit equ 5
        ; comment {Miscellaneous constants :}
        ;   constant space 0xff  
space equ 255
        ;   constant buffer_size 3  
buffer_size equ 3
        ; string_constants Start
string___fetch:
        movwf pcl___register
        ;   binary_string = 0s'Binary'  
binary_string___string equ 0
binary_string:
        addwf pcl___register,f
        ; Length = 6
        retlw 6
        ; `Binary'
        retlw 66
        retlw 105
        retlw 110
        retlw 97
        retlw 114
        retlw 121
        ;   bit_string = 0s'Bit'  
bit_string___string equ 8
bit_string:
        addwf pcl___register,f
        ; Length = 3
        retlw 3
        ; `Bit'
        retlw 66
        retlw 105
        retlw 116
        ;   channel_string = 0s'Channel'  
channel_string___string equ 13
channel_string:
        addwf pcl___register,f
        ; Length = 7
        retlw 7
        ; `Channel'
        retlw 67
        retlw 104
        retlw 97
        retlw 110
        retlw 110
        retlw 101
        retlw 108
        ;   clock_string = 0s'Clk'  
clock_string___string equ 22
clock_string:
        addwf pcl___register,f
        ; Length = 3
        retlw 3
        ; `Clk'
        retlw 67
        retlw 108
        retlw 107
        ;   common_string = 0s'Common'  
common_string___string equ 27
common_string:
        addwf pcl___register,f
        ; Length = 6
        retlw 6
        ; `Common'
        retlw 67
        retlw 111
        retlw 109
        retlw 109
        retlw 111
        retlw 110
        ;   done_string = 0s'Done'  
done_string___string equ 35
done_string:
        addwf pcl___register,f
        ; Length = 4
        retlw 4
        ; `Done'
        retlw 68
        retlw 111
        retlw 110
        retlw 101
        ;   fail_string = 0s'Fail'  
fail_string___string equ 41
fail_string:
        addwf pcl___register,f
        ; Length = 4
        retlw 4
        ; `Fail'
        retlw 70
        retlw 97
        retlw 105
        retlw 108
        ;   hello_string = 0s'AnalogIn4_Test'  
hello_string___string equ 47
hello_string:
        addwf pcl___register,f
        ; Length = 14
        retlw 14
        ; `AnalogIn4_Test'
        retlw 65
        retlw 110
        retlw 97
        retlw 108
        retlw 111
        retlw 103
        retlw 73
        retlw 110
        retlw 52
        retlw 95
        retlw 84
        retlw 101
        retlw 115
        retlw 116
        ;   input_string = 0s'Input'  
input_string___string equ 63
input_string:
        addwf pcl___register,f
        ; Length = 5
        retlw 5
        ; `Input'
        retlw 73
        retlw 110
        retlw 112
        retlw 117
        retlw 116
        ;   interrupt_string = 0s'Interrupt'  
interrupt_string___string equ 70
interrupt_string:
        addwf pcl___register,f
        ; Length = 9
        retlw 9
        ; `Interrupt'
        retlw 73
        retlw 110
        retlw 116
        retlw 101
        retlw 114
        retlw 114
        retlw 117
        retlw 112
        retlw 116
        ;   patterns = 0 , 1 , 2 , 4 , 8 , 0x10 , 0x20 , 0x40 , 0x80 , 0xff , 0  
patterns___string equ 81
patterns:
        addwf pcl___register,f
        ; Length = 11
        retlw 11
        ; 0
        retlw 0
        ; 1
        retlw 1
        ; 2
        retlw 2
        ; 4
        retlw 4
        ; 8
        retlw 8
        ; 0x10
        retlw 16
        ; 0x20
        retlw 32
        ; 0x40
        retlw 64
        ; 0x80
        retlw 128
        ; 0xff
        retlw 255
        ; 0
        retlw 0
        ;   register_string = 0s'Register'  
register_string___string equ 94
register_string:
        addwf pcl___register,f
        ; Length = 8
        retlw 8
        ; `Register'
        retlw 82
        retlw 101
        retlw 103
        retlw 105
        retlw 115
        retlw 116
        retlw 101
        retlw 114
        ;   test_string = 0s'Test'  
test_string___string equ 104
test_string:
        addwf pcl___register,f
        ; Length = 4
        retlw 4
        ; `Test'
        retlw 84
        retlw 101
        retlw 115
        retlw 116
        ;   threshold_string = 0s'Threshold'  
threshold_string___string equ 110
threshold_string:
        addwf pcl___register,f
        ; Length = 9
        retlw 9
        ; `Threshold'
        retlw 84
        retlw 104
        retlw 114
        retlw 101
        retlw 115
        retlw 104
        retlw 111
        retlw 108
        retlw 100
        ; string__constants End
temp equ global__variables__bank0+0

        ; procedure main start
main:
main__variables__base equ global__variables__bank0+1
main__bytes__base equ main__variables__base+0
main__bits__base equ main__variables__base+7
main__total__bytes equ 7
main__124byte0 equ main__bytes__base+6
main__152byte0 equ main__bytes__base+6
        ;   arguments_none  
        ; Read a byte .
main__buffer equ main__bytes__base+0
main__char equ main__bytes__base+3
main__index equ main__bytes__base+4
main__number equ main__bytes__base+5
        ; Print out a welcome message :
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   call master_string {{ hello_string }}  
        movlw LOW hello_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Main loop
        ;   number := 0  
        clrf main__number
        ; loop_forever ... start
main__112loop__forever:
        ; Get a character :
        ;   tx_slave_pin := 1  
        bsf tx_slave_pin__byte,tx_slave_pin__bit
        ;   char := master_get {{ }}  
        call master_get
        movf master_get__0return__byte,w
        movwf main__char
        ; Delay 2 / 3 ' s of bit make sure that get_byte is done .
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } start
        movlw 48
        subwf main__char,w
        ; expression=`0c'0' <= char' exp_delay=2 true_delay=-1  false_delay=1 true_size=132 false_size=1
        btfss c___byte,c___bit
        goto and121__0false
        movlw 58
        subwf main__char,w
        ; expression=`char < {{ 0c'9' + 1 }}' exp_delay=2 true_delay=9  false_delay=-1 true_size=11 false_size=116
        btfsc c___byte,c___bit
        goto label121__1false
label121__1true:
and121__0true:
        ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body start
        ; Do a multiply by 8 then add in digit :
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   number := {{ number << 3 }} + char - 0c'0'  
        rlf main__number,w
        movwf main__124byte0
        rlf main__124byte0,f
        rlf main__124byte0,w
        andlw 248
        addwf main__char,w
        addlw 208
        movwf main__number
        ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } body end
        goto label121__1end
label121__1false:
and121__0false:
        movlw 115
        subwf main__char,w
        ; expression=`{ char = 0c's' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=8 false_size=103
        btfss z___byte,z___bit
        goto label125__0false
label125__0true:
        ; else_if { char = 0c's' } body start
        ; Send byte to brick , no wait :
        ; Echo command and send CRLF :
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Ship the byte down to the brick :
        ;   call slave_send {{ number }}  
        movf main__number,w
        movwf slave_send__data
        call slave_send
        ;   number := 0  
        clrf main__number
        ; else_if { char = 0c's' } body end
        goto label125__0end
label125__0false:
        movlw 119
        subwf main__char,w
        ; expression=`{ char = 0c'w' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=39 false_size=59
        btfss z___byte,z___bit
        goto label136__0false
label136__0true:
        ; else_if { char = 0c'w' } body start
        ; Send byte to brick , wait for results :
        ; Echo command and send CRLF :
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Ship the byte down to the brick ...
        ;   call slave_send {{ number }}  
        movf main__number,w
        movwf slave_send__data
        call slave_send
        ;   number := 0  
        clrf main__number
        ; call delay < >
        ; ... and wait for a response :
        ;   index := 0  
        clrf main__index
        ; `while  index < buffer_size  ...' start
main__151while__continue:
        movlw 3
        subwf main__index,w
        ; expression=` index < buffer_size ' exp_delay=2 true_delay=10  false_delay=2 true_size=11 false_size=1
        btfsc c___byte,c___bit
        goto main__151while__break
        ;   buffer ~~ {{ index }} := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf main__152byte0
        movlw LOW main__buffer
        addwf main__index,w
        movwf fsr___register
        movf main__152byte0,w
        bcf irp___register,irp___bit
        movwf indf___register
        ;   index := index + 1  
        incf main__index,f
        goto main__151while__continue
        ; if exp=` index < buffer_size ' false goto
        ; Other expression=` index < buffer_size ' delay=-1
main__151while__break:
        ; `while  index < buffer_size  ...' end
        ;   index := 0  
        clrf main__index
        ; `while  index < buffer_size  ...' start
main__157while__continue:
        movlw 3
        subwf main__index,w
        ; expression=` index < buffer_size ' exp_delay=2 true_delay=8  false_delay=2 true_size=9 false_size=1
        btfsc c___byte,c___bit
        goto main__157while__break
        ;   call master_octal {{ buffer ~~ {{ index }} }}  
        movlw LOW main__buffer
        addwf main__index,w
        movwf fsr___register
        bcf irp___register,irp___bit
        movf indf___register,w
        movwf master_octal__number
        call master_octal
        ;   index := index + 1  
        incf main__index,f
        goto main__157while__continue
        ; if exp=` index < buffer_size ' false goto
        ; Other expression=` index < buffer_size ' delay=-1
main__157while__break:
        ; `while  index < buffer_size  ...' end
        ; Terminate the output list
        ;   call master_crlf {{ }}  
        call master_crlf
        ; else_if { char = 0c'w' } body end
        goto label136__0end
label136__0false:
        movlw 105
        subwf main__char,w
        ; expression=`{ char = 0c'i' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=12 false_size=42
        btfss z___byte,z___bit
        goto label164__0false
label164__0true:
        ; else_if { char = 0c'i' } body start
        ; Interrogate the slave RoboBrick :
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Initialize the id index :
        ;   call slave_send {{ 0xfd }}  
        movlw 253
        movwf slave_send__data
        call slave_send
        ; Get the first 8 bytes :
        ;   call common_test_id_bytes8 {{ }}  
        call common_test_id_bytes8
        ; Get the next 8 bytes of random numbers :
        ;   call common_test_id_bytes8 {{ }}  
        call common_test_id_bytes8
        ; Get the next 8 bytes of random numbers :
        ;   call common_test_id_bytes8 {{ }}  
        call common_test_id_bytes8
        ; Get the slave brick name :
        ;   call common_test_id_string {{ }}  
        call common_test_id_string
        ; Get the vendor name :
        ;   call common_test_id_string {{ }}  
        call common_test_id_string
        ; else_if { char = 0c'i' } body end
        goto label164__0end
label164__0false:
        movlw 116
        subwf main__char,w
        ; expression=`{ char = 0c't' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=5 false_size=32
        btfss z___byte,z___bit
        goto label187__0false
label187__0true:
        ; else_if { char = 0c't' } body start
        ; Do testing :
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   call test {{ }}  
        call test
        ; else_if { char = 0c't' } body end
        goto label187__0end
label187__0false:
        movlw 99
        subwf main__char,w
        ; expression=`{ char = 0c'c' }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=8 false_size=19
        btfss z___byte,z___bit
        goto label192__0false
label192__0true:
        ; else_if { char = 0c'c' } body start
        ;   call master_send {{ char }}  
        movf main__char,w
        movwf master_send__character
        call master_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   call clock_adjust {{ number }}  
        movf main__number,w
        movwf clock_adjust__adjust
        call clock_adjust
        ;   number := 0  
        clrf main__number
        ; else_if { char = 0c'c' } body end
        goto label192__0end
label192__0false:
        movlw 252
        subwf main__char,w
        ; expression=`{ char != 0xfc }' exp_delay=2 true_delay=-1  false_delay=0 true_size=15 false_size=0
        btfsc z___byte,z___bit
        goto label197__0end
        ; else_if { char != 0xfc } body start
        ; Just echo back the current number :
        ;   call master_send {{ 0c'<' }}  
        movlw 60
        movwf master_send__character
        call master_send
        ;   call master_octal {{ char }}  
        movf main__char,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c'>' }}  
        movlw 62
        movwf master_send__character
        call master_send
        ; Send a carriage - return line - feed :
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Output the character in octal :
        ;   call master_octal {{ number }}  
        movf main__number,w
        movwf master_octal__number
        call master_octal
        ; Send a carriage - return line - feed :
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Reset number
        ;   number := 0  
        clrf main__number
        ; else_if { char != 0xfc } body end
label197__0end:
        ; if exp=` char != 0xfc ' empty false
        ; Other expression=`{ char != 0xfc }' delay=-1
        ; if exp=` char = 0c'c' ' generic
label192__0end:
        ; Other expression=`{ char = 0c'c' }' delay=-1
        ; if exp=` char = 0c't' ' generic
label187__0end:
        ; Other expression=`{ char = 0c't' }' delay=-1
        ; if exp=` char = 0c'i' ' generic
label164__0end:
        ; Other expression=`{ char = 0c'i' }' delay=-1
        ; if exp=` char = 0c'w' ' generic
label136__0end:
        ; Other expression=`{ char = 0c'w' }' delay=-1
        ; if exp=` char = 0c's' ' generic
label125__0end:
        ; Other expression=`{ char = 0c's' }' delay=-1
        ; if exp=`char < {{ 0c'9' + 1 }}' generic
label121__1end:
        ; Other expression=`char < {{ 0c'9' + 1 }}' delay=-1
        ; if exp=`0c'0' <= char' false goto
        ; Other expression=`0c'0' <= char' delay=-1
and121__0end:
        ; if { 0c'0' <= char && char < {{ 0c'9' + 1 }} } end
        goto main__112loop__forever
        ; loop_forever ... end
        ; procedure main end

        ; procedure clock_adjust start
clock_adjust:
clock_adjust__variables__base equ global__variables__bank0+8
clock_adjust__bytes__base equ clock_adjust__variables__base+0
clock_adjust__bits__base equ clock_adjust__variables__base+10
clock_adjust__total__bytes equ 10
clock_adjust__234byte0 equ clock_adjust__bytes__base+9
clock_adjust__280byte0 equ clock_adjust__bytes__base+9
clock_adjust__290byte0 equ clock_adjust__bytes__base+9
clock_adjust__294byte0 equ clock_adjust__bytes__base+9
clock_adjust__adjust equ clock_adjust__bytes__base+0
        ; This procedure will adjust the clock to the slave .
clock_adjust__command equ clock_adjust__bytes__base+1
clock_adjust__count equ clock_adjust__bytes__base+2
clock_adjust__error equ clock_adjust__bytes__base+3
clock_adjust__error_minimum equ clock_adjust__bytes__base+4
clock_adjust__high equ clock_adjust__bytes__base+5
clock_adjust__low equ clock_adjust__bytes__base+6
clock_adjust__target equ clock_adjust__bytes__base+7
clock_adjust__wait equ clock_adjust__bytes__base+8
        ;   target := iterations_low - adjust  
        movlw 59
        movwf clock_adjust__234byte0
        movf clock_adjust__adjust,w
        subwf clock_adjust__234byte0,w
        movwf clock_adjust__target
        ;   count := 2  
        movlw 2
        movwf clock_adjust__count
        ;   error := 0xff  
        movlw 255
        movwf clock_adjust__error
        ;   error_minimum := 0xf0  
        movlw 240
        movwf clock_adjust__error_minimum
        ; Print out the target :
        ;   call master_send {{ 0c'T' }}  
        movlw 84
        movwf master_send__character
        call master_send
        ;   call master_octal {{ iterations_high }}  
        movlw 5
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ target }}  
        movf clock_adjust__target,w
        movwf master_octal__number
        call master_octal
        ;   call master_crlf {{ }}  
        call master_crlf
        ; loop_forever ... start
clock_adjust__245loop__forever:
        ; Print out the clock value :
        ;   call master_send {{ 0c'C' }}  
        movlw 67
        movwf master_send__character
        call master_send
        ;   call slave_send {{ 0xfa }}  
        movlw 250
        movwf slave_send__data
        call slave_send
        ;   call master_octal {{ slave_get {{ }} }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf master_octal__number
        call master_octal
        ; Ask for a timing byte :
        ;   call slave_send {{ 0xfb }}  
        movlw 251
        movwf slave_send__data
        call slave_send
        ;   wait := 0  
        clrf clock_adjust__wait
        ;   low := 0  
        clrf clock_adjust__low
        ;   high := 0  
        clrf clock_adjust__high
        ; `while rx_slave_pin ...' start
clock_adjust__257while__continue:
        ; expression=`rx_slave_pin' exp_delay=0 true_delay=3  false_delay=2 true_size=2 false_size=1
        btfss rx_slave_pin__byte,rx_slave_pin__bit
        goto clock_adjust__257while__break
        ; Do nothing :
        ;   wait := wait + 1  
        incf clock_adjust__wait,f
        goto clock_adjust__257while__continue
        ; if exp=`rx_slave_pin' false goto
        ; Other expression=`rx_slave_pin' delay=-1
clock_adjust__257while__break:
        ; `while rx_slave_pin ...' end
        ; `while  ! rx_slave_pin  ...' start
clock_adjust__261while__continue:
        ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=5 true_size=1 false_size=4
        btfsc rx_slave_pin__byte,rx_slave_pin__bit
        goto clock_adjust__261while__break
        ;   low := low + 1  
        incf clock_adjust__low,f
        ; if { z } start
        ; expression=`{ z }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
        btfsc z__byte,z__bit
        ; if { z } body start
        ;   high := high + 1  
        incf clock_adjust__high,f
        ; if { z } body end
        ; if exp=`z' false skip delay=2
        ; Other expression=`{ z }' delay=2
        ; if { z } end
        goto clock_adjust__261while__continue
        ; if exp=`rx_slave_pin' true goto
        ; Other expression=`rx_slave_pin' delay=-1
clock_adjust__261while__break:
        ; `while  ! rx_slave_pin  ...' end
        ; Print out high and low :
        ;   call master_send {{ 0c'H' }}  
        movlw 72
        movwf master_send__character
        call master_send
        ;   call master_octal {{ high }}  
        movf clock_adjust__high,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c'L' }}  
        movlw 76
        movwf master_send__character
        call master_send
        ;   call master_octal {{ low }}  
        movf clock_adjust__low,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c'W' }}  
        movlw 87
        movwf master_send__character
        call master_send
        ;   call master_octal {{ wait }}  
        movf clock_adjust__wait,w
        movwf master_octal__number
        call master_octal
        ; Now think about adjusting clock .
        ; if { high > iterations_high } start
        movlw 6
        subwf clock_adjust__high,w
        ; expression=`{ high > iterations_high }' exp_delay=2 true_delay=7  false_delay=-1 true_size=7 false_size=36
        btfsc c___byte,c___bit
        goto label277__0true
label277__0false:
        movlw 5
        subwf clock_adjust__high,w
        ; expression=`{ high < iterations_high }' exp_delay=2 true_delay=4  false_delay=-1 true_size=4 false_size=27
        btfss c___byte,c___bit
        goto label281__0true
label281__0false:
        ; else body start
        ; The high 8 - bits are equal :
        ; if { low > target } start
        movf clock_adjust__low,w
        subwf clock_adjust__target,w
        ; expression=`{ low > target }' exp_delay=2 true_delay=7  false_delay=-1 true_size=7 false_size=15
        btfss c___byte,c___bit
        goto label287__0true
label287__0false:
        movf clock_adjust__target,w
        subwf clock_adjust__low,w
        ; expression=`{ low < target }' exp_delay=2 true_delay=7  false_delay=3 true_size=7 false_size=3
        btfss c___byte,c___bit
        goto label291__0true
label291__0false:
        ; else body start
        ; Exact match ; we are done :
        ;   command := 0  
        clrf clock_adjust__command
        ;   error := 0  
        clrf clock_adjust__error
        ;   error_minimum := 0  
        clrf clock_adjust__error_minimum
        ; else body end
        goto label291__0end
label291__0true:
        ; else_if { low < target } body start
        ; Clock pulse is too short ; slave clock is too fast :
        ;   command := 0xf8  
        movlw 248
        movwf clock_adjust__command
        ;   error := target - low  
        movf clock_adjust__target,w
        movwf clock_adjust__294byte0
        movf clock_adjust__low,w
        subwf clock_adjust__294byte0,w
        movwf clock_adjust__error
        ; else_if { low < target } body end
        ; if exp=` low < target ' generic
label291__0end:
        ; Other expression=`{ low < target }' delay=-1
        goto label287__0end
label287__0true:
        ; if { low > target } body start
        ; Clock pulse is too long ; slave clock is too slow :
        ;   command := 0xf9  
        movlw 249
        movwf clock_adjust__command
        ;   error := low - target  
        movf clock_adjust__low,w
        movwf clock_adjust__290byte0
        movf clock_adjust__target,w
        subwf clock_adjust__290byte0,w
        movwf clock_adjust__error
        ; if { low > target } body end
        ; if exp=` low > target ' generic
label287__0end:
        ; Other expression=`{ low > target }' delay=-1
        ; if { low > target } end
        ; else body end
        goto label281__0end
label281__0true:
        ; else_if { high < iterations_high } body start
        ; Clock pulse is too short ; slave clock is too fast :
        ;   command := 0xf8  
        movlw 248
        movwf clock_adjust__command
        ;   error := target  
        movf clock_adjust__target,w
        movwf clock_adjust__error
        ; else_if { high < iterations_high } body end
        ; if exp=` high < iterations_high ' generic
label281__0end:
        ; Other expression=`{ high < iterations_high }' delay=-1
        goto label277__0end
label277__0true:
        ; if { high > iterations_high } body start
        ; Clock pulse is too long ; slave clock is too slow :
        ;   command := 0xf9  
        movlw 249
        movwf clock_adjust__command
        ;   error := 0xff - target  
        movlw 255
        movwf clock_adjust__280byte0
        movf clock_adjust__target,w
        subwf clock_adjust__280byte0,w
        movwf clock_adjust__error
        ; if { high > iterations_high } body end
        ; if exp=` high > iterations_high ' generic
label277__0end:
        ; Other expression=`{ high > iterations_high }' delay=-1
        ; if { high > iterations_high } end
        ; Print out the error and error minimum :
        ;   call master_send {{ 0c'E' }}  
        movlw 69
        movwf master_send__character
        call master_send
        ;   call master_octal {{ error }}  
        movf clock_adjust__error,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c'M' }}  
        movlw 77
        movwf master_send__character
        call master_send
        ;   call master_octal {{ error_minimum }}  
        movf clock_adjust__error_minimum,w
        movwf master_octal__number
        call master_octal
        ; if { error = error_minimum } start
        movf clock_adjust__error,w
        subwf clock_adjust__error_minimum,w
        ; expression=`{ error = error_minimum }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=2 false_size=14
        btfss z___byte,z___bit
        goto label309__0false
label309__0true:
        ; if { error = error_minimum } body start
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   return  
        retlw 0
        ; if { error = error_minimum } body end
        goto label309__0end
label309__0false:
        movf clock_adjust__error_minimum,w
        subwf clock_adjust__error,w
        ; expression=`{ error < error_minimum }' exp_delay=2 true_delay=3  false_delay=-1 true_size=3 false_size=6
        btfss c___byte,c___bit
        goto label312__0true
label312__0false:
        ; else body start
        ;   count := count - 1  
        decf clock_adjust__count,f
        ; if { z } start
        ; expression=`{ z }' exp_delay=0 true_delay=3  false_delay=0 true_size=3 false_size=0
        btfss z__byte,z__bit
        goto label317__0end
        ; if { z } body start
        ;   error_minimum := error_minimum + 1  
        incf clock_adjust__error_minimum,f
        ;   count := 2  
        movlw 2
        movwf clock_adjust__count
        ; if { z } body end
label317__0end:
        ; if exp=`z' empty false
        ; Other expression=`{ z }' delay=-1
        ; if { z } end
        ; else body end
        goto label312__0end
label312__0true:
        ; else_if { error < error_minimum } body start
        ;   error_minimum := error  
        movf clock_adjust__error,w
        movwf clock_adjust__error_minimum
        ;   error := error + 1  
        incf clock_adjust__error,f
        ; else_if { error < error_minimum } body end
        ; if exp=` error < error_minimum ' generic
label312__0end:
        ; Other expression=`{ error < error_minimum }' delay=-1
        ; if exp=` error = error_minimum ' generic
label309__0end:
        ; Other expression=`{ error = error_minimum }' delay=-1
        ; if { error = error_minimum } end
        ; Now adjust the clock :
        ;   call slave_send {{ command }}  
        movf clock_adjust__command,w
        movwf slave_send__data
        call slave_send
        ;   call master_crlf {{ }}  
        call master_crlf
        goto clock_adjust__245loop__forever
        ; loop_forever ... end
        ; procedure clock_adjust end

        ; procedure test start
test:
test__variables__base equ global__variables__bank0+18
test__bytes__base equ test__variables__base+0
test__bits__base equ test__variables__base+4
test__total__bytes equ 4
        ;   arguments_none  
        ; This procedure will test the Shaft2 RoboBrick :
test__channel equ test__bytes__base+0
test__index equ test__bytes__base+1
test__pattern equ test__bytes__base+2
test__result equ test__bytes__base+3
        ; Verify that the common commands are working :
        ;   call master_string {{ common_string }}  
        movlw LOW common_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ test_string }}  
        movlw LOW test_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   call common_test {{ }}  
        call common_test
        ;   call interrupt_test {{ }}  
        call interrupt_test
        ; Test registers :
        ;   call master_string {{ register_string }}  
        movlw LOW register_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ test_string }}  
        movlw LOW test_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Complement :
        ;   call test_register_nibble {{ 0x20 , 8 , 0x30 }}  
        movlw 32
        movwf test_register_nibble__set_command
        movlw 8
        movwf test_register_nibble__get_command
        movlw 48
        movwf test_register_nibble__error
        call test_register_nibble
        ; High :
        ;   call test_register_nibble {{ 0x40 , 9 , 0x31 }}  
        movlw 64
        movwf test_register_nibble__set_command
        movlw 9
        movwf test_register_nibble__get_command
        movlw 49
        movwf test_register_nibble__error
        call test_register_nibble
        ; Low :
        ;   call test_register_nibble {{ 0x50 , 0xa , 0x32 }}  
        movlw 80
        movwf test_register_nibble__set_command
        movlw 10
        movwf test_register_nibble__get_command
        movlw 50
        movwf test_register_nibble__error
        call test_register_nibble
        ; Raising :
        ;   call test_register_nibble {{ 0x60 , 0xb , 0x33 }}  
        movlw 96
        movwf test_register_nibble__set_command
        movlw 11
        movwf test_register_nibble__get_command
        movlw 51
        movwf test_register_nibble__error
        call test_register_nibble
        ; Falling :
        ;   call test_register_nibble {{ 0x70 , 0xc , 0x34 }}  
        movlw 112
        movwf test_register_nibble__set_command
        movlw 12
        movwf test_register_nibble__get_command
        movlw 52
        movwf test_register_nibble__error
        call test_register_nibble
        ; Test threshold registers :
        ;   call master_string {{ threshold_string }}  
        movlw LOW threshold_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ register_string }}  
        movlw LOW register_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ test_string }}  
        movlw LOW test_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   channel := 0  
        clrf test__channel
        ; `while  channel < 4  ...' start
test__369while__continue:
        movlw 4
        subwf test__channel,w
        ; expression=` channel < 4 ' exp_delay=2 true_delay=1  false_delay=2 true_size=77 false_size=1
        btfsc c___byte,c___bit
        goto test__369while__break
        ;   index := 0  
        clrf test__index
        ; `while  index < patterns . size  ...' start
test__371while__continue:
        movlw 11
        subwf test__index,w
        ; expression=` index < patterns . size ' exp_delay=2 true_delay=1  false_delay=2 true_size=70 false_size=1
        btfsc c___byte,c___bit
        goto test__371while__break
        ;   pattern := patterns ~~ {{ index }}  
        incf test__index,w
        clrf pclath___register
        call patterns
        movwf test__pattern
        ; Set high threshold :
        ;   call slave_send {{ 0x18 | channel }}  
        movlw 24
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ pattern }}  
        movf test__pattern,w
        movwf slave_send__data
        call slave_send
        ; Read high threshold :
        ;   call slave_send {{ 0x10 | channel }}  
        movlw 16
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test__result
        ; if { pattern != result } start
        movf test__pattern,w
        subwf test__result,w
        ; expression=`{ pattern != result }' exp_delay=2 true_delay=6  false_delay=0 true_size=14 false_size=0
        btfsc z___byte,z___bit
        goto label381__0end
        ; if { pattern != result } body start
        ;   call master_octal {{ channel }}  
        movf test__channel,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ pattern }}  
        movf test__pattern,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ threshold_string , 0x50 }}  
        movlw LOW threshold_string+1
        movwf master_fail__test_name
        movlw 80
        movwf master_fail__test_number
        call master_fail
        ; if { pattern != result } body end
label381__0end:
        ; if exp=` pattern != result ' empty false
        ; Other expression=`{ pattern != result }' delay=-1
        ; if { pattern != result } end
        ; Set low threshold :
        ;   call slave_send {{ 0x1c | channel }}  
        movlw 28
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ pattern }}  
        movf test__pattern,w
        movwf slave_send__data
        call slave_send
        ; Read high threshold :
        ;   call slave_send {{ 0x14 | channel }}  
        movlw 20
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test__result
        ; if { pattern != result } start
        movf test__pattern,w
        subwf test__result,w
        ; expression=`{ pattern != result }' exp_delay=2 true_delay=6  false_delay=0 true_size=14 false_size=0
        btfsc z___byte,z___bit
        goto label395__0end
        ; if { pattern != result } body start
        ;   call master_octal {{ channel }}  
        movf test__channel,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ pattern }}  
        movf test__pattern,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ threshold_string , 0x51 }}  
        movlw LOW threshold_string+1
        movwf master_fail__test_name
        movlw 81
        movwf master_fail__test_number
        call master_fail
        ; if { pattern != result } body end
label395__0end:
        ; if exp=` pattern != result ' empty false
        ; Other expression=`{ pattern != result }' delay=-1
        ; if { pattern != result } end
        ;   index := index + 1  
        incf test__index,f
        goto test__371while__continue
        ; if exp=` index < patterns . size ' false goto
        ; Other expression=` index < patterns . size ' delay=-1
test__371while__break:
        ; `while  index < patterns . size  ...' end
        ;   channel := channel + 1  
        incf test__channel,f
        goto test__369while__continue
        ; if exp=` channel < 4 ' false goto
        ; Other expression=` channel < 4 ' delay=-1
test__369while__break:
        ; `while  channel < 4  ...' end
        ; Set the Vref bit :
        ;   call slave_send {{ 0xf }}  
        movlw 15
        movwf slave_send__data
        call slave_send
        ; Test Vref bit :
        ;   call slave_send {{ 0xd }}  
        movlw 13
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test__result
        ; if { result != 1 } start
        decf test__result,w
        ; expression=`{ result != 1 }' exp_delay=1 true_delay=4  false_delay=0 true_size=8 false_size=0
        btfsc z___byte,z___bit
        goto label411__0end
        ; if { result != 1 } body start
        ;   call master_octal {{ result }}  
        movf test__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ register_string , 0x52 }}  
        movlw LOW register_string+1
        movwf master_fail__test_name
        movlw 82
        movwf master_fail__test_number
        call master_fail
        ; if { result != 1 } body end
label411__0end:
        ; if exp=` result != 1 ' empty false
        ; Other expression=`{ result != 1 }' delay=-1
        ; if { result != 1 } end
        ; Clear the Vref bit :
        ;   call slave_send {{ 0xe }}  
        movlw 14
        movwf slave_send__data
        call slave_send
        ; Test Vref bit :
        ;   call slave_send {{ 0xd }}  
        movlw 13
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test__result
        ; if { result != 0 } start
        ; expression=`{ result != 0 }' exp_delay=1 true_delay=4  false_delay=0 true_size=8 false_size=0
        btfsc z___byte,z___bit
        goto label420__0end
        ; if { result != 0 } body start
        ;   call master_octal {{ result }}  
        movf test__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ register_string , 0x53 }}  
        movlw LOW register_string+1
        movwf master_fail__test_name
        movlw 83
        movwf master_fail__test_number
        call master_fail
        ; if { result != 0 } body end
label420__0end:
        ; if exp=` result != 0 ' empty false
        ; Other expression=`{ result != 0 }' delay=-1
        ; if { result != 0 } end
        ; Now set all of the thresholds :
        ;   channel := 0  
        clrf test__channel
        ; `while  channel < 4  ...' start
test__427while__continue:
        movlw 4
        subwf test__channel,w
        ; expression=` channel < 4 ' exp_delay=2 true_delay=9  false_delay=2 true_size=16 false_size=1
        btfsc c___byte,c___bit
        goto test__427while__break
        ; Set high threshold :
        ;   call slave_send {{ 0x18 | channel }}  
        movlw 24
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ 0xc0 }}  
        movlw 192
        movwf slave_send__data
        call slave_send
        ; Set low threshold :
        ;   call slave_send {{ 0x1c | channel }}  
        movlw 28
        iorwf test__channel,w
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ 0x40 }}  
        movlw 64
        movwf slave_send__data
        call slave_send
        ;   channel := channel + 1  
        incf test__channel,f
        goto test__427while__continue
        ; if exp=` channel < 4 ' false goto
        ; Other expression=` channel < 4 ' delay=-1
test__427while__break:
        ; `while  channel < 4  ...' end
        ; Test some shaft inputs :
        ;   call master_string {{ input_string }}  
        movlw LOW input_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ test_string }}  
        movlw LOW test_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ; Set all inputs low :
        ;   call test_input {{ 0 , 0 }}  
        clrf test_input__channel
        clrf test_input__target
        call test_input
        ;   call test_input {{ 1 , 0 }}  
        movlw 1
        movwf test_input__channel
        clrf test_input__target
        call test_input
        ;   call test_input {{ 2 , 0 }}  
        movlw 2
        movwf test_input__channel
        clrf test_input__target
        call test_input
        ;   call test_input {{ 3 , 0 }}  
        movlw 3
        movwf test_input__channel
        clrf test_input__target
        call test_input
        ;   call test_binary {{ 0 , 0x60 }}  
        clrf test_binary__pattern
        movlw 96
        movwf test_binary__error
        call test_binary
        ; Set all inputs high , one by one :
        ;   call test_input {{ 0 , 0xff }}  
        clrf test_input__channel
        movlw 255
        movwf test_input__target
        call test_input
        ;   call test_binary {{ 1 , 0x64 }}  
        movlw 1
        movwf test_binary__pattern
        movlw 100
        movwf test_binary__error
        call test_binary
        ;   call test_input {{ 1 , 0xff }}  
        movlw 1
        movwf test_input__channel
        movlw 255
        movwf test_input__target
        call test_input
        ;   call test_binary {{ 3 , 0x68 }}  
        movlw 3
        movwf test_binary__pattern
        movlw 104
        movwf test_binary__error
        call test_binary
        ;   call test_input {{ 2 , 0xff }}  
        movlw 2
        movwf test_input__channel
        movlw 255
        movwf test_input__target
        call test_input
        ;   call test_binary {{ 7 , 0x6c }}  
        movlw 7
        movwf test_binary__pattern
        movlw 108
        movwf test_binary__error
        call test_binary
        ;   call test_input {{ 3 , 0xff }}  
        movlw 3
        movwf test_input__channel
        movlw 255
        movwf test_input__target
        call test_input
        ;   call test_binary {{ 0xf , 0x70 }}  
        movlw 15
        movwf test_binary__pattern
        movlw 112
        movwf test_binary__error
        call test_binary
        ; Now do some interrupt tests :
        ; Low :
        ;   call test_interrupt {{ 0x50 , 0 }}  
        movlw 80
        movwf test_interrupt__mask_set_command
        clrf test_interrupt__target
        call test_interrupt
        ; High :
        ;   call test_interrupt {{ 0x40 , 0xff }}  
        movlw 64
        movwf test_interrupt__mask_set_command
        movlw 255
        movwf test_interrupt__target
        call test_interrupt
        ; Falling :
        ;   call test_interrupt {{ 0x70 , 0 }}  
        movlw 112
        movwf test_interrupt__mask_set_command
        clrf test_interrupt__target
        call test_interrupt
        ; Raising :
        ;   call test_interrupt {{ 0x60 , 0xff }}  
        movlw 96
        movwf test_interrupt__mask_set_command
        movlw 255
        movwf test_interrupt__target
        call test_interrupt
        ; Set channel 1 to half value :
        ;   call test_input {{ 1 , 0x80 }}  
        movlw 1
        movwf test_input__channel
        movlw 128
        movwf test_input__target
        call test_input
        ; Lastly put the puppy in Vref mode :
        ;   call slave_send {{ 0xf }}  
        movlw 15
        movwf slave_send__data
        call slave_send
        ;   call test_input {{ 0 , 0x80 }}  
        clrf test_input__channel
        movlw 128
        movwf test_input__target
        call test_input
        ;   call test_input {{ 2 , 0x80 }}  
        movlw 2
        movwf test_input__channel
        movlw 128
        movwf test_input__target
        call test_input
        ;   call test_input {{ 3 , 0x80 }}  
        movlw 3
        movwf test_input__channel
        movlw 128
        movwf test_input__target
        call test_input
        ; Say we are done :
        ;   call master_string {{ done_string }}  
        movlw LOW done_string+1
        movwf master_string__message
        call master_string
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure test end
        retlw 0

        ; procedure test_input start
test_input:
test_input__variables__base equ global__variables__bank0+22
test_input__bytes__base equ test_input__variables__base+0
test_input__bits__base equ test_input__variables__base+3
test_input__total__bytes equ 3
test_input__channel equ test_input__bytes__base+0
test_input__target equ test_input__bytes__base+1
        ; This procedure will verify that we can input a value of < target >
        ; from < channel > .
test_input__actual equ test_input__bytes__base+2
        ;   actual := target ^ 0x55  
        movlw 85
        xorwf test_input__target,w
        movwf test_input__actual
        ; `while  actual != target  ...' start
test_input__495while__continue:
        movf test_input__actual,w
        subwf test_input__target,w
        ; expression=` actual != target ' exp_delay=2 true_delay=20  false_delay=2 true_size=36 false_size=1
        btfsc z___byte,z___bit
        goto test_input__495while__break
        ;   call master_send {{ cr }}  
        movlw 13
        movwf master_send__character
        call master_send
        ;   call master_string {{ channel_string }}  
        movlw LOW channel_string+1
        movwf master_string__message
        call master_string
        ;   call master_octal {{ channel }}  
        movf test_input__channel,w
        movwf master_octal__number
        call master_octal
        ;   call master_string {{ input_string }}  
        movlw LOW input_string+1
        movwf master_string__message
        call master_string
        ;   call slave_send {{ channel }}  
        movf test_input__channel,w
        movwf slave_send__data
        call slave_send
        ;   actual := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test_input__actual
        ;   call master_octal {{ actual }}  
        movwf master_octal__number
        call master_octal
        ; if { actual = target } start
        movf test_input__actual,w
        subwf test_input__target,w
        ; expression=`{ actual = target }' exp_delay=2 true_delay=-1  false_delay=-1 true_size=1 false_size=1
        btfsc z___byte,z___bit
        ; if { actual = target } body start
        ;   call master_send {{ 0c'=' }}  
        movlw 61
        ; 2 instructions found for sharing
        btfss z___byte,z___bit
        ; else body start
        ;   call master_send {{ 0c'~' }}  
        movlw 126
        ; 2 instructions found for sharing
        ; if exp=` actual = target ' single true and false skip delay=6
        ; Other expression=`{ actual = target }' delay=6
        ; 2 shared instructions follow
        movwf master_send__character
        call master_send
        ; if { actual = target } end
        ;   call master_octal {{ target }}  
        movf test_input__target,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c':' }}  
        movlw 58
        movwf master_send__character
        call master_send
        goto test_input__495while__continue
        ; if exp=` actual != target ' false goto
        ; Other expression=` actual != target ' delay=-1
test_input__495while__break:
        ; `while  actual != target  ...' end
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure test_input end
        retlw 0

        ; procedure test_register_nibble start
test_register_nibble:
test_register_nibble__variables__base equ global__variables__bank0+25
test_register_nibble__bytes__base equ test_register_nibble__variables__base+0
test_register_nibble__bits__base equ test_register_nibble__variables__base+5
test_register_nibble__total__bytes equ 5
test_register_nibble__set_command equ test_register_nibble__bytes__base+0
test_register_nibble__get_command equ test_register_nibble__bytes__base+1
test_register_nibble__error equ test_register_nibble__bytes__base+2
        ; This procedure will verify that the register that is set with
        ; < set_command > and read with < get_command > can take values between
        ; 0 and < maximum > . If there are any problems < error > is used as the
        ; error code .
test_register_nibble__value equ test_register_nibble__bytes__base+3
test_register_nibble__result equ test_register_nibble__bytes__base+4
        ;   value := 0  
        clrf test_register_nibble__value
        ; `while  value < 16  ...' start
test_register_nibble__529while__continue:
        movlw 16
        subwf test_register_nibble__value,w
        ; expression=` value < 16 ' exp_delay=2 true_delay=1  false_delay=2 true_size=27 false_size=1
        btfsc c___byte,c___bit
        goto test_register_nibble__529while__break
        ;   call slave_send {{ set_command | value }}  
        movf test_register_nibble__set_command,w
        iorwf test_register_nibble__value,w
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ get_command }}  
        movf test_register_nibble__get_command,w
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test_register_nibble__result
        ; if { value != result } start
        movf test_register_nibble__value,w
        subwf test_register_nibble__result,w
        ; expression=`{ value != result }' exp_delay=2 true_delay=5  false_delay=0 true_size=11 false_size=0
        btfsc z___byte,z___bit
        goto label533__0end
        ; if { value != result } body start
        ;   call master_octal {{ value }}  
        movf test_register_nibble__value,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test_register_nibble__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ register_string , error }}  
        movlw LOW register_string+1
        movwf master_fail__test_name
        movf test_register_nibble__error,w
        movwf master_fail__test_number
        call master_fail
        ; if { value != result } body end
label533__0end:
        ; if exp=` value != result ' empty false
        ; Other expression=`{ value != result }' delay=-1
        ; if { value != result } end
        ;   value := value + 1  
        incf test_register_nibble__value,f
        goto test_register_nibble__529while__continue
        ; if exp=` value < 16 ' false goto
        ; Other expression=` value < 16 ' delay=-1
test_register_nibble__529while__break:
        ; `while  value < 16  ...' end
        ; Clear the pattern :
        ;   call slave_send {{ set_command }}  
        movf test_register_nibble__set_command,w
        movwf slave_send__data
        call slave_send
        ; procedure test_register_nibble end
        retlw 0

        ; procedure test_binary start
test_binary:
test_binary__variables__base equ global__variables__bank0+30
test_binary__bytes__base equ test_binary__variables__base+0
test_binary__bits__base equ test_binary__variables__base+3
test_binary__total__bytes equ 3
test_binary__pattern equ test_binary__bytes__base+0
test_binary__error equ test_binary__bytes__base+1
        ; This procedure will verify that the binary pattern matches < pattern > .
        ; If it does not , < error > is the error code used .
test_binary__result equ test_binary__bytes__base+2
        ; First verify that we read out the correct pattern :
        ;   call slave_send {{ 4 }}  
        movlw 4
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test_binary__result
        ; if { result != pattern } start
        subwf test_binary__pattern,w
        ; expression=`{ result != pattern }' exp_delay=2 true_delay=5  false_delay=0 true_size=11 false_size=0
        btfsc z___byte,z___bit
        goto label557__0end
        ; if { result != pattern } body start
        ;   call master_octal {{ pattern }}  
        movf test_binary__pattern,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test_binary__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ binary_string , error }}  
        movlw LOW binary_string+1
        movwf master_fail__test_name
        movf test_binary__error,w
        movwf master_fail__test_number
        call master_fail
        ; if { result != pattern } body end
label557__0end:
        ; if exp=` result != pattern ' empty false
        ; Other expression=`{ result != pattern }' delay=-1
        ; if { result != pattern } end
        ; Test complement :
        ;   call slave_send {{ 0x2f }}  
        movlw 47
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ 4 }}  
        movlw 4
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test_binary__result
        ; if { result != pattern ^ 0xf } start
        movlw 15
        xorwf test_binary__pattern,w
        subwf test_binary__result,w
        ; expression=`{ result != pattern ^ 0xf }' exp_delay=3 true_delay=6  false_delay=0 true_size=12 false_size=0
        btfsc z___byte,z___bit
        goto label567__0end
        ; if { result != pattern ^ 0xf } body start
        ;   call master_octal {{ pattern }}  
        movf test_binary__pattern,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test_binary__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ binary_string , error | 1 }}  
        movlw LOW binary_string+1
        movwf master_fail__test_name
        movlw 1
        iorwf test_binary__error,w
        movwf master_fail__test_number
        call master_fail
        ; if { result != pattern ^ 0xf } body end
label567__0end:
        ; if exp=` result != pattern ^ 0xf ' empty false
        ; Other expression=`{ result != pattern ^ 0xf }' delay=-1
        ; if { result != pattern ^ 0xf } end
        ; Test raw :
        ;   call slave_send {{ 5 }}  
        movlw 5
        movwf slave_send__data
        call slave_send
        ;   result := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf test_binary__result
        ; if { result != pattern } start
        subwf test_binary__pattern,w
        ; expression=`{ result != pattern }' exp_delay=2 true_delay=6  false_delay=0 true_size=12 false_size=0
        btfsc z___byte,z___bit
        goto label576__0end
        ; if { result != pattern } body start
        ;   call master_octal {{ pattern }}  
        movf test_binary__pattern,w
        movwf master_octal__number
        call master_octal
        ;   call master_octal {{ result }}  
        movf test_binary__result,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ binary_string , error | 2 }}  
        movlw LOW binary_string+1
        movwf master_fail__test_name
        movlw 2
        iorwf test_binary__error,w
        movwf master_fail__test_number
        call master_fail
        ; if { result != pattern } body end
label576__0end:
        ; if exp=` result != pattern ' empty false
        ; Other expression=`{ result != pattern }' delay=-1
        ; if { result != pattern } end
        ; Reset complement :
        ;   call slave_send {{ 0x20 }}  
        movlw 32
        movwf slave_send__data
        call slave_send
        ; procedure test_binary end
        retlw 0

        ; procedure test_interrupt start
test_interrupt:
test_interrupt__variables__base equ global__variables__bank0+33
test_interrupt__bytes__base equ test_interrupt__variables__base+0
test_interrupt__bits__base equ test_interrupt__variables__base+2
test_interrupt__total__bytes equ 2
test_interrupt__mask_set_command equ test_interrupt__bytes__base+0
test_interrupt__target equ test_interrupt__bytes__base+1
        ; This procedure will test interrupts shaft .
        ; Set mask bit :
        ;   call slave_send {{ mask_set_command | 1 }}  
        movlw 1
        iorwf test_interrupt__mask_set_command,w
        movwf slave_send__data
        call slave_send
        ;   call master_octal {{ target }}  
        movf test_interrupt__target,w
        movwf master_octal__number
        call master_octal
        ;   call master_send {{ 0c':' }}  
        movlw 58
        movwf master_send__character
        call master_send
        ; Set interrupt enable and clear interrupt pending :
        ;   call slave_send {{ 0xf2 }}  
        movlw 242
        movwf slave_send__data
        call slave_send
        ; Wait for an interrupt :
        ; `while rx_slave_pin ...' start
test_interrupt__603while__continue:
        ; expression=`rx_slave_pin' exp_delay=0 true_delay=2  false_delay=2 true_size=1 false_size=1
        btfsc rx_slave_pin__byte,rx_slave_pin__bit
        ; Wait for bit to go low :
        goto test_interrupt__603while__continue
        goto test_interrupt__603while__break
        ; if exp=`rx_slave_pin' true goto small true
test_interrupt__603while__break:
        ; `while rx_slave_pin ...' end
        ; Clear mask bit :
        ;   call slave_send {{ mask_set_command }}  
        movf test_interrupt__mask_set_command,w
        movwf slave_send__data
        call slave_send
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure test_interrupt end
        retlw 0
        ; comment {The procedures below are used to test the common shared commands :}

        ; procedure common_test start
common_test:
common_test__variables__base equ global__variables__bank0+35
common_test__bytes__base equ common_test__variables__base+0
common_test__bits__base equ common_test__variables__base+2
common_test__total__bytes equ 2
common_test__658byte0 equ common_test__bytes__base+1
        ;   arguments_none  
        ; This procedure will verify that the common shared commands work .
common_test__actual equ common_test__bytes__base+0
        ; Print the ID information :
        ; ID reset :
        ;   call slave_send {{ 0xfd }}  
        movlw 253
        movwf slave_send__data
        call slave_send
        ; Read the fixed bytes :
        ;   call common_test_id_match {{ 1 , 0xc0 }}  
        movlw 1
        movwf common_test_id_match__desired
        movlw 192
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 0 , 0xc1 }}  
        clrf common_test_id_match__desired
        movlw 193
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 12 , 0xc2 }}  
        movlw 12
        movwf common_test_id_match__desired
        movlw 194
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 1 , 0xc3 }}  
        movlw 1
        movwf common_test_id_match__desired
        movlw 195
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 0 , 0xc4 }}  
        clrf common_test_id_match__desired
        movlw 196
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 0 , 0xc5 }}  
        clrf common_test_id_match__desired
        movlw 197
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 0 , 0xc6 }}  
        clrf common_test_id_match__desired
        movlw 198
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call common_test_id_match {{ 0 , 0xc7 }}  
        clrf common_test_id_match__desired
        movlw 199
        movwf common_test_id_match__test_number
        call common_test_id_match
        ;   call master_crlf {{ }}  
        call master_crlf
        ;   call common_test_id_bytes8 {{ }}  
        call common_test_id_bytes8
        ;   call common_test_id_bytes8 {{ }}  
        call common_test_id_bytes8
        ; Read the brick name :
        ;   call common_test_id_string {{ }}  
        call common_test_id_string
        ; Read the vendor name :
        ;   call common_test_id_string {{ }}  
        call common_test_id_string
        ; Verfify that we don ' t read off the end of the id and crash :
        ;   call common_test_id_next {{ }}  
        call common_test_id_next
        movf common_test_id_next__0return__byte,w
        ; Reset id :
        ;   call slave_send {{ 0xfd }}  
        movlw 253
        movwf slave_send__data
        call slave_send
        ; Verify that we are still alive :
        ;   call common_test_id_match {{ 1 , 0xc8 }}  
        movlw 1
        movwf common_test_id_match__desired
        movlw 200
        movwf common_test_id_match__test_number
        call common_test_id_match
        ; Read glitch :
        ; Clear glitch register :
        ;   call slave_send {{ 0xfe }}  
        movlw 254
        movwf slave_send__data
        call slave_send
        ;   actual := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf common_test__actual
        ; Send a couple of glitches :
        ;   call slave_send {{ 0xff }}  
        movlw 255
        movwf slave_send__data
        call slave_send
        ;   call slave_send {{ 0xff }}  
        movlw 255
        movwf slave_send__data
        call slave_send
        ; Read the glitch register :
        ;   call slave_send {{ 0xfe }}  
        movlw 254
        movwf slave_send__data
        call slave_send
        ; if { slave_get {{ }} != 2 } start
        call slave_get
        movf slave_get__0return__byte,w
        movwf common_test__658byte0
        movlw 2
        subwf common_test__658byte0,w
        ; expression=`{ slave_get {{ }} != 2 }' exp_delay=3 true_delay=3  false_delay=0 true_size=5 false_size=0
        btfsc z___byte,z___bit
        goto label658__1end
        ; if { slave_get {{ }} != 2 } body start
        ;   call master_fail {{ common_string , 0xc9 }}  
        movlw LOW common_string+1
        movwf master_fail__test_name
        movlw 201
        movwf master_fail__test_number
        call master_fail
        ; if { slave_get {{ }} != 2 } body end
label658__1end:
        ; if exp=` slave_get ## {{ }} != 2 ' empty false
        ; Other expression=`{ slave_get {{ }} != 2 }' delay=-1
        ; if { slave_get {{ }} != 2 } end
        ; Do a clock pulse :
        ;   call slave_send {{ 0xfb }}  
        movlw 251
        movwf slave_send__data
        call slave_send
        ; if { slave_get {{ }} != 0 } start
        call slave_get
        movf slave_get__0return__byte,w
        ; expression=`{ slave_get {{ }} != 0 }' exp_delay=0 true_delay=3  false_delay=0 true_size=5 false_size=0
        btfsc z___byte,z___bit
        goto label664__0end
        ; if { slave_get {{ }} != 0 } body start
        ;   call master_fail {{ common_string , 0xca }}  
        movlw LOW common_string+1
        movwf master_fail__test_name
        movlw 202
        movwf master_fail__test_number
        call master_fail
        ; if { slave_get {{ }} != 0 } body end
label664__0end:
        ; if exp=` slave_get ## {{ }} != 0 ' empty false
        ; Other expression=`{ slave_get {{ }} != 0 }' delay=-1
        ; if { slave_get {{ }} != 0 } end
        ; Read clock :
        ;   call slave_send {{ 0xfa }}  
        movlw 250
        movwf slave_send__data
        call slave_send
        ;   actual := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf common_test__actual
        ; Increment :
        ;   call slave_send {{ 0xf9 }}  
        movlw 249
        movwf slave_send__data
        call slave_send
        ; Decrement :
        ;   call slave_send {{ 0xf8 }}  
        movlw 248
        movwf slave_send__data
        call slave_send
        ; Read clock again :
        ;   call slave_send {{ 0xfa }}  
        movlw 250
        movwf slave_send__data
        call slave_send
        ; if { actual != slave_get {{ }} } start
        call slave_get
        movf slave_get__0return__byte,w
        subwf common_test__actual,w
        ; expression=`{ actual != slave_get {{ }} }' exp_delay=1 true_delay=3  false_delay=0 true_size=5 false_size=0
        btfsc z___byte,z___bit
        goto label676__0end
        ; if { actual != slave_get {{ }} } body start
        ;   call master_fail {{ common_string , 0xcb }}  
        movlw LOW common_string+1
        movwf master_fail__test_name
        movlw 203
        movwf master_fail__test_number
        call master_fail
        ; if { actual != slave_get {{ }} } body end
label676__0end:
        ; if exp=` actual != slave_get ## {{ }} ' empty false
        ; Other expression=`{ actual != slave_get {{ }} }' delay=-1
        ; if { actual != slave_get {{ }} } end
        ; procedure common_test end
        retlw 0

        ; procedure common_test_id_match start
common_test_id_match:
common_test_id_match__variables__base equ global__variables__bank0+37
common_test_id_match__bytes__base equ common_test_id_match__variables__base+0
common_test_id_match__bits__base equ common_test_id_match__variables__base+3
common_test_id_match__total__bytes equ 3
common_test_id_match__desired equ common_test_id_match__bytes__base+0
common_test_id_match__test_number equ common_test_id_match__bytes__base+1
        ; This procedure will verify that the next byte in the id is < desired > .
common_test_id_match__id equ common_test_id_match__bytes__base+2
        ;   id := common_test_id_next {{ }}  
        call common_test_id_next
        movf common_test_id_next__0return__byte,w
        movwf common_test_id_match__id
        ;   call master_octal {{ id }}  
        movwf master_octal__number
        call master_octal
        ; if { desired != id } start
        movf common_test_id_match__desired,w
        subwf common_test_id_match__id,w
        ; expression=`{ desired != id }' exp_delay=2 true_delay=3  false_delay=0 true_size=5 false_size=0
        btfsc z___byte,z___bit
        goto label692__0end
        ; if { desired != id } body start
        ;   call master_fail {{ common_string , test_number }}  
        movlw LOW common_string+1
        movwf master_fail__test_name
        movf common_test_id_match__test_number,w
        movwf master_fail__test_number
        call master_fail
        ; if { desired != id } body end
label692__0end:
        ; if exp=` desired != id ' empty false
        ; Other expression=`{ desired != id }' delay=-1
        ; if { desired != id } end
        ; procedure common_test_id_match end
        retlw 0

        ; procedure common_test_id_bytes8 start
common_test_id_bytes8:
common_test_id_bytes8__variables__base equ global__variables__bank0+40
common_test_id_bytes8__bytes__base equ common_test_id_bytes8__variables__base+0
common_test_id_bytes8__bits__base equ common_test_id_bytes8__variables__base+1
common_test_id_bytes8__total__bytes equ 1
        ;   arguments_none  
        ; This procedure will print out the next 8 bytes of the id in octal .
common_test_id_bytes8__count equ common_test_id_bytes8__bytes__base+0
        ; `count_down count 8 ...' start
        movlw 8
        movwf common_test_id_bytes8__count
common_test_id_bytes8__705_loop:
        ;   call master_octal {{ common_test_id_next {{ }} }}  
        call common_test_id_next
        movf common_test_id_next__0return__byte,w
        movwf master_octal__number
        call master_octal
        decfsz common_test_id_bytes8__count,f
        goto common_test_id_bytes8__705_loop
common_test_id_bytes8__705_done:
        ; `count_down count 8 ...' end
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure common_test_id_bytes8 end
        retlw 0

        ; procedure common_test_id_string start
common_test_id_string:
common_test_id_string__variables__base equ global__variables__bank0+41
common_test_id_string__bytes__base equ common_test_id_string__variables__base+0
common_test_id_string__bits__base equ common_test_id_string__variables__base+1
common_test_id_string__total__bytes equ 1
        ;   arguments_none  
        ; This procedure will print out the next id string .
common_test_id_string__count equ common_test_id_string__bytes__base+0
        ; `count_down count  common_test_id_next ## {{ }}  ...' start
        call common_test_id_next
        movf common_test_id_next__0return__byte,w
        movwf common_test_id_string__count
common_test_id_string__719_loop:
        ;   call master_send {{ common_test_id_next {{ }} }}  
        call common_test_id_next
        movf common_test_id_next__0return__byte,w
        movwf master_send__character
        call master_send
        decfsz common_test_id_string__count,f
        goto common_test_id_string__719_loop
common_test_id_string__719_done:
        ; `count_down count  common_test_id_next ## {{ }}  ...' end
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure common_test_id_string end
        retlw 0

        ; procedure common_test_id_next start
common_test_id_next:
common_test_id_next__variables__base equ global__variables__bank0+42
common_test_id_next__bytes__base equ common_test_id_next__variables__base+0
common_test_id_next__bits__base equ common_test_id_next__variables__base+1
common_test_id_next__total__bytes equ 1
        ;   arguments_none  
common_test_id_next__0return__byte equ common_test_id_next__bytes__base+0
        ; This procedure returns the next byte from the identification string .
        ;   call slave_send {{ 0xfc }}  
        movlw 252
        movwf slave_send__data
        call slave_send
        ;   return slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf common_test_id_next__0return__byte
        retlw 0
        ; procedure common_test_id_next end
        ; comment {The procedures below are used to test the shared interrupt commands :}

        ; procedure interrupt_test start
interrupt_test:
interrupt_test__variables__base equ global__variables__bank0+43
interrupt_test__bytes__base equ interrupt_test__variables__base+0
interrupt_test__bits__base equ interrupt_test__variables__base+1
interrupt_test__total__bytes equ 1
        ;   arguments_none  
        ; This procedure tests the common shared interrupt commands .
interrupt_test__counter equ interrupt_test__bytes__base+0
        ; Clear interrupt bits :
        ;   call slave_send {{ 0xf0 }}  
        movlw 240
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xd0 }}  
        clrf interrupt_read__desired
        movlw 208
        movwf interrupt_read__test_number
        call interrupt_read
        ; Set / clear interrupt pending bit only :
        ;   call slave_send {{ 0xf5 }}  
        movlw 245
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 1 , 0xd1 }}  
        movlw 1
        movwf interrupt_read__desired
        movlw 209
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf4 }}  
        movlw 244
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xd2 }}  
        clrf interrupt_read__desired
        movlw 210
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf1 }}  
        movlw 241
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 1 , 0xd3 }}  
        movlw 1
        movwf interrupt_read__desired
        movlw 211
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf0 }}  
        movlw 240
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xd4 }}  
        clrf interrupt_read__desired
        movlw 212
        movwf interrupt_read__test_number
        call interrupt_read
        ; Set / clear interrupt enable bit only :
        ;   call slave_send {{ 0xf7 }}  
        movlw 247
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 2 , 0xd5 }}  
        movlw 2
        movwf interrupt_read__desired
        movlw 213
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf6 }}  
        movlw 246
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xd6 }}  
        clrf interrupt_read__desired
        movlw 214
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf2 }}  
        movlw 242
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 2 , 0xd7 }}  
        movlw 2
        movwf interrupt_read__desired
        movlw 215
        movwf interrupt_read__test_number
        call interrupt_read
        ;   call slave_send {{ 0xf0 }}  
        movlw 240
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xd8 }}  
        clrf interrupt_read__desired
        movlw 216
        movwf interrupt_read__test_number
        call interrupt_read
        ; Now set both the interrupt enable and pending bit .
        ; This must trigger an interrupt .
        ;   call slave_send {{ 0xf3 }}  
        movlw 243
        movwf slave_send__data
        call slave_send
        ; `count_down counter 3 ...' start
        movlw 3
        movwf interrupt_test__counter
interrupt_test__773_loop:
        ;   call delay {{ }}  
        call delay
        decfsz interrupt_test__counter,f
        goto interrupt_test__773_loop
interrupt_test__773_done:
        ; `count_down counter 3 ...' end
        ; if { rx_slave_pin } start
        ; expression=`{ rx_slave_pin }' exp_delay=0 true_delay=3  false_delay=0 true_size=5 false_size=0
        btfss rx_slave_pin__byte,rx_slave_pin__bit
        goto label776__0end
        ; if { rx_slave_pin } body start
        ; No interrupt detected :
        ;   call master_fail {{ interrupt_string , 0xd9 }}  
        movlw LOW interrupt_string+1
        movwf master_fail__test_name
        movlw 217
        movwf master_fail__test_number
        call master_fail
        ; if { rx_slave_pin } body end
label776__0end:
        ; if exp=`rx_slave_pin' empty false
        ; Other expression=`{ rx_slave_pin }' delay=-1
        ; if { rx_slave_pin } end
        ; Read the interrupt enable bit is cleared as a side effect
        ; of reading the bit .
        ;   call interrupt_read {{ 1 , 0xda }}  
        movlw 1
        movwf interrupt_read__desired
        movlw 218
        movwf interrupt_read__test_number
        call interrupt_read
        ; Clear the interrupt pending bit :
        ;   call slave_send {{ 0xf0 }}  
        movlw 240
        movwf slave_send__data
        call slave_send
        ;   call interrupt_read {{ 0 , 0xdb }}  
        clrf interrupt_read__desired
        movlw 219
        movwf interrupt_read__test_number
        call interrupt_read
        ; procedure interrupt_test end
        retlw 0

        ; procedure interrupt_read start
interrupt_read:
interrupt_read__variables__base equ global__variables__bank0+44
interrupt_read__bytes__base equ interrupt_read__variables__base+0
interrupt_read__bits__base equ interrupt_read__variables__base+2
interrupt_read__total__bytes equ 2
interrupt_read__desired equ interrupt_read__bytes__base+0
interrupt_read__test_number equ interrupt_read__bytes__base+1
        ; This procedure will verify that the interrupt bits match < desired > .
        ;   call slave_send {{ 0xef }}  
        movlw 239
        movwf slave_send__data
        call slave_send
        ;   temp := slave_get {{ }}  
        call slave_get
        movf slave_get__0return__byte,w
        movwf temp
        ; if { temp != desired } start
        subwf interrupt_read__desired,w
        ; expression=`{ temp != desired }' exp_delay=2 true_delay=4  false_delay=0 true_size=8 false_size=0
        btfsc z___byte,z___bit
        goto label798__0end
        ; if { temp != desired } body start
        ;   call master_octal {{ temp }}  
        movf temp,w
        movwf master_octal__number
        call master_octal
        ;   call master_fail {{ interrupt_string , test_number }}  
        movlw LOW interrupt_string+1
        movwf master_fail__test_name
        movf interrupt_read__test_number,w
        movwf master_fail__test_number
        call master_fail
        ; if { temp != desired } body end
label798__0end:
        ; if exp=` temp != desired ' empty false
        ; Other expression=`{ temp != desired }' delay=-1
        ; if { temp != desired } end
        ; procedure interrupt_read end
        retlw 0
        ; comment {The following procedures are used to communicate with the master :}

        ; procedure master_crlf start
master_crlf:
master_crlf__variables__base equ global__variables__bank0+46
master_crlf__bytes__base equ master_crlf__variables__base+0
master_crlf__bits__base equ master_crlf__variables__base+0
master_crlf__total__bytes equ 0
        ;   arguments_none  
        ; This procedure will output a carriage - return line - feed
        ; to the master .
        ;   call master_send {{ cr }}  
        movlw 13
        movwf master_send__character
        call master_send
        ;   call master_send {{ lf }}  
        movlw 10
        movwf master_send__character
        call master_send
        ; procedure master_crlf end
        retlw 0

        ; procedure master_fail start
master_fail:
master_fail__variables__base equ global__variables__bank0+46
master_fail__bytes__base equ master_fail__variables__base+0
master_fail__bits__base equ master_fail__variables__base+2
master_fail__total__bytes equ 2
master_fail__test_name equ master_fail__bytes__base+0
master_fail__test_number equ master_fail__bytes__base+1
        ; This procedure will output ` fail ' followed by a carriage return
        ; and line feed .
        ;   call master_string {{ fail_string }}  
        movlw LOW fail_string+1
        movwf master_string__message
        call master_string
        ;   call master_string {{ test_name }}  
        movf master_fail__test_name,w
        movwf master_string__message
        call master_string
        ;   call master_octal {{ test_number }}  
        movf master_fail__test_number,w
        movwf master_octal__number
        call master_octal
        ;   call master_crlf {{ }}  
        call master_crlf
        ; procedure master_fail end
        retlw 0

        ; procedure master_get start
master_get:
master_get__variables__base equ global__variables__bank0+48
master_get__bytes__base equ master_get__variables__base+0
master_get__bits__base equ master_get__variables__base+1
master_get__total__bytes equ 1
        ;   arguments_none  
master_get__0return__byte equ master_get__bytes__base+0
        ; This procedure will get the next byte or return 0xfc if
        ; no byte is forthcoming .
        ;   return get_byte {{ rx_master_mask }}  
        movlw 2
        movwf get_byte__mask
        call get_byte
        movf get_byte__0return__byte,w
        movwf master_get__0return__byte
        retlw 0
        ; procedure master_get end

        ; procedure master_octal start
master_octal:
master_octal__variables__base equ global__variables__bank0+49
master_octal__bytes__base equ master_octal__variables__base+0
master_octal__bits__base equ master_octal__variables__base+2
master_octal__total__bytes equ 2
master_octal__848byte0 equ master_octal__bytes__base+1
master_octal__849byte0 equ master_octal__bytes__base+1
master_octal__number equ master_octal__bytes__base+0
        ; This procedure will output < number > in octal to the tx port .
        ; Output the character in octal :
        ;   call master_send {{ {{ number >> 6 }} + 0c'0' }}  
        swapf master_octal__number,w
        movwf master_octal__848byte0
        rrf master_octal__848byte0,f
        rrf master_octal__848byte0,w
        andlw 3
        addlw 48
        movwf master_send__character
        call master_send
        ;   call master_send {{ {{ {{ number >> 3 }} & 7 }} + 0c'0' }}  
        rrf master_octal__number,w
        movwf master_octal__849byte0
        rrf master_octal__849byte0,f
        rrf master_octal__849byte0,w
        andlw 7
        addlw 48
        movwf master_send__character
        call master_send
        ;   call master_send {{ {{ number & 7 }} + 0c'0' }}  
        movlw 7
        andwf master_octal__number,w
        addlw 48
        movwf master_send__character
        call master_send
        ;   call master_send {{ sp }}  
        movlw 32
        movwf master_send__character
        call master_send
        ; procedure master_octal end
        retlw 0

        ; procedure slave_get start
slave_get:
slave_get__variables__base equ global__variables__bank0+51
slave_get__bytes__base equ slave_get__variables__base+0
slave_get__bits__base equ slave_get__variables__base+1
slave_get__total__bytes equ 1
        ;   arguments_none  
slave_get__0return__byte equ slave_get__bytes__base+0
        ; This procedure will get a byte from the slave or return 0xfc
        ; if no byte is forthcoming .
        ;   return get_byte {{ rx_slave_mask }}  
        movlw 32
        movwf get_byte__mask
        call get_byte
        movf get_byte__0return__byte,w
        movwf slave_get__0return__byte
        retlw 0
        ; procedure slave_get end

        ; procedure slave_send start
slave_send:
slave_send__variables__base equ global__variables__bank0+52
slave_send__bytes__base equ slave_send__variables__base+0
slave_send__bits__base equ slave_send__variables__base+1
slave_send__total__bytes equ 1
slave_send__data equ slave_send__bytes__base+0
        ; This procedure will send one byte of < data > to the slave .
        ;   call send_byte {{ data , tx_slave_mask }}  
        movf slave_send__data,w
        movwf send_byte__char
        movlw 16
        movwf send_byte__mask
        call send_byte
        ; procedure slave_send end
        retlw 0
        ; comment {The last procedures do character sending and receiving :}

        ; procedure get_byte start
get_byte:
get_byte__variables__base equ global__variables__bank0+53
get_byte__bytes__base equ get_byte__variables__base+0
get_byte__bits__base equ get_byte__variables__base+5
get_byte__total__bytes equ 5
get_byte__905byte1 equ get_byte__bytes__base+4
get_byte__mask equ get_byte__bytes__base+0
get_byte__0return__byte equ get_byte__bytes__base+1
        ; Get an 8 - bit byte from < mask > bit of < portb > and return it .
        ; If no character shows up in a while 0xfc is returned .
get_byte__count equ get_byte__bytes__base+2
get_byte__char equ get_byte__bytes__base+3
        ; Wait until a start bit arrives :
        ;   count := 0  
        clrf get_byte__count
        ; `while  portb & mask != 0  ...' start
get_byte__887while__continue:
        movf portb,w
        andwf get_byte__mask,w
        ; expression=` portb & mask != 0 ' exp_delay=2 true_delay=1  false_delay=2 true_size=9 false_size=1
        btfsc z___byte,z___bit
        goto get_byte__887while__break
        ;   count := count - 1  
        decf get_byte__count,f
        ; if { count = 0 } start
        movf get_byte__count,w
        ; expression=`{ count = 0 }' exp_delay=1 true_delay=3  false_delay=0 true_size=3 false_size=0
        btfss z___byte,z___bit
        goto label889__0end
        ; if { count = 0 } body start
        ;   return 0xfc  
        movlw 252
        movwf get_byte__0return__byte
        retlw 0
        ; if { count = 0 } body end
label889__0end:
        ; if exp=` count = 0 ' empty false
        ; Other expression=`{ count = 0 }' delay=-1
        ; if { count = 0 } end
        ;   call delay {{ }}  
        call delay
        goto get_byte__887while__continue
        ; if exp=` portb & mask != 0 ' false goto
        ; Other expression=` portb & mask != 0 ' delay=-1
get_byte__887while__break:
        ; `while  portb & mask != 0  ...' end
        ; Skip over the start bit :
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; Sample in the middle third of each data bit :
        ; 1 cycle :
        ;   char := 0  
        clrf get_byte__char
        ; 2 cycles for loop setup :
        ; 1 + 2 = 3
        ; nop extra_instructions_per_bit - 3
        ; Delay 9 cycles
        movlw 2
        movwf get_byte__905byte1
get_byte__905delay0:
        decfsz get_byte__905byte1,f
        goto get_byte__905delay0
        nop
        nop
        ; `count_down count 8 ...' start
        movlw 8
        movwf get_byte__count
get_byte__906_loop:
        ;   call delay {{ }}  
        call delay
        ; 2 cycles :
        ;   char := char >> 1  
        bcf c___byte,c___bit
        rrf get_byte__char,f
        ; 3 cycles :
        ; if { portb & mask != 0 } start
        movf portb,w
        andwf get_byte__mask,w
        ; expression=`{ portb & mask != 0 }' exp_delay=2 true_delay=1  false_delay=0 true_size=1 false_size=0
        btfss z___byte,z___bit
        ; if { portb & mask != 0 } body start
        ;   char @ 7 := 1  
        ; Select char @ 7
get_byte__char__912select0 equ get_byte__char+0
get_byte__char__912select0__byte equ get_byte__char+0
get_byte__char__912select0__bit equ 7
        bsf get_byte__char__912select0__byte,get_byte__char__912select0__bit
        ; if { portb & mask != 0 } body end
        ; if exp=` portb & mask != 0 ' false skip delay=4
        ; Other expression=`{ portb & mask != 0 }' delay=4
        ; if { portb & mask != 0 } end
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 3 cycles at end of loop :
        ; 2 + 3 + 3 = 8
        ; nop extra_instructions_per_bit - 8
        ; Delay 4 cycles
        nop
        nop
        nop
        nop
        decfsz get_byte__count,f
        goto get_byte__906_loop
get_byte__906_done:
        ; `count_down count 8 ...' end
        ; Skip over 1 / 3 of the stop bit :
        ;   call delay {{ }}  
        call delay
        ;   return char  
        movf get_byte__char,w
        movwf get_byte__0return__byte
        retlw 0
        ; procedure get_byte end

        ; procedure send_byte start
send_byte:
send_byte__variables__base equ global__variables__bank0+58
send_byte__bytes__base equ send_byte__variables__base+0
send_byte__bits__base equ send_byte__variables__base+4
send_byte__total__bytes equ 4
send_byte__char equ send_byte__bytes__base+0
send_byte__mask equ send_byte__bytes__base+1
        ; Send < char > to < mask > bit of < portb > .
send_byte__count equ send_byte__bytes__base+2
send_byte__mark equ send_byte__bytes__base+3
        ; Send the start bit :
        ; 3 cycles :
        ;   mark := mask ^ space  
        movlw 255
        xorwf send_byte__mask,w
        movwf send_byte__mark
        ; 1 cycle < mark is already in W > :
        ;   portb := mark  
        movwf portb
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 2 cycles for loop setup :
        ; 3 + 1 + 2 = 6
        ; nop extra_instructions_per_bit - 6
        ; Delay 6 cycles
        nop
        nop
        nop
        nop
        nop
        nop
        ; Send the data :
        ; `count_down count 8 ...' start
        movlw 8
        movwf send_byte__count
send_byte__950_loop:
        ; 5 cycles :
        ; if { char @ 0 } start
        ; Alias variable for select char @ 0
send_byte__char__952select0 equ send_byte__char+0
send_byte__char__952select0__byte equ send_byte__char+0
send_byte__char__952select0__bit equ 0
        ; expression=`{ char @ 0 }' exp_delay=0 true_delay=1  false_delay=1 true_size=1 false_size=1
        btfsc send_byte__char__952select0__byte,send_byte__char__952select0__bit
        ; if { char @ 0 } body start
        ;   portb := space  
        movlw 255
        ; 1 instructions found for sharing
        btfss send_byte__char__952select0__byte,send_byte__char__952select0__bit
        ; else body start
        ;   portb := mark  
        movf send_byte__mark,w
        ; 1 instructions found for sharing
        ; if exp=` char @ 0 ' single true and false skip delay=4
        ; Other expression=`{ char @ 0 }' delay=4
        ; 1 shared instructions follow
        movwf portb
        ; if { char @ 0 } end
        ; 2 cycles :
        ;   char := char >> 1  
        bcf c___byte,c___bit
        rrf send_byte__char,f
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 3 cycles at end of loop :
        ; 5 + 2 + 3 = 10
        ; nop extra_instructions_per_bit - 10
        ; Delay 2 cycles
        nop
        nop
        decfsz send_byte__count,f
        goto send_byte__950_loop
send_byte__950_done:
        ; `count_down count 8 ...' end
        ; Send the stop bit :
        ; 1 cycle to finish off previous loop :
        ; nop 1
        ; Delay 1 cycles
        nop
        ; 2 cycles :
        ;   portb := space  
        movlw 255
        movwf portb
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 4 cycles for call / return :
        ; 4 cycles for tw arguments :
        ; 2 + 4 + 4 = 10
        ; nop extra_instructions_per_bit - 10
        ; Delay 2 cycles
        nop
        nop
        ; procedure send_byte end
        retlw 0

        ; procedure master_send start
master_send:
master_send__variables__base equ global__variables__bank0+62
master_send__bytes__base equ master_send__variables__base+0
master_send__bits__base equ master_send__variables__base+1
master_send__total__bytes equ 1
master_send__character equ master_send__bytes__base+0
        ; This procedure will output < character > to the master .
        ;   call send_byte {{ character , tx_master_mask }}  
        movf master_send__character,w
        movwf send_byte__char
        movlw 4
        movwf send_byte__mask
        call send_byte
        ; procedure master_send end
        retlw 0

        ; procedure master_string start
master_string:
master_string__variables__base equ global__variables__bank0+63
master_string__bytes__base equ master_string__variables__base+0
master_string__bits__base equ master_string__variables__base+3
master_string__total__bytes equ 3
master_string__message equ master_string__bytes__base+0
        ; This procedure will output < message > to the master .
master_string__size equ master_string__bytes__base+1
master_string__index equ master_string__bytes__base+2
        ;   index := 0  
        clrf master_string__index
        ; `while  index < message . size  ...' start
master_string__1000while__continue:
        clrf pclath___register
        movf master_string__message,w
        call string___fetch
        subwf master_string__index,w
        ; expression=` index < message . size ' exp_delay=4 true_delay=7  false_delay=2 true_size=8 false_size=1
        btfsc c___byte,c___bit
        goto master_string__1000while__break
        ;   call master_send {{ message ~~ {{ index }} }}  
        incf master_string__index,w
        addwf master_string__message,w
        clrf pclath___register
        call string___fetch
        movwf master_send__character
        call master_send
        ;   index := index + 1  
        incf master_string__index,f
        goto master_string__1000while__continue
        ; if exp=` index < message . size ' false goto
        ; Other expression=` index < message . size ' delay=-1
master_string__1000while__break:
        ; `while  index < message . size  ...' end
        ;   call master_send {{ sp }}  
        movlw 32
        movwf master_send__character
        call master_send
        ; procedure master_string end
        retlw 0

        ; procedure delay start
        ; optimize 0
delay:
delay__variables__base equ global__variables__bank0+66
delay__bytes__base equ delay__variables__base+0
delay__bits__base equ delay__variables__base+1
delay__total__bytes equ 1
delay__1007byte1 equ delay__bytes__base+0
        ;   arguments_none  
        ;   uniform_delay delay_instructions  
        ; Uniform delay remaining = 339 Accumulated Delay = 0
        ; Uniform delay remaining = 339 Accumulated Delay = 0
        ; Delay 1 third of a bit :
        ; Uniform delay remaining = 339 Accumulated Delay = 0
        ;   watch_dog_reset  
        clrwdt
        ; Uniform delay remaining = 338 Accumulated Delay = 1
        ; Uniform delay remaining = 338 Accumulated Delay = 1
        ; Soak up remaining 338 cycles
        ; Delay 338 cycles
        movlw 112
        movwf delay__1007byte1
delay__1007delay0:
        decfsz delay__1007byte1,f
        goto delay__1007delay0
        nop
        ; procedure delay end
        retlw 0
        ; optimize 1

        ; Register bank 0 used 67 bytes of 96 available bytes
        ; Register bank 1 used 0 bytes of 80 available bytes
        ; Register bank 2 used 0 bytes of 48 available bytes
        ; Register bank 3 used 0 bytes of 0 available bytes

        end

