Is there a major positive quality when using "or" instead of "cmp"?
Consider this function prologue:
push ebp
mov ebp,esp
push ebx
xor eax,eax ;error return code
mov ecx,[ebp +8] ;first integer arg after return addr.
mov edx,[ebp +12] ;second integer argument
The function shall calculate a / b
or a % b
.
First I need to check against a 0 divisor.
My intuitive move would be to assemble
cmp edx,0
je InvalidDivisor
But when I look into advanced books on assembler there would be used this:
or edx,edx
jz InvalidDivisor
My question is why is this second solution "more correct"?
Would it not take longer to calculate an or-operation and check for zero-flag than just compare two values?
Is it just a matter of more advanced coding style?