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
?
Reverse Engineering Stack Exchange is a question and answer site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation. It only takes a minute to sign up.
Sign up to join this communitytest
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
?