Conditional Branch Instructions in AVR Microcontroller Last Updated : 24 Sep, 2020 Comments Improve Suggest changes Like Article Like Report 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 Comment More infoAdvertise with us Next Article Conditional Branch Instructions in AVR Microcontroller K kunalsg18elec Follow Improve Article Tags : Electronics Engineering microprocessor Similar Reads Branch Instructions in AVR Microcontroller In this article, we will be discussing looping in AVR and branch instructions, both Conditional and Unconditional. Looping in AVR : A repeated operation or a set of instructions is known as a loop in programming. It is one of the most fundamental techniques which comes in very handy in writing code. 3 min read Arithmetic instructions in AVR microcontroller Arithmetic Instructions are the instructions which perform basic arithmetic operations such as addition, subtraction, multiplication, etc. AVR micro-controller has 2 operands which are actually registers that hold the data. The left register is the source register while the right one is the source r 2 min read Data Transfer instructions in AVR microcontroller Data transfer instructions are the instructions that are used to transfer data into micro-controller. These instructions can be used to transfer data from: Register to Register : In register-to-register transfer, data is transfer from one register to another register. Consider an example where you h 3 min read Logical Instructions in AVR Microcontroller Logical Instructions are the instructions which perform basic arithmetic operations such as AND, OR, XOR, etc. In AVR micro-controller, the destination operand is always a register. The following table shows the logical instructions : Instruction Operand Explanation Example AND D, S D = D AND S Perf 2 min read Branching instructions in 8085 microprocessor 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: Jump (unconditional and conditional) Call (unconditional and conditional) Return (unconditional and conditi 5 min read Process control instructions in 8086 microprocessor Process control instructions are the instructions which control the processor's action by setting(1) or resetting(0) the values of flag registers. Following is the table showing the list of process control instructions: OPCODEOPERANDEXPLANATIONEXAMPLESTCnonesets carry flag to 1STCCLCnoneresets carry 1 min read Machine Control Instructions in Microprocessor Microprocessors are electronic devices that process digital information using instructions stored in memory. Machine control instructions are a type of instruction that control machine functions such as Halt, Interrupt, or do nothing. These instructions alter the different type of operations execute 4 min read Data transfer instructions in 8085 microprocessor Data transfer instructions are the instructions that transfer data in the microprocessor. They are also called copy instructions. Here is the following is the table showing the list of logical instructions: OPCODEOPERANDEXPLANATIONNo. of bytesMachine cyclesNo. of T-statesEXAMPLEMOVRd, RsRd = Rs11 op 4 min read Arithmetic instructions in 8086 microprocessor Arithmetic Instructions are the instructions which perform basic arithmetic operations such as addition, subtraction and a few more. Unlike in 8085 microprocessor, in 8086 microprocessor the destination operand need not be the accumulator. Following is the table showing the list of arithmetic instru 2 min read Arithmetic instructions in 8085 microprocessor Arithmetic Instructions are the instructions which perform basic arithmetic operations such as addition, subtraction and a few more. In 8085 microprocessor, the destination operand is generally the accumulator. Following is the table showing the list of arithmetic instructions: OpcodeOperandExplanat 4 min read Like