Jump to content

Recommended Posts

Posted

I just want to toggle a bits state.

How do I flip a bit?

[this isnt working for me]

btfss  CHAOS_DCO1_WAVE, 0

bcf CHAOS_DCO1_WAVE, 0

bsf CHAOS_DCO1_WAVE, 0

[uPDATED]

I discovered btg by accident on the net. This is the first time I've come across it.

Of all the PIC assembly links on the net I've gone through, I've never found this.

btg filereg,0

does exactly what I want!

Posted

Hi

Think about what is happening....

btfss  CHAOS_DCO1_WAVE, 0 ; if CHAOS_DCO1_WAVE, 0 is set, skip next instruction

  bcf  CHAOS_DCO1_WAVE, 0 ; Not set so clear it, but it is already clear

  bsf  CHAOS_DCO1_WAVE, 0 ; set it again regardless

The bit will always be set.

Dave

Posted

Dave:

I was following this description of btfss:

"btfss: tests a bit in a file register and skips the next instruction if the result

is set"

I'm thinking 'set' = 00000001

not 'set' = 00000000

if bit is set (00000001),  then do next instruction whic is clear.

Looks like I've got the SET thing backwards.

...anyway, BTG is what I needed.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...