hi i m asm beginer and want to know about these instructions more information with expalination.what i know about these each one i write.i thing this is not enough so plz guide me more regarding this.

a)AND

truth table
     
0 0 |0
0 1 |0
1 0 |0
1 1 |1

1.used for turning off unwanted bits(masking bits) (not understand)
2.used to clear registers(understand)
    and ax,00h 

b)OR

truth table
0 0 |0
0 1 |1
1 0 |1
1 1 |1

1.used to turn on bits(not understand)

c)XOR

truth table

0 0 |0
0 1 |1
1 0 |1
1 1 |0

1.used for toggling bits(turn on/off bits)(understand)


d)TEST ?...



i want to know more about AND,OR,XOR,TEST
plz tell me other usage of each will example with different situations

i see a code by XCHG
http://www.asmcommunity.net/board/index.php?topic=25069.msg183807#msg183807

where he use OR and TEST operations i don't understand plz clarify
Posted on 2006-07-22 05:37:04 by AssemblyBeginner
Read through these two pages in our WikiBook and then specify any leftover questions:

Bit_Operations
Conditional_Statements

Cheers,
Jimmy
Posted on 2006-07-22 07:54:00 by JimmyClif
thks Jimmy

but about "or" operation in xchg code

    OR      AL , AH              ; AL = AL + AH
    CMP    AL , 01h              ; See if AL + AH = 01 (0 + 1 || 1 + 0)

what this mean or also mean addition ,i don't understand these lines

http://www.asmcommunity.net/board/index.php?topic=25069.msg183807#msg183807
Posted on 2006-07-22 08:36:51 by AssemblyBeginner
Ok, the comment is a little misleading. I know where the problem lays:

OR AL,AH ; AL=AL+AH

Gives the illusion that OR could perform an addition. But that's not the case. Let me quote exchange here:


The blocks are separated by null values and your program?s full path is separated from the others by 00h 01h 00h. I just coded an example, which I think might help you more than any more description.


So the stuff he's looking for is separated between a bunch of bytes 0's and 1's.

Now he grabs 2 bytes into AX (AH,AL); and any of them two could have a 1 or a 0 or something comletely different of course (like the stuff he's looking for).
Now - If you OR the two bytes (AL, AH) together than the result will have a 1 if either the upper byte or the lower one had a 1.

If there is no 1 then he reached his destination.
Posted on 2006-07-22 08:58:53 by JimmyClif
I'm not sure that code is the smartest - it would find (0,1), (1,0) AND (1,1)... if you need to find (0,1,0) then that's what you should search for, really :)
Posted on 2006-07-22 09:06:35 by f0dder
sorry f0dder i don't understand what u want 2 say
I'm not sure that code is the smartest - it would find (0,1), (1,0) AND (1,1)... if you need to find (0,1,0) then that's what you should search for, really
Posted on 2006-07-22 09:13:27 by AssemblyBeginner
thks jimmy once again


plz explain TEST operation with example where it is useful with explaination.

and how OR is useful in window style operations as mentioned in asm book in wikipedia.plz explain with example
Posted on 2006-07-22 09:16:53 by AssemblyBeginner
I would have a hard time explaining.

The best you can do is play with this code:


.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive


include kernel32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib

.data
BitIsSet db "Set",0
BitIsNotSet db "Not Set",0

.code

start:
xor eax, eax
or eax,        1b
or eax,      10b
or eax,      100b
or eax,    1000b

or eax, 40000000h ; WS_CHILD

test eax, 01000000000000000000000000000000b
jz @F
invoke MessageBox,0,addr BitIsSet,0,0
jmp @out
@@:
invoke MessageBox,0,addr BitIsNotSet,0,0
@out:
invoke ExitProcess,0
end start


Just like in upper example you OR different numbers together, you would in regular coding OR Window Styles together. By Testing you would see if one or the other would be present.

Modify the upper or eax, ??? lines with whatever you value you want and see what will happen.
WS_CHILD for example is 40000000h which translates to 01000000000000000000000000000000b.
Posted on 2006-07-22 20:11:14 by JimmyClif
Hint: get OllyDebug and trace through the code, see how registers change.
Posted on 2006-07-23 03:56:29 by f0dder
or- a donator of bits (register same value or higher)
and- a censor of bits (register same value or lower)
xor- a bit flipper

test is a fake and that sets the flags like cmp without changing register values.

so if you want to know if your result is divisible by 4 without messing up the registers

mov ax,1234
mov bx,1011b
test ax,bx

would set the zf




Posted on 2006-08-01 07:46:19 by eek