CMP Instruction Single-Flag Based Jump Instruc
 Conditional Jump Instructions

 Conditional jump instructions are the basic tools for creating selective structures like the IF..ENDIF statement and repetitive structures like loops. A conditional jump tests one or more flags in the flags register If the flag settings match the instruction, control transfers to the target location If the match fails, the CPU ignores the conditional jump and execution continues with the next instruction. Most of the time, a conditional jump is executed after a CMP instruction. The CMP instruction sets the flags so that test can be carried out for less than, greater than, equality, etc.

Conditional jump instructions take the following form:

```	Jcc label;
```

The “cc” in Jcc indicates that some character sequence, specifying the type of condition to be tested, must be substituted. For example, JS stands for jump if the sign flag is set and JC stands for jump if the carry flag is set.

Conditional jumps test the sign (S), zero (Z), carry (C), parity (P), and overflow (O) flags.

When comparing two numbers it is necessary to know whether these numbers are representing signed or unsigned numbers in order to establish a relationship between them.
For example, suppose that AL=FF and BL=01. If we execute the instruction CMP AL, BL, the result of the comparison will be different depending on whether the registers represent signed or unsigned numbers.
If unsigned numbers are represented, then AL=255 and BL=1 and hence AL is greater than BL. However, if signed numbers are represented, then AL=-1 and BL=1 and hence BL is greater than AL. Thus, we need conditional jump instructions for unsigned number comparison and conditional jump instructions for signed number comparison.

Conditional jump instructions are divided into three main types:

 Single Flag Based Jump Instructions Unsigned Conditional Jump Instructions Signed Conditional Jump Instructions

 Example: Target address is SHORT. ``` CMP AX, BX ; compare ax to bx to set flags JE THERE ; if equal, then skip next statement ADD AX, 0002H ; correction statement THERE: MOV CL, 07H ; load count .... ```
 Example: Target address is Near. ``` CMP AX, BX ; compare AX to BX to set flags JNE FIX ; if not equal, then goto label FIX JMP THERE ; otherwise, unconditional jump to there FIX: ADD AX, 0002H ; correction statement THERE: MOV CL, 07H ; load count .... ```