Conditional branch instructions are the set of instructions that is used to branch out of a loop. We will discuss these instructions for the AVR micro-controller.

To understand these instructions, first, we need to know about the registers in the AVR micro-controller.

**Status Register (SReg) :**- It is the flag register in the AVR micro-controller.
- It is a 8 – bit register. Only 6 of these 8 bits are called conditional flags. They are C, Z, N, V, S, H.
- The value of these bits indicates some conditions that result after the execution of an instruction.

**C – Carry Flag :**- This flag is set whenever there is a carryout from the D7 bit.
- This flag bit is affected after an 8-bit addition or subtraction.

**Z – Zero Flag :**- The zero flag reflects the result of an arithmetic or logic operation.
- If the result is zero, then Z = 1. Therefore, Z = 0 if the result is not zero.

**N – Negative Flag :**- Binary representation of signed numbers uses D7 as the sign bit.
- The negative flag reflects the result of an arithmetic operation. If the D7 bit of the result is zero.
- Then N = 0 and the result is positive. If the D7 bit is one, then N = 1 and the result is negative.

**V – Overflow Flag :**- This flag is set whenever the result of a signed number operation is too large.
- Causing the high-order bit to overflow into the sign bit.

**S – Sign Flag :**- This flag is the result of Exclusive-ORing of N and V flags.

**H – Half Carry Flag :**- If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared.
- This flag bit is used by instructions that perform BCD (binary coded decimal) arithmetic.

The following table shows a few branch loop instructions :

Instruction | Explanation | Flag Status |
---|---|---|

BREQ | Branch if equal | Branch if Z = 1 |

BRNE | Branch if not equal | Branch if Z = 0 |

BRSH | Branch if same or higher | Branch if C = 0 |

BRLO | Branch if lower | Branch if C = 1 |

BRLT | Branch if less than (signed) | Branch if S = 1 |

BRGE | Branch if greater than or equal (signed) | Branch if S = 0 |

BRVS | Branch if Overflow flag set | Branch if V = 1 |

BRVC | Branch if Overflow flag clear | Branch if V = 0 |

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Arithmetic instructions in AVR microcontroller
- Data Transfer instructions in AVR microcontroller
- Logical Instructions in AVR Microcontroller
- Introduction to 8051 Microcontroller
- Pin diagram of 8051 Microcontroller
- Difference between AVR and ARM
- Difference between 8051 and AVR
- Difference between AVR and PIC
- Branch Prediction in Pentium
- Correlating Branch Prediction
- Machine Instructions
- Computer Organization | Basic Computer Instructions
- Arithmetic instructions in 8085 microprocessor
- Logical instructions in 8085 microprocessor
- Data transfer instructions in 8085 microprocessor
- Branching instructions in 8085 microprocessor
- Arithmetic instructions in 8086 microprocessor
- Logical instructions in 8086 microprocessor
- Data transfer instructions in 8086 microprocessor
- 8086 program to transfer a block of 4 bytes by using string instructions

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.