Theory Lecture Week 6M MES Prof Muhibul
Theory Lecture Week 6M MES Prof Muhibul
Assembly Language
Programming for
ATmega328P
Status
than Z = 1, else Z = 0.
❑ N = Negative Flag, It reflects the result of an arithmetic operation. If the D7 bit of the result is
Register
zero, then N = 0 and the result is positive. Else N = 1 and the result is negative.
❑ V = Overflow Flag,
❑ S = Sign Flag,
❑ H = Half Carry Flag, this bit is set if there is a carry from D3 to D4 bit after ADD or SUB
instruction.
❑ T = Bit Copy Storage. Used as a temporary storage for bit. It can be used to copy a bit from a
GPR to another GPR.
❑ I = Global Interrupt Enable
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan
Professor, Department of EEE, American International University-Bangladesh (AIUB), Dhaka, Bangladesh Slide # 4 of Total 32 Slides
Lecture # 05: Assembly Language Programming for ATmega328P
❑ DDRB= 0x 05; 0 0 0 0 0 0 0 1
If b no bit of A register is 1,
SBIS A, b Skip if Bit in I/O Register is set None 1
then skip PC by 2 or 3.
STS 0x60, R0
PC = PC+2 or 3
CBI DDRB, 5;
DDRB Register SBIS R8, 5;
PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 R8 Register
0 0 0 0 0 0 0 0 8 7 6 5 4 3 2 1
1 1 1 1 1 1 1 1
PC = PC+2 or 3
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan
Professor, Department of EEE, American International University-Bangladesh (AIUB), Dhaka, Bangladesh Slide # 10 of Total 32 Slides
Lecture # 05: Assembly Language Programming for ATmega328P
7 6 5 4 3 2 1 0
EEPM(1:0) EERIE EEMPE EEPE EERE
➢ Step 1: Start
➢ Step 2: Declare two variables
Declare variables
C, F
➢ Step 1: Start
➢ Step 2: Declare and initialize a variable with a 0 value
➢ Step 3: Increment the variable value by 1 and store it
in the same declared variable
➢ Step 4: Print the value stored in the variable
➢ Step 5: If the variable is < 20 then go to step 3,
otherwise go to the next step
➢ Step 6: Stop