Hi, In a recent project I had to test for a change of state on an I/O pin. The code I came up with works ok, but is a bit clunky. I was wondering if there is a "standard solution" or a better way. This is what I did: tstToggle movf gpio, w ; get the port data andlw b'00000100' ; isolate the pin (I was interested in bit 2) xorwf LPin, w ; LPin is a register that holds the last pin state skpnz ; if non-zero, then the pin has toggled goto Next_Bit_of_Code comf LPin, w ; update the previous value andlw b'00000100' movwf LPin ; Do any other processing here Next_Bit_of_Code ... I feel that it could be shorter and use only 1 bit to store the last value. Any thoughts, anyone? Regards, Mike Watson