        radix dec
global__variables__bank0 equ 8
global__variables__bank1 equ 48
global__variables__bank2 equ 80
global__variables__bank3 equ 112
global__bit__variables__bank0 equ 18
global__bit__variables__bank1 equ 57
global__bit__variables__bank2 equ 80
global__bit__variables__bank3 equ 112
indf___register equ 0
pcl___register equ 2
c___byte equ 3
c___bit equ 0
z___byte equ 3
z___bit equ 2
        ; On 12-bit PIC's, RP0 is actually bit 5 in FSR (=4)
rp0___byte equ 4
rp0___bit equ 5
        ; On 12-bit PIC's, RP1 is actually bit 6 in FSR (=4)
rp1___byte equ 4
rp1___bit equ 6
        ; On 12-bit PIC's, PA0 is actually bit 5 in STATUS (=3)
pa0___byte equ 3
pa0___bit equ 5
fsr___register equ 4
        org 0
start:
        ; Use oscillator calibration value already in register W
        movwf 5
        ; Initialize TRIS registers
b___tris equ global__variables__bank1+9
        movlw 203
        tris 6
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf b___tris
        movlw 192
        tris 7
        ; Switch from code bank 0 to code bank 1 before possible transfer (goto)
        bsf pa0___byte,pa0___bit
        goto main
        ; comment #############################################################################
        ; comment {}
        ; comment {Copyright < c > 2002 - 2003 by Wayne C . Gramlich and Bill Benson}
        ; 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 the code that implements the CompassDT1 RoboBrick . Basically}
        ; comment {it just waits for commands that come in at 2400 baud and responds}
        ; comment {to them . See}
        ; comment {}
        ; comment {http : / / gramlich . net / projects / robobricks / compassdt1 / index . html}
        ; comment {}
        ; comment {for more details .}
        ; comment {}
        ; comment #############################################################################
        ;   processor pic16c505 cp = off wdte = on mclre = off fosc = intrc_no_clock  
        ; 4052=0xfd4 4095=0xfff
        __config 4052
configuration___address equ 4095
        ; comment {Define processor constants :}
        ;   constant clock_rate 4000000  
clock_rate equ 4000000
        ;   constant clocks_per_instruction 4  
clocks_per_instruction equ 4
        ;   constant instruction_rate clock_rate / clocks_per_instruction  
instruction_rate equ 1000000
        ; comment {Define serial communication control constants :}
        ;   constant baud_rate 2400  
baud_rate equ 2400
        ;   constant instructions_per_bit instruction_rate / baud_rate  
instructions_per_bit equ 416
        ;   constant delays_per_bit 3  
delays_per_bit equ 3
        ;   constant instructions_per_delay instructions_per_bit / delays_per_bit  
instructions_per_delay equ 138
        ;   constant extra_instructions_per_bit 9  
extra_instructions_per_bit equ 9
        ;   constant extra_instructions_per_delay extra_instructions_per_bit / delays_per_bit  
extra_instructions_per_delay equ 3
        ;   constant delay_instructions instructions_per_delay - extra_instructions_per_delay  
delay_instructions equ 135
        ; comment {Register definitions :}
        ; comment {Status register :}
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 {OSCCAL register :}
osccal equ 5
        ;   constant osccal_lsb 4  
osccal_lsb equ 4
        ;   constant i2c_delay 3  
i2c_delay equ 3
        ; comment {Define bit offsets :}
        ;   constant d1_bit 5  
d1_bit equ 5
        ;   constant d2_bit 4  
d2_bit equ 4
        ;   constant d3_bit 3  
d3_bit equ 3
        ;   constant d4_bit 2  
d4_bit equ 2
        ;   constant d5_bit 1  
d5_bit equ 1
        ;   constant d6_bit 0  
d6_bit equ 0
        ;   constant scl_bit 0  
scl_bit equ 0
        ;   constant sda_bit 1  
sda_bit equ 1
        ;   constant freq_bit 2  
freq_bit equ 2
        ;   constant serial_in_bit 3  
serial_in_bit equ 3
        ;   constant serial_out_bit 4  
serial_out_bit equ 4
        ;   constant trigger_bit 5  
trigger_bit equ 5
        ; comment {Define pin assignments and directions :}
portb equ 6
portc equ 7
d1__byte equ 7
d1__bit equ 5
d2__byte equ 7
d2__bit equ 4
d3__byte equ 7
d3__bit equ 3
d4__byte equ 7
d4__bit equ 2
d5__byte equ 7
d5__bit equ 1
d6__byte equ 7
d6__bit equ 0
scl__byte equ 6
scl__bit equ 0
sda__byte equ 6
sda__bit equ 1
trigger__byte equ 6
trigger__bit equ 5
freq__byte equ 6
freq__bit equ 2
serial_out__byte equ 6
serial_out__bit equ 4
serial_in__byte equ 6
serial_in__bit equ 3
        ;   constant mask 0x1f  
mask equ 31
        ; string_constants Start
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (label)
        bcf pa0___byte,pa0___bit
string___fetch:
        movwf pcl___register
        ;   id = 1 , 0 , 13 , 1 , 0 , 0 , 0 , 0 , 0r'16' , 11 , 0s'CompassDT1C' , 15 , 0s'Gramlich&Benson'  
id___string equ 0
id:
        addwf pcl___register,f
        ; Length = 52
        retlw 52
        ; 1
        retlw 1
        ; 0
        retlw 0
        ; 13
        retlw 13
        ; 1
        retlw 1
        ; 0
        retlw 0
        ; 0
        retlw 0
        ; 0
        retlw 0
        ; 0
        retlw 0
        ; 0r'16'
        retlw 51 ; random number
        retlw 211 ; random number
        retlw 73 ; random number
        retlw 121 ; random number
        retlw 167 ; random number
        retlw 100 ; random number
        retlw 106 ; random number
        retlw 35 ; random number
        retlw 173 ; random number
        retlw 108 ; random number
        retlw 161 ; random number
        retlw 145 ; random number
        retlw 7 ; random number
        retlw 10 ; random number
        retlw 42 ; random number
        retlw 222 ; random number
        ; 11
        retlw 11
        ; `CompassDT1C'
        retlw 67
        retlw 111
        retlw 109
        retlw 112
        retlw 97
        retlw 115
        retlw 115
        retlw 68
        retlw 84
        retlw 49
        retlw 67
        ; 15
        retlw 15
        ; `Gramlich&Benson'
        retlw 71
        retlw 114
        retlw 97
        retlw 109
        retlw 108
        retlw 105
        retlw 99
        retlw 104
        retlw 38
        retlw 66
        retlw 101
        retlw 110
        retlw 115
        retlw 111
        retlw 110
        ; string__constants End
        ; comment {Some globals : byte}
interrupt_enable equ global__bit__variables__bank0+0
interrupt_enable__byte equ global__bit__variables__bank0+0
interrupt_enable__bit equ 0
interrupt_pending equ global__bit__variables__bank0+0
interrupt_pending__byte equ global__bit__variables__bank0+0
interrupt_pending__bit equ 1
receiving equ global__bit__variables__bank0+0
receiving__byte equ global__bit__variables__bank0+0
receiving__bit equ 2
        ;   bank 1  
        ; Default register bank is now 1
