Hi All, I'm using a PIC16F684 in assembly language. What is the most efficient way to determine if a register has a specific value? Would I have to test each bit individually?
Or is there some unique way of subtraction with evaluating the carry flag?
For example, How would I determine if a register reads exactly 0x06?
You can "and" with the 1's complement (comf) of the number you want and see if it returns a zero (Z). That is the same as subtracting, but might be easier to visualize.
I have used XOR as well, but don't understand why 'and' won't work. 0x6 anded with 0x9 gives zero. I just ran it in simulation too, and Z was set appropriately.
I was too target fixated. As I fully woke up and ran the simulation more, the correctness of diver300's comment became obvious. Hence my edit of post#7.
I realized that 0x6 and 0x9 gave zero and affect the zero bit, which was what led to the error in post #3.
John
Eric: Maybe to avoid confusion, you should restore post#7, and I will add the edit below it? Otherwise, your quote of a now absent post could raise questions. Whatever you think is least confusing is fine with me.