0% found this document useful (0 votes)
258 views

Branching Instructions IN 8086: By: Ankit Mundra Assistant Professor Department of IT Manipal University Jaipur

This document discusses branching instructions in 8086. It describes unconditional branching instructions like CALL, RET, INT, IRET, JMP. It also describes conditional branching instructions like JZ, JNZ, JS, JNS etc based on different flag conditions. Branching instructions transfer the flow of execution by modifying the CS and IP registers. Unconditional branching jumps unconditionally while conditional branching jumps only if certain flag conditions are satisfied.

Uploaded by

KONARK TANWAR
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views

Branching Instructions IN 8086: By: Ankit Mundra Assistant Professor Department of IT Manipal University Jaipur

This document discusses branching instructions in 8086. It describes unconditional branching instructions like CALL, RET, INT, IRET, JMP. It also describes conditional branching instructions like JZ, JNZ, JS, JNS etc based on different flag conditions. Branching instructions transfer the flow of execution by modifying the CS and IP registers. Unconditional branching jumps unconditionally while conditional branching jumps only if certain flag conditions are satisfied.

Uploaded by

KONARK TANWAR
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

BRANCHING

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.

 When the instruction is executed, the Code Segment (CS) and


Program Counter/Instruction Pointer (IP) registers get loaded
with new values of CS and IP corresponding to the location to be
transferred.
 Two types of branching instructions:
• Unconditional
• Conditional
3
Unconditional Jump Instructions

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)

Syntax: JMP procedure_name memory_location


Example: JMP short 12h
JMP Near 1234h
JMP Far 1234h
Unconditional
Branching
 The execution control is transferred to the specified
location independent of any status or condition.

 The CS and IP are unconditionally modified to the new value of


CS and IP.

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.

INTO: Interrupt on Overflow


 Used to interrupt the program during execution if (Overflow
Flag) OF = 1

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

LOOPNZ / LOOPENE Label


 Loop through a sequence of instructions from label while ZF=1
and CX=0.
13

You might also like