Additional COOL info:

How to check if only the 3rd bit is change...

This is a technique that you will certainly need to use one day. Suppose that you have again temp1 and temp1_old, and you want to test if the 3rd bit of temp1 is changed. This is what you do:

movf temp1,w

xorwf temp1_old,w

The XOR instruction has this ability to identify ONLY the changed bits. If both bits are 0 or 1, then the XOR function returns 0. But if bits are different (1-0 or 0-1), XOR returns 1. Here is an example:

temp1=00001100

temp1_old=10001000

The XORWF will return

00001100

10001000 XOR

-----------------------

10000100

Now, you can simply check the 3d bit of the XOR result"

`movf temp1,w`

xorwf temp1_old,w

movwf temp2 ;another temporary register that you store the XOR result

btfsc temp2,3

goto Bit_3_Is_Changed

And here is another way that has the same result but without using this lousy temp2 register:

`movf temp1,w`

xorwf temp1_old,w

andlw '00001000'

btfss zero

goto Bit_3_Is_Changed

This technique uses the AND logic function, which can isolate a single bit from a number. Check this:

00111110

00001000 AND

-----------------------

00001000

and this:

00110110

00001000 AND

-----------------------

00000000

The result of the AND logic function is affected ONLY by the 3rd bit. So, if the result is 0, this means that bit 3 was zero...