Correct me if I am wrong.
This is my understanding of JNZ
and CMP
.
JNZ
- The jump WILL take place if the Z
Flag is NOT zero (1)
CMP
- If the two values are equal, the Z
Flag is set (1) otherwise it is not set (0)
This is a flash tutorial I am watching. It is teaching the solution to a simple CrackMe.
As you can see, the previous instruction compared AL
with 47h
. They were equal which set the Z
flag. (You can see it in the Registers windows on the right side)
The next instruction is a JNZ
. My understanding was that the jump will take place if the Z
flag is set. The Z
flag IS set, but the jump doesn't take place!
Why?
The JNZ instruction transfers control to the specified address if the value in the accumulator is not 0. If the accumulator has a value of 0, the next instruction is executed. Neither the accumulator nor any flags are modified by this instruction.
JE and JZ are just different names for exactly the same thing: a conditional jump when ZF (the "zero" flag) is equal to 1. (Similarly, JNE and JNZ are just different names for a conditional jump when ZF is equal to 0.)
Microprocessor8085. In 8085 Instruction set, we are having one mnemonic JNZ a16, which stands for “Jump if Not Zero” and “a16” stands for any 16-bit address. This instruction is used to jump to the address a16 as provided in the instruction.
JNZ is short for "Jump if not zero (ZF = 0)", and NOT "Jump if the ZF is set".
If it's any easier to remember, consider that JNZ and JNE (jump if not equal) are equivalent. Therefore, when you're doing cmp al, 47
and the content of AL
is equal to 47, the ZF is set, ergo the jump (if Not Equal - JNE) should not be taken.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With