Professional Documents
Culture Documents
AVR Microcontroller Instructions Hardik Harishbhai Makwana
AVR Microcontroller Instructions Hardik Harishbhai Makwana
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 3
Recap (Mathematical Operations)
Add
Subtract
Multiply
All these operations supported by AVR
Microcontroller.
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 4
LDI Instruction
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 5
LDI Instruction
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 6
Add Instruction
Add R1, R2
R1 = R1 + R2
Answer: 0x8
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 8
Recap (Flag Register)
What are the different flags are there in AVR?
C - Carry Flag
Z - Zero Flag
N - Negative Flag
V - Overflow Flag
S - Sign Flag
H - Half Carry Flag
T - Bit Copy Storage Flag
I - Global Interrupt Enable Flag
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 9
Add Instruction Affects which flags?
C
Z
N
V
S
H
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 10
Add Instruction Affects which flags?
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 11
Add Instruction Affects which flags?
Calculate the Value of R20 at the end
LDI R20, 0x9C
LDI R21, 0x64
ADD R20, R21
1111 1
$9C 1001 1100
+ $64 0 1 1 0 0100
$100 0 0 0 0 0 0 0 0 - z
H, C, Z, V
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 12
CONSOLIDATION
LDI Instruction Loads Immediate data
into register ( R16 to R31)
ADD Instruction Adds value of source
register with the value of destination
register and stores result in destination
register.
C,Z,N,V,S & H flags can be affected
while using ADD instruction of AVR
Microcontroller.
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 13
Reference
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 14
Questions?? Doubts??
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 15
How was my session?
Saturday, June 11, 2022 AVR Microcontroller Instructions (LDI & ADD) 16