To flip, or toggle, a single bit – to change it from 0 to 1 or from 1 to 0, you can exclusive-or it with 1.
That is:
0 XOR 1 = 1
1 XOR 1 = 0
So to repeatedly toggle GP1, we can read the current state of GPIO, exclusive-or the bit corresponding to GP1, then write it back to GPIO, as follows:
movlw b'000010' ; bit mask to toggle GP1 only
flash
xorwf GPIO,f ; toggle GP1 using mask in W
goto flash ; repeat forever
That is:
0 XOR 1 = 1
1 XOR 1 = 0
So to repeatedly toggle GP1, we can read the current state of GPIO, exclusive-or the bit corresponding to GP1, then write it back to GPIO, as follows:
movlw b'000010' ; bit mask to toggle GP1 only
flash
xorwf GPIO,f ; toggle GP1 using mask in W
goto flash ; repeat forever
