Your expectation of what the instruction does TESTis incorrect.
The instruction is used to perform bit tests. You would usually use it to βcheckβ if certain bits are specified with respect to the mask. It will be used in conjunction with JZ(jump if zero) or JNZ(jump if not zero) instructions .
- ( ). , ZF ( ) 1 ( ). , , JNZ. , , JZ.
JE JNE , -.
. CMP. .
( ). 0 (ZF = 1). , (ZF = 0). , , JE (jump if equal). , , JNE (jump if not equal).
, TEST, ZF = 0 (0x1 0x1 = 0x1, ). ZF = 0, JNE , .
TL;DR
CMP, , TEST .
int main()
{
__asm
{
mov EAX, 1
mov EDX, EAX
cmp EAX, EDX
L: jne L ; no more infinite loop
}
}