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 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 |
Note : Here D and S stand for Destination and Source respectively.
D and S are registers. There is no instruction for division in AVR.
Please Login to comment...