Conditional branches in the Intel 8086/88 are made on the basis of a number of condition flags. The condition flags are set by most of the arithmetic instructions. For example, the ZF (Zero) flag is a 1 if the result of the last operation was 0.
The two-address CMP is another instruction that sets the condition flags. This instruction compares the value in a register with another value from a register or memory by computing the difference between the first value and the other value and setting the condition flags on the basis of the result. It does not change either of the values. Thus,
Flag Name Meaning if Flag On On Name Off Name
--------------------------------------------------------
ZF Result zero ZR NZ
SF Sign Negative NG PL
OF Overflow occurred OV NV
CF Carry CY NC
AF Auxiliary carry AC NA
PF Parity even PE PO
TF* Trap (for Debugging) -- --
IF* Interrupt enabled EI DI
DF* Direction down DN UP
---------------------------------------------------------------
* This is not a condition flag; it controls processor actions.
---------------------------------------------------------------
JS Jump on Sign (Branches if SF=1)
JNS Jump if Not Sign (Branches if SF=0)
JZ Jump on Zero (Branches if ZF=1)
JE Jump if Equal (Same as JZ)
JNZ Jump if Not Zero (Branches if ZF=0)
JNE Jump if Not Equal (Same as JNZ)
JAE Jump if Above or Equal
---------------------------------------------------------------
There is more than one name for some instructions. For example, tests
for Zero (JZ) and equality (JE) are the same. Following an arithmetic
operation, JZ determines if the result is zero. Following a comparison,
JE determines whether the compared values are identical. Since a
comparison is based on an arithmetic operation (subtraction), there is
no difference.