clr Count ;clear our 16 bit counter
clr Count+1
WaitSignal0 btfsc PORTB,0 ;wait for signal 1 to be low
goto WaitSignal0
WaitSignal1 btfss PORTB,0 ;wait for signal 1 to go high
goto WaitSignal1
TimeSignal0 btfss PORTB,1 ;is signal 2 low
goto WaitEdge ;yes, go wait for rising edge
incf Count,f ;no so count
btfsc STATUS,Z ;is there a carry
incf Count+1,f ;yes, inc high byte
nop ;waste 1 cycle
goto $+1 ;waste 2 cycles
goto TimeSignal0 ;loop around - total time = 10 cycles
WaitEdge btfsc PORTB,1 ;is signal 2 high
goto GotTime ;yes, so were done
incf Count,f ;as above
btfsc STATUS,Z
incf Count+1,f
nop
goto $+1
goto WaitEdge
GotTime