I have read that TEST does a bitwise and on the two arguments. I have also read that jz and je are both equivalent, and jump if the zero flag is set. So here's the problem I'm struggling with. Consider the (rather useless) following code:
mov ax, 0x2 test ax, 0x2 je equal mov ax, 0x0 jmp done equal: mov ax, 0x1 done:
Logically, "jump if equal" should jump, but 0x2 & 0x2 should not set the zero flag. As I understand jz/je will jump if the zero flag is set, this means je is not logically doing what it implies ("jump if equal"). And in practice, the code will fall through and set ax to 0x0, rather than jumping and setting ax to 0x1.
Can anyone explain where my understanding is going wrong? Clearly I'm not understanding something correctly.