flat assembler
Message board for the users of flat assembler.

 Index > Main > What is the "Equation" of XOR (Bitwise)? (If there
Author
typedef

Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 19 Apr 2011, 00:41
What is the equation of XOR?
For example

let's say this is the standard form of XOR

A xor B

6 xor 4 = 2;

So,

Is it ( A xor B = ( A > B) ? A - B : B - A; (but either way the result is 2).

So I say that's not the way it is computed.

Let A=9 & Let B=12

A xor B = 5.. How, i was expecting 3 (LOL)

It looks like there are some conditions inside it.

Anyhbody know, I asked Google and all he said was the Boolean XOR equation. I interrogated him but still he refused to say.
19 Apr 2011, 00:41
asmhack

Joined: 01 Feb 2008
Posts: 431
asmhack 19 Apr 2011, 00:55
Code:
110 ;6
100 ;4
____
010 ;2

1001 ;9
1100 ;12
____
0101 ;5

xor is a digital logic gate that implements an exclusive disjunction, not absolute subtraction, that's the conditions.
19 Apr 2011, 00:55
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 18961
revolution 19 Apr 2011, 01:01
XOR is the same as addition (and subtraction) but without any internal carries propagated.

For each bit in the operand:

0+0=0
0+1=1
1+0=1
1+1=0 (ignore the carry)

Works for subtraction also:

0-0=0
0-1=1 (ignore the carry)
1-0=1
1-1=0

The mathematical equivalent would be: bitwise A + B = C mod 2
19 Apr 2011, 01:01
typedef

Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 19 Apr 2011, 01:12
Oh, so the trick is to just convert from whatever base you are in to base 2 and then use the truth table ?.......
19 Apr 2011, 01:12
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 18961
revolution 19 Apr 2011, 01:24
AFAIK XOR is only defined in the binary domain. "boolean" is the word that should alert you to it being binary.
19 Apr 2011, 01:24
bitRAKE

Joined: 21 Jul 2003
Posts: 3515
Location: vpcmipstrm
bitRAKE 19 Apr 2011, 02:12
A xor B = (A or B) and ((not A) or (not B))
...and the wiki has several alternatives.
19 Apr 2011, 02:12
bitshifter

Joined: 04 Dec 2007
Posts: 786
Location: Massachusetts, USA
bitshifter 19 Apr 2011, 10:45
My BitBox helps to visualize such things...
http://board.flatassembler.net/topic.php?t=11615
Have fun
19 Apr 2011, 10:45
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum