#include <P12F509.inc>
__CONFIG _MCLRE_ON & _WDT_OFF & _IntRC_OSC
cblock 0x07
count,temp
endc
org 0x000
main movlw b'11001000' ;clear T0CS for output on GPIO2
option
movlw b'00001000' ;set pins to all outs
tris GPIO
movlw b'11110000'
movlw temp
call shift5
goto main
shift5 movlw 0x08 ;set loop counter
movwf count
movf INDF,w ;get a byte
movwf temp
shift1 rrf temp,f ;rotate ms-bit into carry
btfsc STATUS,C ;is it 0?
goto shift2 ;no, shift out a 1
goto shift3 ;yes, shift out a 0
shift2 bsf GPIO,1
nop
bsf GPIO,2 ;blip clock
nop
bcf GPIO,2
goto shift4
shift3 bcf GPIO,1
nop
bsf GPIO,2 ;blip clock
nop
bcf GPIO,2
shift4 decfsz count,f ;done 8-bits?
goto shift1 ;no, go again
bcf GPIO,4
bsf GPIO,4
retlw 0
end