Shop OBEX P1 Docs P2 Docs Learn Events
Invert variable — Parallax Forums

Invert variable

bpislifebpislife Posts: 10
edited 2010-08-13 19:02 in Propeller 1
Is there a way I can invert a variable?

For example, say a byte data is %10101010. Can I make it %01010101 with a simple command? I looked and could have swore I saw something, I just can't remember where.

I was thinking of doing an XOR against %11111111 but I am not sure how to XOR in spin either.

I am sure there is a simple way to do this, but I have no clue.

Comments

  • KyeKye Posts: 2,200
    edited 2010-08-13 18:45
    Use the "!" operator.
  • bpislifebpislife Posts: 10
    edited 2010-08-13 18:50
    OMFG!!! I can't believe that. You know you have been coding too many complex things when you forget the basics. Thanks!!
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-08-13 19:02
    Yup! , the "!" operator :-)
    PUB DEMO                         ' Uses LEDs on DEMO board
    
        DIRA[16..23]~~
        OUTA[16..23] := %11001100    ' Set pattern
        
        repeat
          !OUTA[16..23]              ' invert pattern  
          waitcnt(clkfreq+cnt)
    
    
Sign In or Register to comment.