In IDA when disassembling a x86 EXE file there is a line
test byte ptr [ebp+XXX], cl
Before this line cl
has a value of 0x11
The Hex-Rays decompiler plugin translates it as if (v10 &0x11)
.
Why is test
decompiled like and
?
test
is basically an and
instruction except it doesn't update the left operand.
In the other hand, cmp
is the equivalent of sub
instruction except it doesn't update the left operand.
To sum up:
if (v & n)
Is compiled as test
instruction.
if (v == n)
Is compiled as cmp
instruction (or test reg, reg
is n is 0x0)
v = a & n
Is compiled as and
instruction.
test
instruction's manual, or at least google forx86 test instruction
?