Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
eblc1388 said:Hi guys,
On a 16F877, I have set up eight flags using a single register called "flags" and I need to change them or toggle them individually.
I know I can test the bit and change it, but is there an easy way to just toggle a single bit, for example?
eblc1388 said:Thanks Nigel, but I like to "toggle" the bit not set or clear it.
Nevermind, I figured it out myself.
Code:movlw B'00001000' ;toggle bit3 xorwf flags,F
#define FLAG1 B'00000001'
#define FLAG2 B'00000010'
#define FLAGS1n2 FLAG1 | FLAG2
[...]
movlw FLAGS1n2
xorwf [file]
Jay.slovak said:on PIC18F, you would just use BTG (Bit togle) instruction
Actually yes, good point here (I didn't think about that).Joel Rainville said:Jay.slovak said:on PIC18F, you would just use BTG (Bit togle) instruction
Yes, but as you can see from my previous example, xorwf is more "powerful". If I am not mistaken, BTG limits you to 1 bit at a time?...