temporary equ global__variables__bank1+0
glitch equ global__variables__bank1+1
index equ global__variables__bank1+2
        ; comment {Note that the 12 - bit PIC ' s only have a 2 - level deep stack .}
        ; comment {The code starts in the main procedure < located at the end of this code >}
        ; comment {The next level of procedure call is either get_byte or send_byte .}
        ; comment {Lastly , the lowest level of procedure call is delay . It all fits ,}
        ; comment {but just barely .}
        ;   bank 0  
        ; Default register bank is now 0

        ; procedure i2c_start start
i2c_start:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
i2c_start__variables__base equ global__variables__bank0+1
i2c_start__bytes__base equ i2c_start__variables__base+0
i2c_start__bits__base equ i2c_start__variables__base+0
i2c_start__total__bytes equ 1
        ;   arguments_none  
        ; Invariant : SCL = OC & SDA = OC
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction sda write  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; Invariant : SCL = 0 V & SDA = 0 V
        ; procedure i2c_start end
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        retlw 0

        ; procedure i2c_restart start
i2c_restart:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
i2c_restart__variables__base equ global__variables__bank0+2
i2c_restart__bytes__base equ i2c_restart__variables__base+0
i2c_restart__bits__base equ i2c_restart__variables__base+0
i2c_restart__total__bytes equ 0
        ;   arguments_none  
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction sda read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl read  
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction sda write  
        bcf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; procedure i2c_restart end
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        retlw 0

        ; procedure i2c_stop start
i2c_stop:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
i2c_stop__variables__base equ global__variables__bank0+2
i2c_stop__bytes__base equ i2c_stop__variables__base+0
i2c_stop__bits__base equ i2c_stop__variables__base+0
i2c_stop__total__bytes equ 0
        ;   arguments_none  
        ; Invariant : SCL = 0 V & SDA = 0 V
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction sda read  
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; Invariant : SCL = OC & SDA = OC
        ; procedure i2c_stop end
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        retlw 0

        ; procedure i2c_get_byte start
i2c_get_byte:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
i2c_get_byte__variables__base equ global__variables__bank0+2
i2c_get_byte__bytes__base equ i2c_get_byte__variables__base+0
i2c_get_byte__bits__base equ i2c_get_byte__variables__base+3
i2c_get_byte__total__bytes equ 3
        ;   arguments_none  
i2c_get_byte__0return__byte equ i2c_get_byte__bytes__base+0
        ; This procedure will wait for a byte to be received from
        ; serial_in_bit . It calls the delay procedure for all delays .
i2c_get_byte__count equ i2c_get_byte__bytes__base+1
i2c_get_byte__char equ i2c_get_byte__bytes__base+2
        ; Invariant : SCL = 0 V & SDA = 0 V
        ;   direction sda read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; `count_down count 8 ...' start
        movlw 8
        movwf i2c_get_byte__count
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
i2c_get_byte__158_loop:
        ;   char := char << 1  
        bcf c___byte,c___bit
        rlf i2c_get_byte__char,f
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; if { sda } start
        ; expression=`{ sda }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
        btfsc sda__byte,sda__bit
        ; if { sda } body start
        ;   char @ 0 := 1  
        ; Select char @ 0
i2c_get_byte__char__165select0 equ i2c_get_byte__char+0
i2c_get_byte__char__165select0__byte equ i2c_get_byte__char+0
i2c_get_byte__char__165select0__bit equ 0
        bsf i2c_get_byte__char__165select0__byte,i2c_get_byte__char__165select0__bit
        ; if { sda } body end
        ; if exp=`sda' false skip delay=2
        ; Other expression=`{ sda }' delay=2
        ; if { sda } end
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Request switch to bank 0
        decfsz i2c_get_byte__count,f
        goto i2c_get_byte__158_loop
i2c_get_byte__158_done:
        ; `count_down count 8 ...' end
        ; Clock in ACK bit :
        ;   direction sda write  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl read  
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; Invariant : SCL = 0 V & SDA = 0 V
        ;   return char  
        movf i2c_get_byte__char,w
        movwf i2c_get_byte__0return__byte
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        retlw 0
        ; procedure i2c_get_byte end

        ; procedure i2c_send_byte start
i2c_send_byte:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
i2c_send_byte__variables__base equ global__variables__bank0+5
i2c_send_byte__bytes__base equ i2c_send_byte__variables__base+0
i2c_send_byte__bits__base equ i2c_send_byte__variables__base+2
i2c_send_byte__total__bytes equ 2
i2c_send_byte__data equ i2c_send_byte__bytes__base+0
        ; Send < data > to compass using I2c :
i2c_send_byte__count equ i2c_send_byte__bytes__base+1
        ; Invariant : SCL = 0 V & SDA = 0 V
        ; Send 8 - bits of data :
        ; `count_down count 8 ...' start
        movlw 8
        movwf i2c_send_byte__count
i2c_send_byte__194_loop:
        ; if { data @ 7 } start
        ; Alias variable for select data @ 7
i2c_send_byte__data__195select0 equ i2c_send_byte__data+0
i2c_send_byte__data__195select0__byte equ i2c_send_byte__data+0
i2c_send_byte__data__195select0__bit equ 7
        ; expression=`{ data @ 7 }' exp_delay=0 true_delay=2  false_delay=2 true_size=2 false_size=2
        btfss i2c_send_byte__data__195select0__byte,i2c_send_byte__data__195select0__bit
        goto label195__1false
label195__1true:
        ; if { data @ 7 } body start
        ;   direction sda read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,sda__bit
        ; 2 instructions found for sharing
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        goto label195__1end
label195__1false:
        ; else body start
        ;   direction sda write  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf b___tris,sda__bit
        ; 2 instructions found for sharing
        ; if exp=` data @ 7 ' generic
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
label195__1end:
        ; Other expression=`{ data @ 7 }' delay=-1
        ; 2 shared instructions follow
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movf b___tris,w
        tris 6
        ; if { data @ 7 } end
        ;   data := data << 1  
        bcf c___byte,c___bit
        rlf i2c_send_byte__data,f
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction sda read  
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Request switch to bank 0
        decfsz i2c_send_byte__count,f
        goto i2c_send_byte__194_loop
i2c_send_byte__194_done:
        ; `count_down count 8 ...' end
        ; Clock in ACK bit :
        ;   direction sda read  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop i2c_delay
        ; Delay 3 cycles
        nop
        nop
        nop
        ;   direction scl read  
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ;   count := 255  
        movlw 255
        movwf i2c_send_byte__count
        ; `while  sda && count != 0  ...' start
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
i2c_send_byte__213while__continue:
        ; expression=`sda' exp_delay=0 true_delay=-1  false_delay=4 true_size=5 false_size=1
        btfss sda__byte,sda__bit
        goto and213__0false
        movf i2c_send_byte__count,w
        ; expression=`count != 0' exp_delay=1 true_delay=3  false_delay=2 true_size=2 false_size=1
        btfsc z___byte,z___bit
and213__0false:
        goto i2c_send_byte__213while__break
and213__0true:
        ;   count := count - 1  
        decf i2c_send_byte__count,f
        goto i2c_send_byte__213while__continue
        ; if exp=`count != 0' false goto
        ; Other expression=`count != 0' delay=-1
        ; if exp=`sda' false goto
        ; Other expression=`sda' delay=-1
and213__0end:
i2c_send_byte__213while__break:
        ; `while  sda && count != 0  ...' end
        ;   direction scl write  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ;   count := 255  
        movlw 255
        movwf i2c_send_byte__count
        ; `while  ! sda && count != 0  ...' start
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
i2c_send_byte__218while__continue:
        ; expression=`sda' exp_delay=0 true_delay=4  false_delay=-1 true_size=1 false_size=5
        btfsc sda__byte,sda__bit
        goto and218__0false
        movf i2c_send_byte__count,w
        ; expression=`count != 0' exp_delay=1 true_delay=3  false_delay=2 true_size=2 false_size=1
        btfsc z___byte,z___bit
and218__0false:
        goto i2c_send_byte__218while__break
and218__0true:
        ;   count := count - 1  
        decf i2c_send_byte__count,f
        goto i2c_send_byte__218while__continue
        ; if exp=`count != 0' false goto
        ; Other expression=`count != 0' delay=-1
        ; if exp=`sda' true goto
        ; Other expression=`sda' delay=-1
and218__0end:
i2c_send_byte__218while__break:
        ; `while  ! sda && count != 0  ...' end
        ; Grab the SDA back again :
        ;   direction sda write  
        ; Switch from register bank 0 to register bank 1 (which contains b___tris)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; Invariant : SCL = 0 V & SDA = 0 V
        ; procedure i2c_send_byte end
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        retlw 0

        ; procedure get_byte start
get_byte:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 0
        ; Procedure must be called with PCLATH set to code bank 0
get_byte__variables__base equ global__variables__bank0+7
get_byte__bytes__base equ get_byte__variables__base+0
get_byte__bits__base equ get_byte__variables__base+3
get_byte__total__bytes equ 3
        ;   arguments_none  
get_byte__0return__byte equ get_byte__bytes__base+0
        ; This procedure will wait for a byte to be received from
        ; serial_in_bit . It calls the delay procedure for all delays .
get_byte__count equ get_byte__bytes__base+1
get_byte__char equ get_byte__bytes__base+2
        ; Why does the delay procedure wait for a third of bit ? Well , it
        ; has to do with the loop immediately below . If we catch the
        ; start bit at the beginning of a 1 / 3 bit time , we will be
        ; sampling data at approximately 1 / 3 of the way into each bit .
        ; Conversely , if we catch the start near the end of a 1 / 3 bit
        ; bit time , we will be sampling data at approximately 2 / 3 of the
        ; way into each bit . So , what this means is that our bit sample
        ; times will be somewhere between 1 / 3 and 2 / 3 of bit < i . e . in
        ; the middle of the bit .
        ; It would be nice to tweak the code to shorter delay times
        ; < 1 / 4 bit , 1 / 5 bit , etc . > but then it gets too hard to get
        ; the bookeeping done in the delay routine . A 12 - bit PIC
        ; running at 4 MHz <= 1 MIPS > , only has 138 instructions available
        ; for the delay routine when at 1 / 3 of bit .
        ; Wait for a start bit :
        ;   receiving := 1  
        bsf receiving__byte,receiving__bit
        ; `while serial_in ...' start
get_byte__255while__continue:
        ; expression=`serial_in' exp_delay=0 true_delay=1  false_delay=2 true_size=2 false_size=1
        btfss serial_in__byte,serial_in__bit
        goto get_byte__255while__break
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (goto)
        bcf pa0___byte,pa0___bit
        goto get_byte__255while__continue
        ; if exp=`serial_in' false goto
        ; Other expression=`serial_in' delay=-1
get_byte__255while__break:
        ; `while serial_in ...' end
        ; Clear interrupt :
        ; 1 cycle :
        ;   serial_out := 1  
        bsf serial_out__byte,serial_out__bit
        ; Skip over start bit :
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; Sample in the middle third of each data bit ;
        ; 1 cycle :
        ;   char := 0  
        ; Switch from register bank 1 to register bank 0 (which contains get_byte__char)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        clrf get_byte__char
        ; 2 cycles to set up loop :
        ; 1 + 1 + 2 = 4
        ; nop extra_instructions_per_bit - 4
        ; Delay 5 cycles
        nop
        nop
        nop
        nop
        nop
        ; `count_down count 8 ...' start
        movlw 8
        movwf get_byte__count
        ; Switch from code bank 1 to code bank 0 before possible transfer (label)
        bcf pa0___byte,pa0___bit
get_byte__274_loop:
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        ; 2 cycles :
        ;   char := char >> 1  
        bcf c___byte,c___bit
        ; Switch from register bank 1 to register bank 0 (which contains get_byte__char)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        rrf get_byte__char,f
        ; 2 cycles :
        ; if { serial_in } start
        ; expression=`{ serial_in }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
        ; Switch from code bank 1 to code bank 0 before possible transfer (btfsc)
        bcf pa0___byte,pa0___bit
        btfsc serial_in__byte,serial_in__bit
        ; if { serial_in } body start
        ;   char @ 7 := 1  
        ; Select char @ 7
get_byte__char__280select0 equ get_byte__char+0
get_byte__char__280select0__byte equ get_byte__char+0
get_byte__char__280select0__bit equ 7
        bsf get_byte__char__280select0__byte,get_byte__char__280select0__bit
        ; if { serial_in } body end
        ; if exp=`serial_in' false skip delay=2
        ; Other expression=`{ serial_in }' delay=2
        ; if { serial_in } end
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        ;   call delay {{ }}  
        call delay
        ; 3 cycles at end of loop :
        ; 2 + 2 + 3 = 7
        ; nop extra_instructions_per_bit - 7
        ; Delay 2 cycles
        nop
        nop
        ; Switch from register bank 1 to register bank 0 (which contains get_byte__count)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (decfsz)
        bcf pa0___byte,pa0___bit
        decfsz get_byte__count,f
        goto get_byte__274_loop
get_byte__274_done:
        ; `count_down count 8 ...' end
        ; Skip over 2 / 3 ' s of stop bit :
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        ;   call delay {{ }}  
        call delay
        ;   return char  
        ; Switch from register bank 1 to register bank 0 (which contains get_byte__char)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        movf get_byte__char,w
        movwf get_byte__0return__byte
        ; Switch from code bank 1 to code bank 0 before possible transfer (retlw)
        bcf pa0___byte,pa0___bit
        retlw 0
        ; procedure get_byte end
        ;   origin 0x200  
        org 512
        ;   bank 1  
        ; Default register bank is now 1

        ; procedure send_byte start
send_byte:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 1
        ; Procedure must be called with PCLATH set to code bank 0
send_byte__variables__base equ global__variables__bank1+3
send_byte__bytes__base equ send_byte__variables__base+0
send_byte__bits__base equ send_byte__variables__base+2
send_byte__total__bytes equ 2
send_byte__char equ send_byte__bytes__base+0
        ; Send < char > to < tx > :
send_byte__count equ send_byte__bytes__base+1
        ; < receiving > will be 1 if the last get / put routine was a get .
        ; Before we start transmitting a response back , we want to ensure
        ; that there has been enough time to turn the line around .
        ; We delay the first 1 / 3 of a bit to pad out the 9 - 2 / 3 bits from
        ; for get_byte to 10 bits . We delay another 1 / 3 of a bit just
        ; for good measure . Technically , the second call to delay < >
        ; is not really needed .
        ; if { receiving } start
        ; expression=`{ receiving }' exp_delay=0 true_delay=-1  false_delay=0 true_size=3 false_size=0
        ; Switch from register bank 1 to register bank 0 (which contains receiving__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf z___byte,z___bit
        btfsc receiving__byte,receiving__bit
        bsf z___byte,z___bit
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        btfss z___byte,z___bit
        goto label313__0end
        ; if { receiving } body start
        ;   receiving := 0  
        ; Switch from register bank 1 to register bank 0 (which contains receiving__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf receiving__byte,receiving__bit
        ;   call delay {{ }}  
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        call delay
        ;   call delay {{ }}  
        call delay
        ; if { receiving } body end
label313__0end:
        ; if exp=`receiving' empty false
        ; Other expression=`{ receiving }' delay=-1
        ; if { receiving } end
        ; Send the start bit :
        ; 1 cycle :
        ;   serial_out := 0  
        bcf serial_out__byte,serial_out__bit
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 2 cycles to set up loop :
        ; 1 + 2 = 3
        ; nop extra_instructions_per_bit - 3
        ; 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__331_loop:
        ; 4 cycles :
        ;   serial_out := char @ 0  
        ; Alias variable for select char @ 0
send_byte__char__333select0 equ send_byte__char+0
send_byte__char__333select0__byte equ send_byte__char+0
send_byte__char__333select0__bit equ 0
        btfss send_byte__char__333select0__byte,send_byte__char__333select0__bit
        bcf serial_out__byte,serial_out__bit
        btfsc send_byte__char__333select0__byte,send_byte__char__333select0__bit
        bsf serial_out__byte,serial_out__bit
        ; 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 :
        ; 4 + 2 + 3 = 9 = no NOP ' s needed :
        decfsz send_byte__count,f
        goto send_byte__331_loop
send_byte__331_done:
        ; `count_down count 8 ...' end
        ; Send the stop bit :
        ; nop 1
        ; Delay 1 cycles
        nop
        ; 1 cycle
        ;   serial_out := 1  
        bsf serial_out__byte,serial_out__bit
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ;   call delay {{ }}  
        call delay
        ; 2 cycles for call / return
        ; 2 cycles for argument
        ; 1 + 2 + 2 = 5
        ; nop extra_instructions_per_bit - 5
        ; Delay 4 cycles
        nop
        nop
        nop
        nop
        ; procedure send_byte end
        retlw 0

        ; procedure delay start
        ; optimize 0
delay:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 1
        ; Procedure must be called with PCLATH set to code bank 0
delay__variables__base equ global__variables__bank1+5
delay__bytes__base equ delay__variables__base+0
delay__bits__base equ delay__variables__base+1
delay__total__bytes equ 1
delay__356byte1 equ delay__bytes__base+0
        ;   arguments_none  
        ;   uniform_delay delay_instructions  
        ; Uniform delay remaining = 131 Accumulated Delay = 0
        ; Uniform delay remaining = 131 Accumulated Delay = 0
        ; This procedure delays 1 / 3 of a bit .
        ; Uniform delay remaining = 131 Accumulated Delay = 0
        ; Uniform delay remaining = 131 Accumulated Delay = 0
        ; Kick the dog :
        ; Uniform delay remaining = 131 Accumulated Delay = 0
        ;   watch_dog_reset  
        clrwdt
        ; Uniform delay remaining = 130 Accumulated Delay = 1
        ; Uniform delay remaining = 130 Accumulated Delay = 1
        ; Soak up remaining 130 cycles
        ; Delay 130 cycles
        movlw 43
        movwf delay__356byte1
delay__356delay0:
        decfsz delay__356byte1,f
        goto delay__356delay0
        ; procedure delay end
        retlw 0
        ; optimize 1
        ; comment {The main procedure is loaded with switch statements . On the 12 - bit}
        ; comment {PIC ' s , switch statements have to live in the first 256 bytes of}
        ; comment {each code bank . For this reason , we shove main into code bank 1 .}
        ; comment {If we , try to put main in code bank 0 , it pushes the first bytes}
        ; comment {of several routines out of the first 256 bytes , which is also a}
        ; comment {no - no of the 12 - bit PIC ' s .}

        ; procedure main start
switch__424block_start:
        addwf pcl___register,f
        goto switch__424block425
        goto switch__424block438
        goto switch__424block450
        goto switch__424block455
        goto switch__424block475
        goto switch__424block475
        goto switch__424block475
        goto switch__424block475
switch__424block_end:
        ; switch_check 424 switch__424block_start switch__424block_end
switch__421block_start:
        addwf pcl___register,f
        goto switch__421block422
        goto switch__421block480
        goto switch__421block483
        goto switch__421block486
        goto switch__421block489
        goto switch__421block489
        goto switch__421block489
        goto switch__421block489
switch__421block_end:
        ; switch_check 421 switch__421block_start switch__421block_end
switch__529block_start:
        addwf pcl___register,f
        goto switch__529block530
        goto switch__529block530
        goto switch__529block530
        goto switch__529block530
        goto switch__529block535
        goto switch__529block535
        goto switch__529block539
        goto switch__529block539
switch__529block_end:
        ; switch_check 529 switch__529block_start switch__529block_end
switch__546block_start:
        addwf pcl___register,f
        goto switch__546block547
        goto switch__546block551
        goto switch__546block555
        goto switch__546block559
        goto switch__546block563
        goto switch__546block571
        goto switch__546block575
        goto switch__546block580
switch__546block_end:
        ; switch_check 546 switch__546block_start switch__546block_end
switch__504block_start:
        addwf pcl___register,f
        goto switch__504block505
        goto switch__504block505
        goto switch__504block505
        goto switch__504block505
        goto switch__504block505
        goto switch__504block509
        goto switch__504block523
        goto switch__504block545
switch__504block_end:
        ; switch_check 504 switch__504block_start switch__504block_end
switch__418block_start:
        addwf pcl___register,f
        goto switch__418block419
        goto switch__418block494
        goto switch__418block498
        goto switch__418block502
switch__418block_end:
        ; switch_check 418 switch__418block_start switch__418block_end
main:
        ; Procedure must be called with RP0, RP1, and IRP set to register bank 1
        ; Procedure must be called with PCLATH set to code bank 0
main__variables__base equ global__variables__bank1+6
main__bytes__base equ main__variables__base+0
main__bits__base equ main__variables__base+3
main__total__bytes equ 3
main__504byte0 equ main__bytes__base+2
main__418byte0 equ main__bytes__base+2
main__467byte1 equ main__bytes__base+2
main__464byte1 equ main__bytes__base+2
main__421byte0 equ main__bytes__base+2
main__461byte1 equ main__bytes__base+2
main__403byte1 equ main__bytes__base+2
main__397byte1 equ main__bytes__base+2
        ;   arguments_none  
main__command equ main__bytes__base+0
main__temp equ main__bytes__base+1
        ; Initalize all of the globals :
        ;   interrupt_enable := 0  
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf interrupt_enable__byte,interrupt_enable__bit
        ;   interrupt_pending := 0  
        bcf interrupt_pending__byte,interrupt_pending__bit
        ; Initialize remaining registers :
        ;   glitch := 0  
        ; Switch from register bank 0 to register bank 1 (which contains glitch)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        clrf glitch
        ;   index := 0  
        clrf index
        ; Set up the SCL bus :
        ;   direction sda read  
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ;   direction scl read  
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ;   sda := 0  
        bcf sda__byte,sda__bit
        ;   scl := 0  
        bcf scl__byte,scl__bit
        ;   trigger := 0  
        bcf trigger__byte,trigger__bit
        ; loop_forever ... start
main__396loop__forever:
        ; nop 40
        ; Delay 40 cycles
        movlw 13
        movwf main__397byte1
main__397delay0:
        decfsz main__397byte1,f
        goto main__397delay0
        ;   trigger := 0  
        bcf trigger__byte,trigger__bit
        ;   sda := 0  
        bcf sda__byte,sda__bit
        ;   scl := 0  
        bcf scl__byte,scl__bit
        ;   direction scl read  
        bsf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ;   direction sda read  
        bsf b___tris,sda__bit
        movf b___tris,w
        tris 6
        ; nop 60
        ; Delay 60 cycles
        movlw 19
        movwf main__403byte1
main__403delay0:
        decfsz main__403byte1,f
        goto main__403delay0
        nop
        nop
        ;   trigger := 1  
        bsf trigger__byte,trigger__bit
        ;   sda := 0  
        bcf sda__byte,sda__bit
        ;   scl := 0  
        bcf scl__byte,scl__bit
        ;   direction scl write  
        bcf b___tris,scl__bit
        movf b___tris,w
        tris 6
        ;   direction sda write  
        bcf b___tris,sda__bit
        movf b___tris,w
        tris 6
        goto main__396loop__forever
        ; loop_forever ... end
        ; Process commands :
        ; loop_forever ... start
main__412loop__forever:
        ; Wait for command :
        ; command := get_byte < >
        ;   command := 3  
        movlw 3
        movwf main__command
        ; Dispatch on command :
        ; switch { command >> 6 }
        swapf main__command,w
        movwf main__418byte0
        rrf main__418byte0,f
        rrf main__418byte0,w
        andlw 3
        ; case 0
        ; case 1
        ; case 2
        ; case 3
        goto switch__418block_start
switch__418block419:
        ; < Command = 00 xx xxxx > :
        ; switch { {{ command >> 3 }} & 7 }
        rrf main__command,w
        movwf main__421byte0
        rrf main__421byte0,f
        rrf main__421byte0,w
        andlw 7
        ; case 0
        ; case 1
        ; case 2
        ; case 3
        ; case 4 5 6 7
        goto switch__421block_start
switch__421block422:
        ; < Command = 0000 0 xxx > :
        ; switch { command & 7 }
        movlw 7
        andwf main__command,w
        ; case 0
        ; case 1
        ; case 2
        ; case 3
        ; case 4 5 6 7
        goto switch__424block_start
switch__424block425:
        ; < Command = 0000 0000 > :
        ;   call send_byte {{ 0xa4 }}  
        movlw 164
        movwf send_byte__char
        call send_byte
        ;   call i2c_start {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_start
        ;   call i2c_send_byte {{ 0xc0 }}  
        movlw 192
        movwf i2c_send_byte__data
        call i2c_send_byte
        ;   call i2c_send_byte {{ 1 }}  
        movlw 1
        movwf i2c_send_byte__data
        call i2c_send_byte
        ;   call i2c_restart {{ }}  
        call i2c_restart
        ;   call i2c_send_byte {{ 0xc1 }}  
        movlw 193
        movwf i2c_send_byte__data
        call i2c_send_byte
        ;   temporary := i2c_get_byte {{ }}  
        call i2c_get_byte
        movf i2c_get_byte__0return__byte,w
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf temporary
        ;   call i2c_stop {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        call i2c_stop
        ;   call send_byte {{ temporary }}  
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movf temporary,w
        movwf send_byte__char
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call send_byte
        ;   portc := temporary  
        movf temporary,w
        movwf portc
        goto switch__424end
switch__424block438:
        ; < Command = 0000 0001 > :
        ;   call send_byte {{ 0xa5 }}  
        movlw 165
        movwf send_byte__char
        call send_byte
        ;   call i2c_start {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_start
        ;   call i2c_send_byte {{ 0xc0 }}  
        movlw 192
        movwf i2c_send_byte__data
        call i2c_send_byte
        ;   call i2c_send_byte {{ 0 }}  
        clrf i2c_send_byte__data
        call i2c_send_byte
        ;   call i2c_restart {{ }}  
        call i2c_restart
        ;   call i2c_send_byte {{ 0xc1 }}  
        movlw 193
        movwf i2c_send_byte__data
        call i2c_send_byte
        ;   temporary := i2c_get_byte {{ }}  
        call i2c_get_byte
        movf i2c_get_byte__0return__byte,w
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf temporary
        ;   call i2c_stop {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        call i2c_stop
        ;   call send_byte {{ temporary }}  
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movf temporary,w
        movwf send_byte__char
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call send_byte
        goto switch__424end
switch__424block450:
        ; < Command = 0001 0 xxx > :
        ;   call send_byte {{ 2 }}  
        movlw 2
        movwf send_byte__char
        call send_byte
        ;   call send_byte {{ 3 }}  
        movlw 3
        movwf send_byte__char
        call send_byte
        goto switch__424end
switch__424block455:
        ; loop_forever ... start
main__456loop__forever:
        ;   trigger := 1  
        bsf trigger__byte,trigger__bit
        ; nop 5
        ; Delay 5 cycles
        nop
        nop
        nop
        nop
        nop
        ;   call i2c_start {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_start
        ;   call i2c_send_byte {{ 0xc0 }}  
        movlw 192
        movwf i2c_send_byte__data
        call i2c_send_byte
        ; nop 50
        ; Delay 50 cycles
        movlw 16
        ; Switch from register bank 0 to register bank 1 (which contains main__461byte1)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf main__461byte1
        ; Switch from code bank 0 to code bank 1 before possible transfer (label)
        bsf pa0___byte,pa0___bit
main__461delay0:
        decfsz main__461byte1,f
        goto main__461delay0
        nop
        ;   call i2c_send_byte {{ 0 }}  
        clrf i2c_send_byte__data
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_send_byte
        ;   call i2c_stop {{ }}  
        call i2c_stop
        ; nop 50
        ; Delay 50 cycles
        movlw 16
        ; Switch from register bank 0 to register bank 1 (which contains main__464byte1)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf main__464byte1
        ; Switch from code bank 0 to code bank 1 before possible transfer (label)
        bsf pa0___byte,pa0___bit
main__464delay0:
        decfsz main__464byte1,f
        goto main__464delay0
        nop
        ;   call i2c_start {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_start
        ;   call i2c_send_byte {{ 0xc1 }}  
        movlw 193
        movwf i2c_send_byte__data
        call i2c_send_byte
        ; nop 50
        ; Delay 50 cycles
        movlw 16
        ; Switch from register bank 0 to register bank 1 (which contains main__467byte1)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf main__467byte1
        ; Switch from code bank 0 to code bank 1 before possible transfer (label)
        bsf pa0___byte,pa0___bit
main__467delay0:
        decfsz main__467byte1,f
        goto main__467delay0
        nop
        ;   temporary := i2c_get_byte {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call i2c_get_byte
        movf i2c_get_byte__0return__byte,w
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf temporary
        ;   call i2c_stop {{ }}  
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        call i2c_stop
        ;   portc := temporary  
        ; Switch from register bank 0 to register bank 1 (which contains temporary)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movf temporary,w
        movwf portc
        ;   trigger := 0  
        bcf trigger__byte,trigger__bit
        ;   call delay {{ }}  
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call delay
        goto main__456loop__forever
        ; loop_forever ... end
        goto switch__424end
switch__424block475:
        ; < Command = = < 0000 01 xx > :
switch__424end:
        goto switch__421end
switch__421block480:
        ; < Command = 0000 1 xxx > :
        goto switch__421end
switch__421block483:
        ; < Command = 0001 0 xxx > :
        goto switch__421end
switch__421block486:
        ; < Command = 0001 1 xxx > :
        goto switch__421end
switch__421block489:
        ; < Command = 001 x xxxx > :
switch__421end:
        goto switch__418end
switch__418block494:
        ; < Command = 01 xx xxxx > :
        ; Do nothing :
        goto switch__418end
switch__418block498:
        ; < Command = 10 xx xxxx > :
        ; Do nothing :
        goto switch__418end
switch__418block502:
        ; < Command = 11 xx xxxx > :
        ; switch { {{ command >> 3 }} & 7 }
        rrf main__command,w
        movwf main__504byte0
        rrf main__504byte0,f
        rrf main__504byte0,w
        andlw 7
        ; case 0 1 2 3 4
        ; case 5
        ; case 6
        ; case 7
        goto switch__504block_start
switch__504block505:
        ; < Command = 110 x xxxx or 1110 0 xxx > :
        ; Do nothing :
        goto switch__504end
switch__504block509:
        ; < Command = 1110 1 xxx > :
        ; if { command = 0xef } start
        movlw 239
        subwf main__command,w
        ; expression=`{ command = 0xef }' exp_delay=2 true_delay=6  false_delay=0 true_size=8 false_size=0
        btfss z___byte,z___bit
        goto label511__0end
        ; if { command = 0xef } body start
        ; Read Interrupt Bits < Command = 1110 1111 > :
        ;   temporary := 0  
        clrf temporary
        ; if { interrupt_pending } start
        ; expression=`{ interrupt_pending }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_pending__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc interrupt_pending__byte,interrupt_pending__bit
        ; if { interrupt_pending } body start
        ;   temporary @ 0 := 1  
        ; Select temporary @ 0
temporary__515select0 equ temporary+0
temporary__515select0__byte equ temporary+0
temporary__515select0__bit equ 0
        ; Switch from register bank 0 to register bank 1 (which contains temporary__515select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf temporary__515select0__byte,temporary__515select0__bit
        ; if { interrupt_pending } body end
        ; if exp=`interrupt_pending' false skip delay=2
        ; Other expression=`{ interrupt_pending }' delay=2
        ; if { interrupt_pending } end
        ; if { interrupt_enable } start
        ; expression=`{ interrupt_enable }' exp_delay=0 true_delay=1  false_delay=0 true_size=1 false_size=0
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc interrupt_enable__byte,interrupt_enable__bit
        ; if { interrupt_enable } body start
        ;   temporary @ 1 := 1  
        ; Select temporary @ 1
temporary__518select0 equ temporary+0
temporary__518select0__byte equ temporary+0
temporary__518select0__bit equ 1
        ; Switch from register bank 0 to register bank 1 (which contains temporary__518select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bsf temporary__518select0__byte,temporary__518select0__bit
        ; if { interrupt_enable } body end
        ; if exp=`interrupt_enable' false skip delay=2
        ; Other expression=`{ interrupt_enable }' delay=2
        ; if { interrupt_enable } end
        ;   call send_byte {{ temporary }}  
        movf temporary,w
        movwf send_byte__char
        call send_byte
        ; if { command = 0xef } body end
label511__0end:
        ; if exp=` command = 0xef ' empty false
        ; Other expression=`{ command = 0xef }' delay=-1
        ; if { command = 0xef } end
        goto switch__504end
switch__504block523:
        ; < Command = 1111 0 xxx > :
        ; Switching between register banks generates bulky code ;
        ; Keep code generation in bank 0 by assigning command to
        ; temporary :
        ;   temporary := command  
        movf main__command,w
        movwf temporary
        ; switch { temporary & 7 }
        movlw 7
        andwf temporary,w
        ; case 0 1 2 3
        ; case 4 5
        ; case 6 7
        goto switch__529block_start
switch__529block530:
        ; Set Interrupt Bits < Command = 1111 00 ep > :
        ;   interrupt_enable := temporary @ 1  
        ; Alias variable for select temporary @ 1
temporary__532select0 equ temporary+0
temporary__532select0__byte equ temporary+0
temporary__532select0__bit equ 1
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf interrupt_enable__byte,interrupt_enable__bit
        ; Switch from register bank 0 to register bank 1 (which contains temporary__532select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf z___byte,z___bit
        btfsc temporary__532select0__byte,temporary__532select0__bit
        bsf z___byte,z___bit
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc z___byte,z___bit
        bsf interrupt_enable__byte,interrupt_enable__bit
        ;   interrupt_pending := temporary @ 0  
        ; Alias variable for select temporary @ 0
temporary__533select0 equ temporary+0
temporary__533select0__byte equ temporary+0
temporary__533select0__bit equ 0
        bcf interrupt_pending__byte,interrupt_pending__bit
        ; Switch from register bank 0 to register bank 1 (which contains temporary__533select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf z___byte,z___bit
        btfsc temporary__533select0__byte,temporary__533select0__bit
        bsf z___byte,z___bit
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_pending__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc z___byte,z___bit
        bsf interrupt_pending__byte,interrupt_pending__bit
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        goto switch__529end
switch__529block535:
        ; Set Interrupt Pending < Command = 1111 010 p > :
        ;   interrupt_pending := temporary @ 0  
        ; Alias variable for select temporary @ 0
temporary__537select0 equ temporary+0
temporary__537select0__byte equ temporary+0
temporary__537select0__bit equ 0
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_pending__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf interrupt_pending__byte,interrupt_pending__bit
        ; Switch from register bank 0 to register bank 1 (which contains temporary__537select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf z___byte,z___bit
        btfsc temporary__537select0__byte,temporary__537select0__bit
        bsf z___byte,z___bit
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_pending__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc z___byte,z___bit
        bsf interrupt_pending__byte,interrupt_pending__bit
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        goto switch__529end
switch__529block539:
        ; Set Interrupt Enable < Command = 1111 011 e > :
        ;   interrupt_enable := temporary @ 0  
        ; Alias variable for select temporary @ 0
temporary__541select0 equ temporary+0
temporary__541select0__byte equ temporary+0
temporary__541select0__bit equ 0
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        bcf interrupt_enable__byte,interrupt_enable__bit
        ; Switch from register bank 0 to register bank 1 (which contains temporary__541select0__byte)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        bcf z___byte,z___bit
        btfsc temporary__541select0__byte,temporary__541select0__bit
        bsf z___byte,z___bit
        ; Switch from register bank 1 to register bank 0 (which contains interrupt_enable__byte)
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        btfsc z___byte,z___bit
        bsf interrupt_enable__byte,interrupt_enable__bit
        ; Switch from register bank 0 to register bank 1
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
switch__529end:
        goto switch__504end
switch__504block545:
        ; switch { command & 7 }
        movlw 7
        andwf main__command,w
        ; case 0
        ; case 1
        ; case 2
        ; case 3
        ; case 4
        ; case 5
        ; case 6
        ; case 7
        goto switch__546block_start
switch__546block547:
        ; Clock Decrement < Command = 1111 1000 > :
        ;   osccal := osccal - osccal_lsb  
        movlw 252
        addwf osccal,f
        goto switch__546end
switch__546block551:
        ; Clock Increment < Command = 1111 1001 > :
        ;   osccal := osccal + osccal_lsb  
        movlw 4
        addwf osccal,f
        goto switch__546end
switch__546block555:
        ; Clock Read < Command = 1111 1010 > :
        ;   call send_byte {{ osccal }}  
        movf osccal,w
        movwf send_byte__char
        call send_byte
        goto switch__546end
switch__546block559:
        ; Clock Pulse < Command = 1111 1011 > :
        ;   call send_byte {{ 0 }}  
        clrf send_byte__char
        call send_byte
        goto switch__546end
switch__546block563:
        ; ID Next < Command = 1111 1100 > :
        ;   call send_byte {{ id ~~ {{ index }} }}  
        incf index,w
        ; Switch from register bank 1 to register bank 0
        bcf rp0___byte,rp0___bit
        ; Register bank is now 0
        ; Switch from code bank 1 to code bank 0 before possible transfer (call)
        bcf pa0___byte,pa0___bit
        call id
        ; Switch from register bank 0 to register bank 1 (which contains send_byte__char)
        bsf rp0___byte,rp0___bit
        ; Register bank is now 1
        movwf send_byte__char
        ; Switch from code bank 0 to code bank 1 before possible transfer (call)
        bsf pa0___byte,pa0___bit
        call send_byte
        ;   index := index + 1  
        incf index,f
        ; if { index >= id . size } start
        movlw 52
        subwf index,w
        ; expression=`{ index >= id . size }' exp_delay=2 true_delay=1  false_delay=0 true_size=1 false_size=0
        btfsc c___byte,c___bit
        ; if { index >= id . size } body start
        ;   index := 0  
        clrf index
        ; if { index >= id . size } body end
        ; if exp=` index >= id . size ' false skip delay=4
        ; Other expression=`{ index >= id . size }' delay=4
        ; if { index >= id . size } end
        goto switch__546end
switch__546block571:
        ; ID Reset < Command = 1111 1101 > :
        ;   index := 0  
        clrf index
        goto switch__546end
switch__546block575:
        ; Glitch Read < Command = 1111 1110 > :
        ;   call send_byte {{ glitch }}  
        movf glitch,w
        movwf send_byte__char
        call send_byte
        ;   glitch := 0  
        clrf glitch
        goto switch__546end
switch__546block580:
        ; Glitch < Command = 1111 1111 > :
        ; if { glitch != 0xff } start
        incf glitch,w
        ; expression=`{ glitch != 0xff }' exp_delay=1 true_delay=1  false_delay=0 true_size=1 false_size=0
        btfss z___byte,z___bit
        ; if { glitch != 0xff } body start
        ;   glitch := glitch + 1  
        incf glitch,f
        ; if { glitch != 0xff } body end
        ; if exp=` glitch != 0xff ' false skip delay=3
        ; Other expression=`{ glitch != 0xff }' delay=3
        ; if { glitch != 0xff } end
switch__546end:
switch__504end:
switch__418end:
        goto main__412loop__forever
        ; loop_forever ... end
        ; procedure main end

        ; Register bank 0 used 10 bytes of 24 available bytes
        ; Register bank 1 used 9 bytes of 16 available bytes
        ; Register bank 2 used 0 bytes of 16 available bytes
        ; Register bank 3 used 0 bytes of 16 available bytes

        end

