movlw ServoBuffer
movwf FSR
movlw 0xff
movwf PORTA ;0 set all on.
Wait btfsc INDF,2 ;1/2 it set then we have 32 cycles to read serial and test for exit
goto DoSerial ;3 exit on 3
incf FSR,F ;3
movfw INDF ;4 prefetch port value
decf FSR,F ;5
Enter decfsz INDF,F ;6/7
goto Wait ;8
movwf PORTA ;8
movlw 3 ;0
addwf FSR,F ;1 point to next port value
movfw INDF ;2 prefetch incase time = 1
decf FSR,F ;3 back to time count
goto Enter ;5
DoSerial movfw FSR ;4 save the pointer
movwf FSRtemp ;5
decf FSR,F ;6 point to last port value
movfw INDF ;7 get it
btfsc STATUS,Z ;8/9 if it was zero, were done
goto Done ; exit on 10
btfss PIR1,RCIF ;10/11
goto NoSerial ; exit on 12
incf FifoStart,W ;14 get fifostart + 1
andlw FifoLength-1 ;15 make it circular
movwf FifoStart ;16
addlw FifoBuffer ;17 add start of buffer
movwf FSR ;18 put in indirect pointer
movfw RCREG ;19 get the received byte
movwf INDF ;20 put it in fifo
movfw FSRtemp ;21 restore the pointer
movwf FSR ;22
decf INDF,F ;23 - 8 = 15 reclaim 8 cycles
decf INDF,F ;15 - 8 = 7 and again
decf INDF,F ;7 - 8 = 2 and again
nop ;3
goto Enter ;5
NoSerial movfw FSRtemp ;11 restore pointer
movwf FSR ;12
decf INDF,F ;13 - 8 = 5 reclaim 8 cycles
goto $+1 ;7
goto $+1 ;9
decf INDF,F ;9 - 8 = 1 and again
goto $+1 ;3
goto Enter ;5