• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

XOR single bit???

Not open for further replies.


New Member
Is it possible to XOR a single bit. In theory, this is what I want to do:

movlw b'00100000' ; moves bit configuration to register W
xorwf PORTB, f ; xor this value to toggle state of bit 5
call Delay

But I do not want to change the values of any other bits besides bit 5. The code above will change the other bits if the bits in PORTB are a 1 (in which some cases they will be).

I want to just single out bit 5 and XOR that to toggle the state. What is the function to do this?


Well-Known Member
Most Helpful Member
I don't see DMon's problem.
If I XOR any number with b 0010 0000 then I get that number back with bit 5 inverted. All other bits are the same as before. We are not using the same computer??


New Member
Yes, ron is right. Once I think about it, XOR with that will not change the status of the other bits. Thank you for helping me resolve my issue.
Not open for further replies.

Latest threads

EE World Online Articles