What's the difference between or eax,eax
and test eax,eax
? I've seen different compilers produce both for the same comparison and as far as documentation goes they do exactly the same thing, so I'm wondering why they don't all use test eax,eax
. Thinking about it and eax,eax
would set the flags in an identical fashion as either but I haven't seen it in either freepascal, delphi, or msVC++.
I did compile some asm blocks in delphi and checked out the assembler source and all 3 forms are the exact same length in opcodes and also checked the intel performance PDF and it says they have the same latency and throughput.
Edit:
The question is specifically about the difference between the specific cases test eax,eax
, or eax,eax
and and eax,eax
. All 3 give completely identical results for registers, flags, opcode length, latency, throughput. And yet for testing if 0, if not zero, or if signed, some compilers will use test eax,eax
while some use or eax,eax
, and I was wondering why they aren't all using test eax,eax
since it makes the code very slightly clearer.
Edit2:
For reference I'm at home and only have and older msvc++ and Delphi here, but testing a variable if zero, msvc++ does test eax,eax
, while Delphi does or eax,eax
.