Page 1 of 1

Why use or al, al instead of cmp al, 0?

Posted: Sun Sep 23, 2007 3:09 pm
by matias_beretta
I noticed that people use: or al, al instead of cmp al, 0.

Is it the same?

Posted: Sun Sep 23, 2007 3:20 pm
by earlz
you will get more replies if you name your topic more appropriately...

thanks

Posted: Sun Sep 23, 2007 3:23 pm
by matias_beretta
thanks, this answer helped me a lot!

Posted: Sun Sep 23, 2007 3:27 pm
by OrOS
I assume that was sarcasm....

Re: Question

Posted: Sun Sep 23, 2007 3:37 pm
by frank
matias_beretta wrote:I noticed that people use: or al, al instead of cmp al, 0.

Is it the same?
It achieves the same result, but maybe or al, al is faster or takes up less space in the binary.

EDIT: Well actually they are the same size. So that rules that out. However or eax, eax is 1 byte shorter than cmp eax, 0.

Posted: Sun Sep 23, 2007 3:42 pm
by earlz
well, isn't 'cmp al,al' just 'and al,al' without changing the destination?

so, or al,al would not be faster.... I've also never seen this though(I don't look at much asm source though..)

...sorry for useless response...I should've put what I put here, but anyway...

Re: Question

Posted: Mon Sep 24, 2007 5:36 am
by Craze Frog
matias_beretta wrote:I noticed that people use: or al, al instead of cmp al, 0.

Is it the same?
cmp performs a subtraction and or only a bitwise boolean operation, so it is theorethically slightly faster. But or destroys the value of al.

Re: Question

Posted: Mon Sep 24, 2007 6:52 am
by kataklinger
Craze Frog wrote:But or destroys the value of al.
or al,al doesn't change value of al!

Re: Question

Posted: Mon Sep 24, 2007 7:35 am
by Craze Frog
kataklinger wrote:
Craze Frog wrote:But or destroys the value of al.
or al,al doesn't change value of al!
You're right. I forgot the source and destination had the same value...