This document discusses jumps in assembly language, including unconditional jumps and conditional jumps. It defines an unconditional jump as a jump without a condition, using the JMP instruction. Conditional jumps use conditions and compare instructions like CMP. Conditional jump instructions include JE/JZ for equal, JNE/JNZ for not equal, JA/JNBE for above, JB/JNAE for below, and others. It also discusses comparing signed vs unsigned numbers and the flags tested for each conditional jump instruction.
2. JUMP
A jump is a instruction used to control the flow of
program.
Types of jumps:
1. Unconditional Jump
2. Conditional Jump
3. Unconditional Jump
A jump without using any condition is known as
unconditional jump.
Or
Jump to label without any condition.
syntax:
JMP label_name
Example:
Label1:
mov dl,'a'
mov ah,02
int 21h
jmp Label1
4. Conditional Jump
A jump with using condition is known as
conditional jump.
Or
Jump to label with condition.
syntax:
J<condition> label_name
(Let us discuss the CMP instruction before discussing the
conditional instructions.)
5. CMP Instruction
Compares the destination operand to the source operand
Nondestructive subtraction of source from destination (destination
operand is not changed)
Syntax:
CMP destination, source
Note:
Cmp reg, reg Cmp dl,aI
Cmp reg, constant Cmp dl, 3
Cmp reg, [memory address] Cmp dl, [sI]
(1 of 3)
6. CMP Instruction
• Case 3: destination > source
mov al,6
mov bl,5
cmp al,bl
; ZF = 0, CF = 0
(2 of 3)
mov al,5
mov bl,5
cmp al,bl
; Zero flag set
Case 1: destination == source
mov al,4
mov bl,5
cmp al,bl
; Carry flag set
• Case 2: destination < source
The comparisons shown here are performed with “Unsigned"
integers.
7. CMP Instruction (3 of 3)
• Case 1: destination >source
mov al,5
Mov bl,-2
cmp al,bl
; Sign flag == Overflow flag
• Case 2 : destination < source
mov al,-1
Mov bl,5
cmp al,bl
; Sign flag != Overflow flag
The comparisons shown here are performed with "signed"
integers.
8. Conditional Jump For Unsigned Numbers
Following are the conditional jump instructions used on
unsigned data used for logical operations −
Instruction Description Flags tested
JE/JZ Jump Equal or Jump Zero ZF
JNE/JNZ Jump not Equal or Jump Not Zero ZF
JA/JNBE Jump Above or Jump Not Below/Equal CF, ZF
JAE/JNB Jump Above/Equal or Jump Not Below CF
JB/JNAE Jump Below or Jump Not Above/Equal CF
JBE/JNA Jump Below/Equal or Jump Not Above AF, CF
9. Conditional Jump For Signed Numbers
Following are the conditional jump instructions used on
unsigned data used for logical operations −
Instruction Description Flags tested
JE/JZ Jump Equal or Jump Zero ZF
JNE/JNZ Jump not Equal or Jump Not Zero ZF
JG/JNLE Jump Greater or Jump Not Less/Equal OF, SF, ZF
JGE/JNL Jump Greater/Equal or Jump Not Less OF, SF
JL/JNGE Jump Less or Jump Not Greater/Equal OF, SF
JLE/JNG Jump Less/Equal or Jump Not Greater OF, SF, ZF
10. Conditional Jump With Flags
The following conditional jump instructions have special
uses and check the value of flags −
Instruction Description Flags tested
JC Jump If Carry CF
JNC Jump If No Carry CF
JO Jump If Overflow OF
JNO Jump If No Overflow OF
JP/JPE Jump Parity or Jump Parity Even PF
JNP/JPO Jump No Parity or Jump Parity Odd PF
JS Jump Sign (negative value) SF
JNS Jump No Sign (positive value) SF