You are on page 1of 1

EXPERIMENT NO: 08 DATE: …../…../…..

COMPLIMENT (ALP)
AIM

Write an assembly language program for ATMega32 to compliment a number 100 times and store the
result in a memory location. Then out the result to PORT B.

EQUIPMENTS AND SOFTARE REQUIRED

Desktop or Laptop computer and Microchip Studio IDE

PROGRAM

.include "m32def.inc"

.ORG 0x0000 ; Origin address


.DEF CONT1 = R16 ; Define Reg 16 as COUNTER1
.DEF CONT2 = R17 ; Define Reg 17 as COUNTER2
.DEF DATA = R20 ; Define Reg 20 as DATA
.EQU ANSR = 0X250 ; Define Memory location 250 as ANSR

LDI CONT1, 0X0A ; Loading 0x0A to Counter 1


LDI DATA1, 0X0A ; Loading 0x0A to DATA
OUT PORTB, DATA ; OUT the answer to PORT B

LOOPA: ; Loop A
LDI CONT2, 0X0A ; Loading 0x0A to Counter 1

LOOPB: ; Loop B
COM DATA ; Compliment DATA
OUT PORTB, DATA ; OUT the answer to PORT B
DEC CONT2 ; Decrement Counter 2 by 1
BRNE LOOPB ; Branch to LOOPB
DEC CONT1 ; Decrement Counter 1 by 1
BRNE LOOPA ; Branch to LOOPA

STS ANSR, DATA ; Copy Value from DATA to ANSR

HERE: JMP HERE ; Stop program

PROCEDURE

Step 01: Open Microchip Studio


Step 02: Go to the File menu. Choose New and then Project
Step 03: In the opened dialog, Choose Assembler or C/C++. Name the project (chose any
name). Choose the path where you like to save the project by clicking on the
Browse button. Press OK.
Step 04: In the Device Selection, Select ATmega as the Device family. Choose ATmega32
(or any other Chips you want to use) Select OK.
Step 05: Writing the Assembly or C program.
Step 06: Building Program, choose Build Solution from the Build menu or Press F7.
Step 07: Debugging. To start debugging, choose Start Debugging and Break from the
Debug menu or press Alt+F5.
Step 08: To monitor the peripherals, including the I/O ports, click on the Debug menu,
choose Windows and then I/O.
RESULT

You might also like