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
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
Read through these two pages in our WikiBook and then specify any leftover questions:
Bit_Operations
Conditional_Statements
Cheers,
Jimmy
Bit_Operations
Conditional_Statements
Cheers,
Jimmy
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
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
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.
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.
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 :)
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
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
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
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
I would have a hard time explaining.
The best you can do is play with this code:
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.
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.
Hint: get OllyDebug and trace through the code, see how registers change.
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
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