;
; B on RB1, A on RB0
;
movf PORTB,W ; get new AB
andlw 0x03 ; only RB1 and RB0 bits
xorwf encold,W ; any change?
skpz ; no, skip, else
xorlw 0x03 ; both changed?
skpnz ; no, skip, else
retlw 0 ; exit (same or skip)
xorlw 0x03 ; restore new AB bits in WREG
xorwf encold,W ; "
rrf encold,F ; encold.0 = old B bit
xorwf encold,F ; encold.0 = new A ^ old B
rrf encold,F ; put bit 0 (dir) into C
movwf encold ; update encoder latch
skpnc ; C = direction
retlw -1 ; return -1
retlw 1 ; return +1