Branching Instructions IN 8086: By: Ankit Mundra Assistant Professor Department of IT Manipal University Jaipur
Branching Instructions IN 8086: By: Ankit Mundra Assistant Professor Department of IT Manipal University Jaipur
INSTRUCTIONS
IN 8086 By:
Ankit Mundra
Assistant Professor
Department of IT
Manipal University Jaipur
AboutBranch Instructions
Unconditional branch instructions
1.CALL 2.RET 3.INT 5.IRET 6.JMP
4.INTO
Conditional
1.JZ/JE label branch instructions
2.JNZ/JNE label 3. JS label 4. JNS label
5. JO label 6. JNO label 7.JNP label 8. JP label
9. JC label 10. JNC label 11. JCXZ label
12. LOOPZ/LOOPE label 13. LOOPNZ/LOOPENE label
2
BRANCHING INSTRUCTION
Transferring the flow of execution of the program to a new
address specified in the instruction directly or indirectly.
There are three types of procedures used for unconditional jump. They
are:
i.NEAR – This procedure targets within the same code segment. (Intra-
segment)
ii.SHORT - This procedure also targets within the same code segment,
but the offset is 1 byte long. (Intra-segment)
iii.FAR - In this procedure, the target is outside the segment and the
size of the pointer is double word. (Inter-segment)
5
CALL
It is used to call a Subroutine (Procedure) from a main program.
On execution, it stores the incremented IP & CS onto the stack and
loads the CS & IP registers with segment and offset addresses of the
procedure to be called.
RET
Written at the end of the procedure
When it is executed, the previously stored content of IP and CS along
with Flags are retrieved into the CS, IP and Flag registers from the
stack and execution of the main program continues further.
6
INT
It is used to interrupt the program during execution and
specified calling service.
There are 256 interrupts defined corresponding to the types
from 00H to FFH.
7
IRET
Used to return from interrupt service to the main program.
JMP
It unconditionally transfers the control of execution to the specified
address using an 8-bit or 16-bit displacement.
No Flags are affected by this instruction.
8
Conditional Branching
Execution control is transferred to the address specified
relatively in the instruction, provided the condition in the
Opcode is satisfied. Otherwise execution continues sequentially.
9
JZ/JE Label
Used to jump if equal/zero flag ZF = 1
JNZ/JNE Label
Used to jump if not equal/zero flag ZF=0
JS Label
Transfer execution control/jump to address ‘Label’, if (Sign
Flag) SF =1.
10
JNS Label
Transfer execution control/jump to address ‘Label’, if not
(Sign Flag) SF=0.
JO Label
Transfer execution control/jump to address ‘Label’, if OF=1.
JNO Label
Used to jump if no overflow flag OF = 0.
11
JNP Label
Transfer execution control to address ‘Label’, if PF (Parity
Flag)=0.
JP Label
Used to jump if parity/parity even PF = 1.
JC Label
Transfer execution control to address ‘Label’, if CF(Carry Flag)=1.
JNC Label
Transfer execution control to address ‘Label’, if CF=0. 12
JCXZ Label
Transfer execution control to address ‘Label’, if CX=0
LOOPZ/LOOPE Label
Used to loop a group of instructions till it satisfies ZF = 1 & CX =
0