flat assembler
Message board for the users of flat assembler.
Index
> Main > what is xor |
Author |
|
LocoDelAssembly 02 Jul 2009, 01:34
It performs the eXclusive OR operation.
http://en.wikipedia.org/wiki/Exclusive_or Not however that many times you'll see that XOR contains two register operands that are the same. For instance, in situations like "XOR eax, eax", "MOV eax, 0" would be the same except for a minor difference (the former alters the flags while the latter doesn't) |
|||
02 Jul 2009, 01:34 |
|
windwakr 02 Jul 2009, 01:36
if the the second bit is one flips the first bit.
By second bit I mean the second operand of xor, not the second bit of the number you're using. So for example, 10011011 xor 10101101 would be 00110110 Code: INPUT A B OUTPUT 0 0 0 0 1 1 1 0 1 1 1 0 |
|||
02 Jul 2009, 01:36 |
|
GhostXoPCorp 02 Jul 2009, 02:26
so xor is just like mov ax,0 without modifying flags?
_________________ Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me. |
|||
02 Jul 2009, 02:26 |
|
windwakr 02 Jul 2009, 02:33
xor ax,ax would be like mov ax,0
|
|||
02 Jul 2009, 02:33 |
|
Yardman 02 Jul 2009, 02:43
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 03:25; edited 1 time in total |
|||
02 Jul 2009, 02:43 |
|
LocoDelAssembly 02 Jul 2009, 02:48
And it is XOR which modifies the flags, so avoid things like this:
Code: cmp ax, VALUE xor ax, ax je IT_IS_EQUAL ; This jump will always be taken In such cases you will need mov Code: cmp ax, VALUE mov ax, 0 je IT_IS_EQUAL ; Will jump only if AX was equal to VALUE before setting it to zero In general you can use XOR safely, only rarely situations like above make it a bad choice. tom tobias must be rolling in the floor laughing at me right now |
|||
02 Jul 2009, 02:48 |
|
bitRAKE 02 Jul 2009, 02:54
XOR does modify flags. If we think in terms of the effect on the bits: XOR uses the source to select which bits to reverse in the destination (i.e. conditional NOT). We see this used in raster graphics algorithms. For example, how to reverse bits 4-7 of a byte? Answer: XOR AL,$F0.
|
|||
02 Jul 2009, 02:54 |
|
arigity 02 Jul 2009, 03:11
Quote: XOR |
|||
02 Jul 2009, 03:11 |
|
GhostXoPCorp 02 Jul 2009, 04:51
thanks for all of the information guys
|
|||
02 Jul 2009, 04:51 |
|
eskizo 02 Jul 2009, 06:20
Every bitwise operation modifies the flags, am I wrong?
xor or and not |
|||
02 Jul 2009, 06:20 |
|
manfred 02 Jul 2009, 15:32
Yes, all bitwise operations modify the flags.
_________________ Sorry for my English... |
|||
02 Jul 2009, 15:32 |
|
Borsuc 02 Jul 2009, 15:44
That's make it easy to remember.
|
|||
02 Jul 2009, 15:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.