0% found this document useful (0 votes)
15 views5 pages

Microprocessor_pdf

The document discusses branching instructions in the 8085 microprocessor, which are crucial for altering program execution flow. It categorizes these instructions into unconditional (e.g., JMP, CALL) and conditional (e.g., JZ, JC) types, detailing their syntax, operation, and use cases. Additionally, it highlights practical applications of these instructions in programming for handling conditions like arithmetic results and user inputs.

Uploaded by

physicist sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Microprocessor_pdf

The document discusses branching instructions in the 8085 microprocessor, which are crucial for altering program execution flow. It categorizes these instructions into unconditional (e.g., JMP, CALL) and conditional (e.g., JZ, JC) types, detailing their syntax, operation, and use cases. Additionally, it highlights practical applications of these instructions in programming for handling conditions like arithmetic results and user inputs.

Uploaded by

physicist sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Ponty | 2022BCSE011

Branching Instructions in 8085


Microprocessor.

Introduction -
Branching instructions are essential for altering the
flow of execution in a program. They allow the CPU
to make decisions based on certain conditions,
enabling control structures such as loops and
conditional statements.

Types of Branching Instructions :


Branching instructions in the 8085 can be classified into two main categories:

1. Unconditional branching
2. Conditional branching

Unconditional Branching:
• Unconditional branching instructions always change the flow of execution to a specified
address, regardless of any conditions or flag statuses. eg.- JMP (Jump), CALL (Call
Subroutine), RET (Return from Subroutine).

Conditional branching:
• Conditional branching instructions alter the flow of execution based on the status of the
processor flags (Zero, Carry, Sign, etc.).
• eg. - JZ(Jump if Zero), JNZ(Jump if Not Zero), JC(Jump if Carry), JNC(Jump if No Carry),
JP(Jump if Positive), JM(Jump if Negative), JPE(Jump if Parity Even), JPO(Jump if Parity
Odd)
Ponty | 2022BCSE011

Detailed Explanation of Instructions:

1. JMP (Unconditional Jump) Instruction


The JMP instruction allows for an unconditional jump from the current program execution to a
specified memory address. Regardless of the current state of flags or conditions, control is
transferred to the new address.

Syntax: JMP 16-bit address


Operation: The 16-bit address provided in the instruction is loaded into the Program
Counter (PC), causing the microprocessor to begin executing instructions from the new
address.
Use Case: When you want the program to jump to another section of code
unconditionally. For example, if a certain routine needs to be skipped, or the program
must begin executing a subroutine or a loop.

Example: JMP 2000H ; Jump to memory location 2000H

If the instruction at memory location 2050H is JMP 2000H, the next instruction that the
microprocessor will execute is the one at memory location 2000H, skipping all instructions in
between.

2. JC (Jump if Carry) Instruction


The JC instruction is used when a conditional jump is required based on the state of the
Carry flag (CY). If a previous operation results in a carry (like after an addition that exceeds
the maximum value for a register), this instruction will jump to the specified address.

Syntax: JC 16-bit address


Condition: Jump occurs only if the Carry flag (CY) is set to 1.
Operation: After an arithmetic or logic operation, if the Carry flag is set, the instruction
will load the specified 16-bit address into the Program Counter (PC). If the Carry flag is
not set, the next instruction is executed sequentially.
Use Case: Commonly used after arithmetic operations (like addition or subtraction)
where handling overflow is necessary.

Example: JC 3000H ; Jump to memory location 3000H if the Carry flag is set

If an addition like MOV A, 09H and ADD A, 08H results in a carry (A becomes 17H, setting the
Carry flag), the JC instruction will jump to memory location 3000H.

3. JNC (Jump if No Carry) Instruction


The JNC instruction is the inverse of JC. It causes the program to jump only if no carry was
generated in the previous operation, i.e., if the Carry flag (CY) is 0.

Syntax: JNC 16-bit address


Ponty | 2022BCSE011

Condition: Jump occurs only if the Carry flag is 0.


Operation: If no carry is generated (CY=0), the instruction jumps to the specified address.
Otherwise, execution continues sequentially.
Use Case: This instruction is used when you want the program to avoid jumping if a carry
occurs, or continue execution if there was no carry.

Example: JNC 3500H ; Jump to memory location 3500H if no carry is present For instance,

after an operation like SUB or ADD, if there is no carry, the microprocessor will
jump to memory location 3500H.

4. JZ (Jump if Zero) Instruction


The JZ instruction is a conditional jump based on the Zero flag (Z). It causes the program to
jump if the result of the previous operation is zero, setting the Zero flag.

Syntax: JZ 16-bit address


Condition: Jump occurs only if the Zero flag is set (Z=1).
Operation: When the result of an arithmetic or logic operation is zero, the Zero flag is set,
and JZ will jump to the specified memory address. If the Zero flag is not set (Z=0), the
next instruction is executed.
Use Case: JZ is typically used after comparison or subtraction operations, where you
want to branch to a specific part of the program if the result of the operation is zero.

Example:

CMP B ; Compare register A with register B


JZ 4000H ; Jump to memory location 4000H if A = B (Z=1)
If A and B are equal, the Zero flag is set, and the program jumps to location 4000H.

Summary of Operation and Flag Interactions:


Instruction Condition Flag Checked

JMP Unconditional None

JC Jump if Carry flag is set Carry (CY)


(CY=1)

JNC Jump if No Carry Carry (CY)


(CY=0)

JZ Jump if Zero flag is set Zero (Z)


(Z=1)
Ponty | 2022BCSE011

Practical Use of Jump Instructions:


Branching instructions in the 8085 allow for more complex program structures such as loops,
conditional branching, and function calls. They enable the microprocessor to respond to
conditions like arithmetic results or user inputs.
In practice, a program might include:

JC and JNC for controlling how overflow or borrowing from subtraction is handled.
JZ for jumping to error-handling routines when zero results from a comparison.
JMP for directing execution to di erent parts of a program unconditionally.

Example :
Ponty | 2022BCSE011

References
1. Geeks for Geeks. (n.d.). 8085 Microprocessor
Branching Instructions. Retrieved from Geeks for
Geeks
2. ChatGPT by OpenAI. (2024). Explanation of
Branching Instructions in 8085 Microprocessor.
3. SlideShare. (n.d.). 8085 Branching Instructions.
Retrieved from SlideShare

You might also like