blob: c98424ffec582932bb63b48d2b22eaee3b798ab0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
CMP subtracts operands and sets internal flags. Among these, it sets the
zero flag if the difference is zero (operands are equal).
TEST sets the zero flag (ZF) when the result of the AND operation is zero. If
the two operands are equal, their bitwise AND is zero only when the operands
themselves are zero. TEST also sets the sign flag (SF) when the most
significant bit is set in the result, and the parity flag (PF) when the number
of set bits is even.
JE (alias of JZ) tests the zero flag and jumps if it is set. This creates the
following equivalencies:
test eax, eax
je <somewhere> ----> if (eax == 0) {}
cmp eax, ebx
je <somewhere> ----> if (eax == ebx) {}
|