Does anyone have a slick method for detecting rising or falling edges? I keep ending up with a variation of these two methods, and both seem cheesy. In this case I am trying to detect a falling edge on PORTA,4 and jump to Index_now. I am using index_flag for storage. First method, wastes the entire byte of index_flag: bcf STATUS,C ;clear carry flag btfsc PORTA,4 ;test the port bit bsf STATUS,C ;set carry if pin was high rlf index_flag,f ;bit0=newpin bit1=oldpin movlw b'00000011' ;only care about bottom two bits andwf index_flag,w ;those bits are now in w xorlw b'00000010' ;compare with falling pattern 1 to 0 btfsc STATUS,Z ;skip if the pattern doesn't match goto Index_now ;pattern matched, jump OK, that was fun, but it was kind of wasteful. This next way only uses one bit of the flag byte: btfss PORTA,4 ;test the port pin goto It_is_zero ;jump if low bsf index_flag,0 ;remember for next go 'round goto Index_not ;get out It_is_zero btfsc index_flag,0 ;test if previously it was high goto Index_now ;we have a falling edge Index_not ;default code here Index_now bcf index_flag,0 ;remember for next time This method is real typical of the stuff I've always done, but it still seems a stupid way to do it. Anybody got a quantum leap for me? Thanks, Bob