Open In App
Related Articles

Branching instructions in 8085 microprocessor

Improve Article
Improve
Save Article
Save
Like Article
Like

Branching instructions refer to the act of switching execution to a different instruction sequence as a result of executing a branch instruction. 

The three types of branching instructions are: 
 

  1. Jump (unconditional and conditional) 
     
  2. Call (unconditional and conditional) 
     
  3. Return (unconditional and conditional) 
     

1. Jump Instructions – The jump instruction transfers the program sequence to the memory address given in the operand based on the specified flag. Jump instructions are 2 types: Unconditional Jump Instructions and Conditional Jump Instructions. 

(a) Unconditional Jump Instructions: Transfers the program sequence to the described memory address. 

 

OPCODEOPERANDEXPLANATIONEXAMPLE
JMPaddressJumps to the addressJMP 2050

(b) Conditional Jump Instructions: Transfers the program sequence to the described memory address only if the condition in satisfied. 

 

OPCODEOPERANDEXPLANATIONEXAMPLE
JCaddressJumps to the address if carry flag is 1JC 2050
JNCaddressJumps to the address if carry flag is 0JNC 2050
JZaddressJumps to the address if zero flag is 1JZ 2050
JNZaddressJumps to the address if zero flag is 0JNZ 2050
JPEaddressJumps to the address if parity flag is 1JPE 2050
JPOaddressJumps to the address if parity flag is 0JPO 2050
JMaddressJumps to the address if sign flag is 1JM 2050
JPaddressJumps to the address if sign flag 0JP 2050

2. Call Instructions – The call instruction transfers the program sequence to the memory address given in the operand. Before transferring, the address of the next instruction after CALL is pushed onto the stack. Call instructions are 2 types: Unconditional Call Instructions and Conditional Call Instructions. 

(a) Unconditional Call Instructions: It transfers the program sequence to the memory address given in the operand. 
 

OPCODEOPERANDEXPLANATIONEXAMPLE
CALLaddressUnconditionally callsCALL 2050

(b) Conditional Call Instructions: Only if the condition is satisfied, the instructions executes. 

OPCODEOPERANDEXPLANATIONEXAMPLE
CCaddressCall if carry flag is 1CC 2050
CNCaddressCall if carry flag is 0CNC 2050
CZaddressCalls if zero flag is 1CZ 2050
CNZaddressCalls if zero flag is 0CNZ 2050
CPEaddressCalls if parity flag is 1CPE 2050
CPOaddressCalls if parity flag is 0CPO 2050
CMaddressCalls if sign flag is 1CM 2050
CPaddressCalls if sign flag is 0CP 2050

3. Return Instructions – The return instruction transfers the program sequence from the subroutine to the calling program. Return instructions are 2 types: Unconditional Jump Instructions and Conditional Jump Instructions. 

(a) Unconditional Return Instruction: The program sequence is transferred unconditionally from the subroutine to the calling program. 

 

OPCODEOPERANDEXPLANATIONEXAMPLE
RETnoneReturn from the subroutine unconditionallyRET

(b) Conditional Return Instruction: The program sequence is transferred unconditionally from the subroutine to the calling program only is the condition is satisfied. 

OPCODEOPERANDEXPLANATIONEXAMPLE
RCnoneReturn from the subroutine if carry flag is 1RC
RNCnoneReturn from the subroutine if carry flag is 0RNC
RZnoneReturn from the subroutine if zero flag is 1RZ
RNZnoneReturn from the subroutine if zero flag is 0RNZ
RPEnoneReturn from the subroutine if parity flag is 1RPE
RPOnoneReturn from the subroutine if parity flag is 0RPO
RMnoneReturns from the subroutine if sign flag is 1RM
RPnoneReturns from the subroutine if sign flag is 0RP

 

Advantages:

Enables conditional execution: The branching instructions in the 8085 microprocessor allow for conditional execution of code, which can help optimize program flow and improve overall efficiency.

Simplifies programming: The branching instructions in the 8085 microprocessor simplify programming by providing a set of dedicated instructions for branching to different memory locations based on conditions.

Supports a wide range of operations: The branching instructions in the 8085 microprocessor support a wide range of operations, including conditional branching, unconditional branching, and subroutine calls.

Allows for loop execution: The branching instructions in the 8085 microprocessor can be used to implement loops by branching to a memory location that contains a loop instruction.

Disadvantages:

Limited branching range: The 8085 microprocessor has a limited branching range, which can restrict the amount of memory that can be accessed. This can be a disadvantage for applications that require a large number of branching instructions.

Limited number of condition codes: The 8085 microprocessor has a limited number of condition codes, which can restrict the types of conditions that can be tested.

Complex addressing modes: The addressing modes used in the branching instructions can be complex, which can make programming more difficult.

Limited instruction set: The 8085 microprocessor has a limited instruction set, which can limit the types of branching instructions that can be used. This can be a disadvantage for applications that require complex program flow.

Applications :

Looping: Branching instructions such as JMP, JZ, JNZ, JC, and JNC are used to implement loops in programs. This allows the program to repeat a set of instructions until a specific condition is met.

Decision-making: Conditional branching instructions are used to implement decision-making in programs. This allows the program to make decisions based on the current state of the microprocessor and branch to different parts of the program accordingly.

Subroutine calls: Call instructions, such as CALL and RET, are used to call subroutines in programs. This allows the program to reuse code and execute common tasks in a modular manner.

Interrupt handling: Branching instructions are used in interrupt handling to transfer control to an interrupt service routine. This involves branching to a different part of the program to handle the interrupt, and then returning to the main program after the interrupt is serviced.

Program flow control: Branching instructions are used to control the flow of programs by transferring control to different parts of the program based on specific conditions or events. This allows the program to execute specific tasks at specific times and in a specific order.

Last Updated : 07 May, 2023
Like Article
Save Article
Similar Reads