XOR woes


Closed Thread
Results 1 to 3 of 3

Thread: XOR woes

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: XOR woes

    Hi,
    You don't want to use the XOR operator, you want the ^ (bitwise XOR).
    Code:
    A VAR BYTE
    B VAR BYTE
    C VAR BYTE
    
    HSEROUT["Start",13]
    A = 0 : B = 45
    GOSUB Display
    
    A = 255 : B = 45
    GOSUB Display
    
    PAUSE 10
    END
    
    Display:
    C = A ^ B
    HSEROUT[DEC A, " ^ ", DEC B , " = ", DEC C,13]
    RETURN
    Gives
    Code:
    Start
    0 ^ 45 = 45
    255 ^ 45 = 210
    If it doesn't work at your end, please post the code.

    /Henrik.

  2. #2
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: XOR woes

    Henrik, thanks for that. And sure, in its basic form the '^' operator works as expected.

    In this specific case, I realize that the complication(s)'s arisen because of the fact that the port being bit-manipulated has some pins which are inputs, and not to be controlled by the XOR.

    I'll need to mask off those bits, I guess.

    Thanks again

Similar Threads

  1. Logical difference between 2 8-bit ports XOR?
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd July 2010, 05:17
  2. XOR result different with PC application
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2009, 05:56
  3. Xor?
    By skimask in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 12th October 2008, 07:13
  4. Xor Sum
    By Sphere in forum General
    Replies: 3
    Last Post: - 7th December 2006, 08:52
  5. Exclusive OR - XOR
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th September 2006, 10:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts