Arithmetic instructions in AVR microcontroller
Last Updated : 07 Apr, 2025
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 register.
The following table shows the arithmetic instructions :
Instruction | Operand | Explanation | Example |
---|
ADD | D, S | D = D+ S | ADD D, S |
ADC | D, S | D = D+ S+ carry | ADC D, K |
SUB | D, S | D = D- S | SUB D, S |
SBC | D, S | D = D- S- carry | SBC D, S |
MUL | Unsigned nos. | R1= Higher byte of the result R0= Lower byte of the result | MUL D, S |
MULS | Signed nos. | R1= Higher byte of the result R0= Lower byte of the result | MULS D, S |
MULSU | Signed nos. and Unsigned nos. | R1= Higher byte of the result R0= Lower byte of the result | MULSU D, S |
INC | D | D= D+1 | INC D |
DEC | D | D= D-1 | DEC D |
Features of the arithmetic instructions in AVR microcontrollers:
Arithmetic operations: AVR microcontrollers support a variety of arithmetic operations, including addition, subtraction, multiplication, and division. These operations can be performed on data stored in registers, and can also involve immediate values or data stored in memory.
Data types: AVR microcontrollers support both 8-bit and 16-bit data types, allowing for arithmetic operations to be performed on both bytes and words of data.
Overflow detection: AVR microcontrollers provide flags to detect arithmetic overflow, which occurs when the result of an arithmetic operation exceeds the maximum or minimum value that can be stored in a register. This allows for error handling and can be used to prevent unexpected behavior in the program.
Conditional instructions: AVR microcontrollers also provide conditional arithmetic instructions, which allow for arithmetic operations to be performed only if certain conditions are met. For example, the branch instructions can be used to jump to a different part of the program depending on the result of a previous arithmetic operation.
Bit manipulation: AVR microcontrollers support a variety of instructions for manipulating individual bits within a register, including bitwise AND, OR, and XOR operations. These instructions can be used for tasks such as setting or clearing individual flags in a register.
Note : Here D and S stand for Destination and Source respectively. D and S are registers. There is no instruction for division in AVR.
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
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
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
Arithmetic Instructions in 80386 Microprocessor A Microprocessor is an important part of a computer architecture without which you will not be able to perform anything on your computer. The 80386 offers a large number of directions that take into consideration more effective and flexible processing. Thus, we should make a plunge and investigate t
4 min read