flat assembler
Message board for the users of flat assembler.

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

Author
Thread Post new topic Reply to topic
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. Very Happy
Post 19 Apr 2011, 00:41
View user's profile Send private message Reply with quote
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.
Post 19 Apr 2011, 00:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
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
Post 19 Apr 2011, 01:01
View user's profile Send private message Visit poster's website Reply with quote
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 ?.......
Post 19 Apr 2011, 01:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
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.
Post 19 Apr 2011, 01:24
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 19 Apr 2011, 02:12
A xor B = (A or B) and ((not A) or (not B))
...and the wiki has several alternatives.
Post 19 Apr 2011, 02:12
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
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 Smile
Post 19 Apr 2011, 10:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.