View Single Post
  #2  
Old 05-12-2004, 14:54
peleon peleon is offline
Friend
 
Join Date: Sep 2003
Posts: 174
Rept. Given: 0
Rept. Rcvd 7 Times in 1 Post
Thanks Given: 0
Thanks Rcvd at 7 Times in 7 Posts
peleon Reputation: 7
Hello 3ch0,

First, I have to admit that book mess up a lot what AND/OR/XOR is. It's a simple concept that is hidden in that text line

About ORing, well, I guess the the author wants to say OR-ing (verb finished in -ing) (that磗 english i suppose ). So, that's the same as saying: "Apply the OR operator..."

My explanation about this:

OR = binary add

0 or 0 = 0
1 or 0 = 1
0 or 1 = 1
1 or 1 = 1

AND = binary multiply

0 and 0 = 0
0 and 1 = 0
1 and 0 = 0
1 and 1 = 1

XOR = exclusive OR

0 xor 0 = 0
0 xor 1 = 1
1 xor 0 = 1
1 xor 1 = 0

So, using this 3 operators you can play with the bits in a registry/memory as you like. For example, suppose that you have in the EAX register a value. If you want to know if that number is odd or even you can make the following:

and eax, 1 ; will leave the bit-0 untouched to check if even or odd

.if eax == 1

; we are odd!

.else

; we are even!

.endif

Hope this helps

Last edited by peleon; 05-12-2004 at 14:56.
Reply With Quote