simple instruction got me stumped

Thread Starter

Man_in_UK

Joined May 13, 2008
192
I'm trying to expand my programming limits and I'm stuck on this ....

XORLW

I do know its an exclusive OR with a number 5 & the w reg, but what does it actually mean ?



The code I am trying to figure out is .......
movf counter,w
xorlw 5
btfss ststus,z
goto delay
 

Papabravo

Joined Feb 24, 2006
22,116
It is a way of comparing for equality. The only value in W that can produce a result of zero when Exclusive ORed with 5 is... well 5! Any other value of W when XORed with 5 will produce a non zero result.
 

Thread Starter

Man_in_UK

Joined May 13, 2008
192
That makes sense, sounds simple enough. Can I ask another ?



From the example how does the 0 result make the status,z bit be not set ?


What is the math to xorlw,is it a simple subtract ?
 

Papabravo

Joined Feb 24, 2006
22,116
If the result of the XORLW is zero then the z bit of the status register will be a one. You can use btfss or btfsc to skip the next instruction if the z bit is equal to zero(set) or note equal to zer(clear).

No it is one of the sixteen possible boolean functions of two variables. There is no concept of borrow in the exclusvive OR function. The resemblance of the truth tables for individual bits ignores the effects of borrow.

Rich (BB code):
0  ^  0 = 0
0  ^  1 = 1
1  ^  0 = 1
1  ^  1 = 0
 
Last edited:

Thread Starter

Man_in_UK

Joined May 13, 2008
192
Thank you.
I was following you OK until I read the table. It shows 1xor1 = 1 & then 1xor1 =0.

How can the same sum have two answers ?
 
Top