0% found this document useful (0 votes)
3 views77 pages

Microcontroller

The document is a laboratory manual for the Microprocessors and Microcontrollers Laboratory course at Madras Institute of Technology, Anna University. It outlines the vision, mission, program educational objectives, program outcomes, course outcomes, and a list of experiments to be conducted, including operations like addition, subtraction, division, and multiplication using the 8085 microprocessor. The manual serves as a guide for students to understand and implement various microprocessor functionalities through practical experiments.

Uploaded by

mddhiyan157
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views77 pages

Microcontroller

The document is a laboratory manual for the Microprocessors and Microcontrollers Laboratory course at Madras Institute of Technology, Anna University. It outlines the vision, mission, program educational objectives, program outcomes, course outcomes, and a list of experiments to be conducted, including operations like addition, subtraction, division, and multiplication using the 8085 microprocessor. The manual serves as a guide for students to understand and implement various microprocessor functionalities through practical experiments.

Uploaded by

mddhiyan157
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MADRAS INSTITUTE OF TECHNOLOGY

ANNA UNIVERSITY

CHROMEPET, CHENNAI-600044

LABORATORY MANUAL

EC23C21 – MICROPROCESSORS AND


MICROCONTROLLERS LABORATORY

(Regulation – 2023)

MOHAMMED DHIYAN S
2024504541
DEPARTMENT OF ELECTRONICS ENGINEERING

MADRAS INSTITUTE OF TECHNOLOGY

ANNA UNIVERSITY
LABORATORY MANUAL

EC23C21 – MICROPROCESSORS AND


MICROCONTROLLERS LABORATORY

(Regulation – 2023)

DEPARTMENT OF ELECTRONICS ENGINEERING

MADRAS INSTITUTE OF TECHNOLOGY

ANNA UNIVERSITY

Prepared By Approved By
VISION

To be recognized as a benchmark and trend setter in Electronics and


Communication Engineering domain keeping in phase with rapidly changing
technologies through effective partnership with reputed academic institutions,
research organizations, industries and community.

MISSION

o Create highly motivated, technologically competent human resource by


imparting high quality technical education through flexible student
centric updated curricula suited to students with diverse backgrounds.

o Adopt best teaching and learning practices and establish state-of-the-


art facilities to provide quality academic ambience for innovativeness,
research and developmental activities.

o Enhance collaborative activities with academic institutions and


industries for evolving indigenous technological solutions to meet
societal needs and nurture leadership and entrepreneurship qualities
with ethical means.

o Facilitate adequate exposure to the students, faculty and staff through


training in the state-of-the art technologies, efficient administration,
global outreach and benchmarking against referential institutions.
PROGRAMME EDUCATIONAL OBJECTIVES (PEOs):

PEO1: The graduated Students will demonstrate sufficient theoretical, analytical and
initiative skills in Basic Sciences and Engineering necessary, to assimilate, analyze,
synthesize and innovative solutions to meet societal needs.

PEO2: The graduated students will have inculcated a thirst for lifelong learning and
sustained research interest.

PEO 3: The graduated students will practice values and exhibit leadership qualities
and team spirit to promote entrepreneurship and indigenization.
PROGRAMME OUTCOMES (POs):
PO1: Ability to apply technical knowledge in mathematics, Science and Engineering
leading to the realization and evaluation of complex systems, through research problems
in the context of evolving societal needs.

PO2: Imaginative critical thinking with an ability to think critically, analyze and solve
Engineering problems.

PO3: Ability to design a system, component, or process to meet desired needs within
realistic constraints.

PO4: Ability to, gather user needs and requirements, design, develop, integrate, and test
complex systems by employing systems engineering thinking and processes, within
required operational and acquisition system environments.

PO5: Personal and intellectual autonomy to independently and with an openness to reflect
upon and use modern engineering tools necessary to engineering practices.

PO6: Educational practices necessary to understand the impact of engineering solutions in


a global, economical, environmental and societal context.

PO7: An active and committed global citizen with an awareness of contemporary issues
and their Impact on economic, environmental, social, political, ethical, health and
safety, manufacturability and sustainability.

PO8: An understanding of professional, ethical, legal issues and responsibilities.

PO9: A creative, enterprising team player and engaged participative leader able to effect
change.

PO10: A confident, resilient and adaptable individual with good communication skills.

PO11: Exercise their responsibilities in the management of cost-effective systems product


development by leading and participating in interdisciplinary teams.

PO12: Active exploration of new ideas through lifelong learning.


Course Outcomes:
CO1: Abilitytounderstandthefeaturesandcomponentsof8-bitand16-bit microprocessors.

CO2: Ability to develop assembly language programme and interface peripherals with

microprocessors.

CO3: Ability to understand the 8051 architecture and the methodology to configure and

program peripherals.

CO4: Ability to design, develop and troubleshoot as simple microprocessor or

microcontroller based systems.

CO5: Ability to understand the ARM architecture and the methodology to configure and

program peripherals.

Course Articulation Matrix:


PO
CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

CO1 2 1 1 1 1

CO2 2 1 1 1 1

CO3 3 3 2 1 1 1 1

CO4 2 2 2 1 1 1

CO5 3 3 3 3 2 1 1 1

Avg 2.2 2 2.33 1.4 1.5 1 1 1


LIST OF EXPERIMENTS:
1. Programs for 8/16-bit Arithmetic, Sorting and Searching operations in 8085 and 8086

2. 7segment display with 8085 or 8086 using 8255 interface.

3. Stepper and DC motor control using 8085 or 8086 microprocessor.

4. Interfacing ADC, DAC with 8085 or 8086 microprocessor.

5. Configuring and programming Timer and Interrupts in 8051 microcontrollers.

6. Data transmission and reception using UART in 8051 microcontrollers.

7. Interfacing LED, LCD, Switch and 4x4 Keypad with ARM processor.

8. Interfacing Sensor and Actuator with ARM processor.

9. Configuring and Programming of Timers/ Counters and Interrupts in ARM Processor.

10. UART and SPI Interfacing using ARM processor.

11. Interfacing RTC and EEPROM with 8051 or ARM processor.


INDEX

Exp.
Date Title of the Experiment Page Marks Remarks
No.
EX NO: ADDITION OF TWO 8-BIT NUMBERS
DATE:

Aim :
To perform Addition of two 8-bit numbers using 8085 microprocessor.

Algorithm :
1. Set the register C to zero.

2. Load the first data in any register (say B).

3. Load the second data in the accumulator.

4. Add the 2 data.

5. If carry arises, increment the C register.

6. If no carry arises, do not increment the C register.

7. Store the result in memory.

Program :

MVI C,00

LDA 8150

MOV B,A

LDA 8151

ADD B

JNC LOOP
INR C

LOOP STA 8152

MOV A,C

STA 8153

HLT

Execution table :
Memory Hex Label Mnemonics Comments

Address Code

8000 0E MVI C,00 Initialize register C to zero. This register

8001 00 will be incremented if carry arises in

addition

8002 3A LDA 8150 load the contents of memory location

8003 50 8150 to the accumulator

8004 81

8005 47 MOV B,A Move contents of accumulator to

register B

8006 3A LDA 8151 load the contents of memory location

8007 51 8151 to the accumulator

8008 81

8009 80 ADD B Add contents of B register with the

Accumulator
800A D2 JNC LOOP
If carry does not arise after addition
800B 0E
jump to label LOOP
800C 80

800D 0C INR C If carry arises after addition, increment

the register C

800E 32 LOOP STA 8152


Store the contents of accumulator to
800F 52
the memory location 8152
8010 81

8011 79 MOV A,C Move data from C register to the

accumulator

8012 32 STA 8153


Store this content in the memory
8013 53
location 8153
8014 81

8015 76 HLT Halt the program


Output Table :

Case 1: No carry arises.

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8150 23 8152 7A

8151 57 8153 00

Case 2 : Carry arises.

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8150 78 8152 0A

8151 92 8153 01

Result :

Thus the assembly Language Program to perform addition of two 8-bit numbers is

performed using 8085 Microprocessor.


EX NO: SUBTRACTION OF TWO 8-BIT NUMBERS
DATE:

Aim :

To perform Subtraction of two 8-bit numbers using 8085 microprocessor.

Algorithm :

1. Set the register C to zero.

2. Load the first data in any register (say B).

3. Load the second data in the accumulator.

4. Subtract the 2 data.

5. If borrow arises, take 2’s complement of the accumulator.

6. Increment the C register.

7. If no carry arises, do not take the 2’s complement.

8. Store the result in memory.

Program :

MVI C,00

LDA 8150

MOV B,A

LDA 8151

SUB B

JNC LOOP
CMA

INR A

INR C

LOOP STA 8152

MOV A,C

STA 8153

HLT

Execution table :

Memory Hex
Label Mnemonics Comments
Address Code

8000 0E MVI C,00 Initialize register C to zero. C is

incremented if borrow arises after


8001 00
subtraction

8002 3A LDA 8150


load the contents of memory location 8150
8003 50
to the accumulator
8004 81

8005 47 MOV B,A Move contents of accumulator to register B

8006 3A LDA 8151


load the contents of memory location 8151
8007 51
to the accumulator
8008 81
Subtract the contents of B from
8009 80 ADD B
accumulator contents

800A D2 JNC LOOP


If borrow does not arise, jump to the label
800B 0E
named LOOP
800C 80

800D 2F CMA Complement the data in the accumulator

800E 3C INR A Increment the accumulator content

800F 0C INR C Increment the register C

8010 32 LOOP STA 8152


Store the contents of accumulator to the
8011 52
memory location 8152
8012 81

Move data from C register to the


8013 79 MOV A,C
accumulator

8014 32 STA 8153


Store this content in the memory location
8015 53
8153
8016 81

8017 76 HLT Halt the program


Output Table:

Case 1: No borrow arises.

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8150 57 8152 34

8151 23 8153 00

Case 2: Borrow arises.

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8150 23 8152 CC

8151 57 8153 01

Result :

Thus the assembly Language Program to perform subtraction of two 8-bit

numbers is performed using 8085 Microprocessor.


EX NO: DIVISION OF TWO 8-BIT NUMBERS
DATE:

Aim :

To perform division of two 8-bit numbers using 8085 microprocessor.

Algorithm :

1. Load the dividend in B register

2. Load the divisor in the accumulator

3. Clear the C register

4. Compare the data in register B with that of the accumulator

5. If the data in the accumulator is larger than the data in register B, increment C register

6. Subtract B from Accumulator

7. Repeat steps 4,5 and 6

8. Once the data in the accumulator is less than the data in the B register, stop the process

9. The remainder is in the accumulator and the quotient is in C register.

10. Store the results in memory.

Program:

LXI H,8150

MOV B,M

MVI C,00
INX H

MOV A,M

LOOP 2 CMP B

JC LOOP 1

SUB B

INR C

JMP LOOP 2

LOOP 1 STA 8152

MOV A,C

STA 8153

HLT
Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8150
8001 50 Move 8150 to HL register pair
8002 81
Move data from memory pointer to
8003 46 MOV B,M
register B
8004 0E MVI C,00
Initialize C register to zero
8005 00
8006 23 INX H increment H register
Move contents of memory pointer to A
8007 7E MOV A,M
register
LOOP
8008 B8 CMP B compare B with data in accumulator
2
8009 DA JC LOOP 1
800A 11 If carry flag is set, jump to LOOP 1
800B 80
subtract data in B from the accumulator
800C 90 SUB B
contents
800D 0C INR C Increment C register
800E C3 JMP LOOP2 Jump to location indicated by LOOP 2
800F 08 Jump to location indicated by LOOP 2
800D 0C INR C Increment C register
8010 80
8011 32 LOOP 1 STA 8152 Store the data in the accumulator in
memory location 8152
8012 52
8013 81
8014 79 MOV A,C Move data from register C to the
accumulator
8015 32 STA 8153 store the accumulator data to memory
location 8153
8016 53
8017 81
8018 76 HLT Halt the program.
Output table:

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8150 02 8152 01

8151 13 8153 02

Result :

Thus the assembly Language Program to perform division of two 8-bit

numbers is performed using 8085 Microprocessor.


EX NO: MULTIPLICATION OF TWO 8-BIT NUMBERS
DATE:

Aim :

To perform multiplication of two 8-bit numbers using 8085 microprocessor.

Algorithm :

1. Load the multiplicand in any register (say E).

2. Load the multiplier in the accumulator


3. Clear the HL register pair and the D register.

4. Rotate the data in the accumulator through the carry 8 times.

5. Each time check if the carry flag is 1 or not

6. If carry flag is 1, perform DAD operation with DE register pair.

7. If no carry flag is 0, perform DAD operation with HL register pair itself.

8. Store the result in memory.

Program

LDA 8500

MOV E, A

LDA 8501

MVI C,09

MVI D,00

LXI H,0000
LOC 1 DCR C

JZ LOC 3

DAD H

RLC

JNC LOC 1

DAD D

LDA 8500

MOV E, A

LDA 8501

MVI C,09

MVI D,00

LXI H,0000

LOC 1 DCR C

JZ LOC 3

DAD H

RLC

JNC LOC 1

DAD D

Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 3A LDA 8500
Load the data from memory location 8500 to the
8001 00
accumulator
8002 85
8003 5F MOV E,A Move data from accumulator to E register
8004 3A LDA 8501
Load the data from memory location 8501 to the
8005 1
accumulator
8006 85
8007 0E MVI C,09
Initialize C register to 09
8008 9
8009 16 MVI D,00
Clear D register
800A 00
800B 21 LXI H,0000
800C 00 Clear HL register pair
800D 00
800E 0D LOC 1 DCR C Decrement C regiter
800F CA JZ LOC 3
8010 19 If zero flag is set, jump to location 3
8011 80
8012 29 DAD H Perform 16 bit addition of HL with HL pair
8013 7 RLC Rotate the contents of accumulator left
8014 D2 JNC LOC 1
8015 0E If carry flag is not set, jump to location 1
8016 80
8017 19 DAD D Perform 16 bit addition of HL with DE pair
8018 C3 JMP LOC 1
8019 0E jump to location 1
801A 80
801B 7C LOC 3 MOV A,H Move the data from H register to the accumulator
801C 32 STA 8502
store the data in accumulator in the memory
801D 2
location 8502
801E 85
801F 7D MOV A,L Move the data from L register to the accumulator
8020 32 STA 8503
store the data in the accumulator in the memory
8021 3
location 8503
8022 85
8023 76 HLT Halt the program

Output Table:
INPUT OUTPUT

Memory Memory
Data Data
Address Address

8500 12 8502 01

8501 13 8503 56

Result :

Thus the assembly Language Program to perform multiplication of two 8-bit

numbers is performed using 8085 Microprocessor.


EX NO: MULTIPLICATION OF TWO 8-BIT NUMBERS
DATE:
Aim :

To perform 16 bit division using 8085 microprocessor.

Algorithm :

1. Load the dividend in the HL register.

2. Load the divisor in any 8-bit register.

3. The divisor is subtracted from the dividend .

4. Each time this subtraction is done, a register indicating quotient is incremented.

5. The results are stored in the memory.

Program :

LHLD 8200
LDA 8202
MOV C,A
LXI D,0000
LOOP 1: MOV A,L
SUB C
MOV L,A
JNC LOOP 2
DCR H
LOOP 2: INX D
MOV A,H
CPI 00
JNZ LOOP 1
MOV A,L
CMP C
JNC LOOP 1
MOV A,L
CMP C
JNC LOOP 1
SHLD 8302
XCHG
SHLD 8300
HLT
Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code

8000 2A LHLD 8200


Load the contents of memory locations 8200
8001 00
and 8201 into HL register pair
8002 82

8003 3A LDA 8202


Load the contents of memory location 8202 into
8004 02
the accumulator
8005 82

8006 4F MOV C,A Copy the contents of accumulator to register C

8007 11 LXI D,0000

8008 00 Initialize DE register pair

8009 00
LOOP Move the contents of L register to the
800A 7D MOV A,L
1 accumulator
Subtract contents of C register with the data in
800B 91 SUB C
the accumulator
800C 6F MOV L,A Copy the contents of accumulator to register L

800D D2 JNC LOOP 2


If carry flag is not set, jump to loop 2
800E 11
800F 80

8010 25 DCR H Decrement H register


LOOP
8011 13 INX D Increment the data in HL register pair
2
Copy the contents of H register to the
8012 7C MOV A,H
accumulator
8013 FE CPI 00
Compare 00 with data in the accumulator
8014 00

8015 C2 JNZ LOOP 1

8016 0A If zero flag is not set, jump to loop 1

8017 80
Copy the contents of L register to the
8018 7D MOV A,L
accumulator
Compare the data in the C register with that of
8019 B9 CMP C
the accumulator
801A D2 JNC LOOP 1

801B 0A If carry flag is not set, jump to loop 1

801C 80

801D 22 SHLD 8302


Store the contents of HL register pair in
801E 02
memory locations 8302 and 8303
801F 83
Exchange the contents of DE and HL register
8020 EB XCHG
pair
8021 22 SHLD 8300
Store the contents of HL register pair in
8022 00
memory locations 8300 and 8301
8023 83

8024 76 HLT Stop the execution of the program

Output Table:
INPUT OUTPUT

Memory Memory
Data Data
Location Location

8200 32 8302 08

8201 32 8303 08

8202 04 8300 00

8301 00

Result :

Thus the assembly Language Program to perform 16 bit division is

performed using 8085 Microprocessor.


EX NO: MULTIPLICATION OF TWO 8-BIT NUMBERS
DATE:
Aim :

To perform 16 bit multiplication using 8085 microprocessor.

Algorithm :

1. Load the multiplicand in the SP register.

2. Load the multiplier in any 8-bit register.

3. The multiplier is user as counter.

4. The multiplicand is added as many times as this counter.

5. If a carry arises in addition, a new register is incremented.

6. The results are stored in the memory.

Program :LXI D,0000

LXI H,0000
LXI SP,8400
MVI B,00
MVI C,03
LOC 1: DAD SP
JC LOC 2
LOC 3: DCX B
MOV A,C
ORA B
JNZ LOC 1
HLT
LOC 2: INX D
JMP LOC 3
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 11 LXI D,0000
8001 00 Initialize DE pair to zero
8002 00
8003 21 LXI H,0000 Initialize HL pair to zero
8004 00
8005 00
8006 31 LXI SP,8400
8007 00 Load multiplicand into SP
8008 84
8009 06 MVI B,00
Initialize B register to zero
800A 00
800B 0E MVI C,03
Load C register with multiplier
800C 03
800D 39 LOC 1 DAD SP Add contents of SP with that of HL pair
800E CA JC LOC 2
800F 18 If carry arises, jump to loc 2
8010 80
8011 0B LOC 3 DCX B Decrement BC pair
8012 79 MOV A,C Copy contents of register C to register A
8013 B0 ORA B logical OR of B register with Accumulator
8014 C2 JNZ LOC 1 If zero flag is not set, jump to loc 1
8015 0D
8016 80
8017 76 HLT Stop the program execution
8018 13 LOC 2 INX D Increment DE register pair
8019 C3 JMP LOC 3
801A 11 Unconditional jump to loc 3
801B 80

Output Table:
INPUT OUTPUT

Register Data Register Data

SP 8400 HL 8C00

BC 0003 DE 0001

Result :

Thus the assembly Language Program to perform 16 bit multiplication is


performed using 8085 Microprocessor.
EX NO: TO ARRANGE AN ARRAY IN ASCENDING ORDER
DATE:

Aim :
To arrange the elements in an array in ascending order using 8085 microprocessor.
Algorithm :
1. Compare the first two 8-bit numbers in the memory.
2. Interchange them if the value in first memory location is greater than the value
in second memory location. Otherwise, don’t interchange.
3. Compare the contents of second and third memory location and, interchange if
needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.
Program :

LXI H,8200
MOV C,M
DCR C
LOOP 1 MOV D,C
LXI H,8201
LOOP 2 MOV A,M
INX H
CMP M
JC LOOP 3
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
LOOP 3 DCR D
JNZ LOOP 2
DCR C
JNZ LOOP 1
HLT

Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8200
8001 00 Load HL register pair with the value 8200
8002 82
8003 4E MOV C,M Move the data in the location pointed out
by M to register C
8004 0D DCR C Decrement C register
8005 51 LOOP 1 MOV D,C Move the data in register C to register D
8006 21 LXI H,8201
8007 01 Load HL register pair with the value 8201
8008 82
8009 7E LOOP 2 MOV A,M Move the data in the location pointed out
by M to the accumulator
800A 23 INX H Increment data in HL pair
800B BE CMP M Compare the data pointed out by M with
the data in accumulator
800C DA JC LOOP 3
800D 14 If carry flag is set, jump to loop 3
800E 80
800F 46 MOV B,M Move the data in the location pointed out
by M to B register
8010 77 MOV M,A Move the accumulator data to the
memory location pointed by M
8011 0B DCX H Decrement the data in HL pair
8012 70 MOV M,B Move the data in B register to the memory
location pointes by M
8013 23 INX H Increment data in HL pair
8014 15 LOOP 3 DCR D Decrement data in D register
8015 C2 JNZ LOOP 2
8016 09 If zero flag is not set, jump to loop 2
8017 80
8018 0D DCR C Decrement C register
8019 C2 JNZ LOOP 1
If zero flag is not set, jump to loop 1
801A 05
801B 80
801C 76 HLT Halt the program execution

Output Table:

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8200 02 8200 02

8201 13 8201 09

8202 09 8202 13

8203 23 8203 14

8204 14 8204 23

Result :

Thus the assembly Language Program to arrange the elements in an array in


ascending order is performed using 8085 Microprocessor.
EX NO: TO ARRANGE AN ARRAY IN DESCENDING ORDER
DATE:

Aim :

To arrange the elements in an array in descending order using 8085 microprocessor.

Algorithm :

1. Compare the first two 8-bit numbers in the memory.

2. Interchange them if the value in first memory location is smaller than the value in

second memory location.

Otherwise, don’t interchange.

3. Compare the contents of second and third memory location and, interchange if

needed.

4. Continue this process till the last two numbers are compared and interchanged.

5. Repeat the above steps n-1 times.

Program :

LXI H,8200
MOV C,M
DCR C
LOOP 1 MOV D,C
LXI H,8201
LOOP 2 MOV A,M
INX H
CMP M

Page 36
JNC LOOP 3
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
LOOP 3 DCR D
JNZ LOOP 2
DCR C
JNZ LOOP 1
HLT

Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8200
8001 00 Load HL register pair with the value 8200
8002 82
8003 4E MOV C,M Move the data in the location pointed out
by M to register C
8004 0D DCR C Decrement C register
8005 51 LOOP 1 MOV D,C Move the data in register C to register D
8006 21 LXI H,8201
8007 01 Load HL register pair with the value 8201
8008 82
8009 7E LOOP 2 MOV A,M Move the data in the location pointed out
by M to the accumulator
800A 23 INX H Increment data in HL pair
800B BE CMP M Compare the data pointed out by M with
the data in accumulator
800C DA JNC LOOP 3
800D 14 If carry flag is not set, jump to loop 3
800E 80
800F 46 MOV B,M Move the data in the location pointed out
by M to B register

Page 37
8010 77 MOV M,A Move the accumulator data to the memory
location pointed by M
8011 0B DCX H Decrement the data in HL pair
8012 70 MOV M,B Move the data in B register to the memory
location pointes by M
8013 23 INX H Increment data in HL pair
8014 15 LOOP 3 DCR D Decrement data in D register
8015 C2 JNZ LOOP 2
8016 09 If zero flag is not set, jump to loop 2
8017 80
8018 0D DCR C Decrement C register
8019 C2 JNZ LOOP 1
If zero flag is not set, jump to loop 1
801A 05
801B 80
801C 76 HLT Halt the program execution

Output Table:

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8200 02 8200 23

8201 13 8201 14

8202 09 8202 13

8203 23 8203 09

8204 14 8204 02

Result :

Page 38
Thus the assembly Language Program to arrange the elements in an array in

descending order is performed using 8085 Microprocessor.

EX NO: TO FIND THE LARGEST VALUE IN AN ARRAY


DATE:
Aim :

To find the largest value in an array using 8085 microprocessor.

Algorithm :

1. Store an array of numbers in the memory

2. Initialize the C register equal to the number of elements in the array

3. Load the first data in the accumulator

4. Compare this data with the second data in the array

5. If the data in the accumulator is lesser than the other data in the memory, perform

swapping

6. Else retain the data in the accumulator

7. Repeat the above steps till count reduces to zero

8. Finally, the largest data is the data in the accumulator

9. Store the result in memory

Program:
MVI C,05
LXI H,8500
MOV A,M
LOC 1 DCR C
JZ LOC 2

Page 39
INX H
CMP M
JNC LOC 1
MOV A,M
JMP LOC 1
LOC 2 STA 8600
HLT

Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code
8000 0E MVI C,05 Move an immediate value of 5 to the
8001 05 register C
8002 21 LXI H,8500
8003 00 Load HL pair with 8500
8004 85
Move the contents of location pointed
8005 7E MOV A,M
out by M to the accumulator
8006 0D LOC 1 DCR C Decrement the counter ( C register)
8007 CA JZ LOC 2
8008 13 If zero flag is set, jump to location 2
8009 80
800A 23 INX H Increment HL pair
Compare the data in the accumulator
800B BE CMP M
with the data pointed by M
800C D2 JNC LOC 1
800D 06 If carry flag is not set, jump to location 1
800E 80
Move the contents of location pointed
800F 7E MOV A,M
out by M to the accumulator
8010 C3 JMP LOC 1
8011 06 Unconditional jump to location 1
8012 80
8013 32 LOC 2 STA 8600 Store contents of accumulator in the
8014 00 memory location 8500

Page 40
8015 86
8016 76 HLT Halt the program

Output Table:
INPUT OUTPUT

Memory Memory
Data Data
Address Address

8500 2 8600 23

8501 13

8502 9

8503 23

8504 14

Result :

Thus the assembly Language Program to find out the largest value in an

array is performed using 8085 Microprocessor.

Page 41
EX NO: TO FIND THE SMALLEST VALUE IN AN ARRAY
DATE:
Aim :

To find the smallest value in an array using 8085 microprocessor.

Algorithm :

1. Store an array of numbers in the memory

2. Initialize the C register equal to the number of elements in the array

3. Load the first data in the accumulator

4. Compare this data with the second data in the array

5. If the data in the accumulator is greater than the other data in the memory, perform

swapping

6. Else retain the data in the accumulator

7. Repeat the above steps till count reduces to zero

8. Finally, the smallest data is the data in the accumulator

9. Store the result in memory

Program :

MVI C,05
LXI H,8500
MOV A,M
LOC 1 DCR C
JZ LOC 2
INX H
CMP M

Page 42
JC LOC 1
MOV A,M
JMP LOC 1
LOC 2 STA 8600
HLT

Execution Table:

Memory Hex
Label Mnemonics Comments
Address Code
8000 0E MVI C,05 Move an immediate value of 5 to the
8001 05 register C
8002 21 LXI H,8500
Load HL pair with 8500
8003 00
8004 85
Move the contents of location pointed
8005 7E MOV A,M
out by M to the accumulator
8006 0D LOC 1 DCR C Decrement the counter ( C register)
8007 CA JZ LOC 2
8008 13 If zero flag is set, jump to location 2
8009 80
800A 23 INX H Increment HL pair
Compare the data in the accumulator
800B BE CMP M
with the data pointed by M
800C DA JC LOC 1
800D 06 If carry flag is set, jump to location 1
800E 80
Move the contents of location pointed
800F 7E MOV A,M
out by M to the accumulator
8010 C3 JMP LOC 1
Unconditional jump to location 1
8011 06
8012 80
8013 32 LOC 2 STA 8600 Store contents of accumulator in the
8014 00 memory location 8500
8015 86
8016 76 HLT Halt the program

Page 43
Output Table:

INPUT OUTPUT

Memory Memory
Data Data
Address Address

8500 02 8600 02

8501 13

8502 09

8503 23

8504 14

Result :

Thus the assembly Language Program to find out the smallest value in an
array is performed using 8085 Microprocessor.

Page 44
EX NO: BASIC ARITHMETIC OPERATIONS USING 8086
DATE: MICROPROCESSOR

Aim:
To perform basic arithmetic operations like addition, subtraction, multiplication,
division.

Algorithm:
Move the contents to the contents to the respective registers.
1. Add the content and store the result in a memory location.
2. Repeat step 2 for subtraction, multiplication, division.
3. Execute the program.
4. To see the result go to the respective memory location where the
5. results are stored.

Program:
MOV AX,2000
MOV BX,1000
MOV CX,AX
ADD AX,BX
MOV [2000],AX
MOV AX,CX
SUB AX,BX
MOV [2002],AX
MOV AX,CX
MUL BX
MOV [2004],AX
MOV [2006],DX
MOV AX,CX
DIV BX

Page 45
MOV [2008],AL
MOV [2009],DX
INT 3

Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS

8000 MOV AX,2000 Move the content to register AX

8003 MOV BX,1000 Move the content to register BX

8006 MOV CX,AX Move the content of register AX to CX

8008 ADD AX,BX Add contents of AX and BX

800A MOV [2000],AX Move the content of register AX to memory


location 2000
800C MOV AX,CX Move the content of register CX to AX

800E SUB AX,BX Subtracts BX from AX

8010 MOV [2002],AX Move the content of register AX to memory


location 2002
8012 MOV AX,CX Move the content of register CX to AX

8014 MUL BX Multiplies BX content with accumulator content

8016 MOV [2004],AX Move the content of register AX to memory


location 2004
8018 MOV [2006],DX Move the content of register DX to memory
location 2006
801A MOV AX,CX Move the content of register CX to AX

801C DIV BX Divide content of accumulator with content of BX


801E MOV [2008],AL Move the content of register AL to memory
location 2008
8020 MOV [2009],DX Move the content of register DX to memory
location 2009
8022 INT 3 End of program

Page 46
Output Table:
OUTPUT

MEMORY DATA
ADDRESS
2000 3000

2002 1000

2004 0200

2006 0000

2008 02

2009 00

Result:
Thus the assembly language program to perform basic arithmetic operations
using 8086 is performed.

Page 47
EX NO: ASCENDING ORDER
DATE:

Aim:
To arrange the given set of numbers in ascending order.

Algorithm:
1. The count and the numbers to be arranged is stored in memory locations.
2. Count is moved to CL and DL register.
3. First two numbers are transferred to AL and BL registers.
4. Both are compared and swapped.
5. The result is the numbers arranged in order in the memory locations.

Program:
MOV SI,9000
MOV CL,[SI]
LOC4: MOV SI,9000
MOV DL,[SI]
INC SI
MOV AL,[SI]
LOC3: INC SI
MOV BL,[SI]
CMP AL,BL
JNB LOC1
DEC SI
MOV [SI],AL
MOV AL,BL
JMP LOC2
LOC1: DEC SI

Page 48
MOV [SI],BL
LOC2: INC SI
DEC DL
JNZ LOC3
MOV [SI],AL
DEC CL
JNZ LOC4
INT 3

Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS

8000 MOV SI,9000 Move 9000 to SI

8003 MOV CL,[SI] Content of SI moved to CL register

8005 MOV SI,9000 Move 9000 to SI

8008 MOV DL,[SI] Content of SI moved to DL register

800A INC SI Increments SI by one

800C MOV AL,[SI] Content of SI moved to AL register

800E INC SI Increments SI by one

8010 MOV BL,[SI] Content of SI moved to BL register


8012 CMP AL,BL Compares contents of registers AL and BL

8014 JNB LOC1 If not below goes to loc1

8016 DEC SI Decrements SI by one

8018 MOV [SI],AL Content of AL moved to SI register

Page 49
801A MOV AL,BL Content of BL moved to AL register

801C JMP LOC2 Jumps to loc2

801E DEC SI Decrements SI by one

8020 MOV [SI],BL Content of BL moved to SI register

8022 INC SI Increments SI by one

8024 DEC DL Decrements DL by one

8026 JNZ LOC3 If not zero jumps to loc3

8028 MOV [SI],AL Content of AL moved to SI register

802A DEC CL Decrements CL by one

802C JNZ LOC4 If not zero jumps to loc4

802E INT 3 End of program

Output Table:
INPUT OUTPUT

MEMORY DATA MEMORY DATA


ADDRESS ADDRESS
9000 04 9000 04

9001 08 9001 02

9002 05 9002 05

9003 09 9003 08

9004 02 9004 09

Page 50
Result:
Thus the numbers are arranged in ascending order using 8086.

Page 51
EX NO: DESCENDING ORDER
DATE:
Aim:
To arrange the given set of numbers in descending order.

Algorithm:
1. The count and the numbers to be arranged is stored in memory locations.
2. Count is moved to CL and DL register.
3. First two numbers are transferred to AL and BL registers.
4. Both are compared and swapped.
5. The result is the numbers arranged in order in the memory locations.

Program:
MOV SI,9000
MOV CL,[SI]
LOC4: MOV SI,9000
MOV DL,[SI]
INC SI
MOV AL,[SI]
LOC3: INC SI
MOV BL,[SI]
CMP AL,BL
JB LOC1
DEC SI
MOV [SI],AL
MOV AL,BL
JMP LOC2
LOC1: DEC SI
MOV [SI],BL

Page 52
LOC2: INC SI
DEC DL
JNZ LOC3
MOV [SI],AL
DEC CL
JNZ LOC4
INT 3

Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS

8000 MOV SI,9000 Move 9000 to SI

8003 MOV CL,[SI] Content of SI moved to CL register

8005 MOV SI,9000 Move 9000 to SI

8008 MOV DL,[SI] Content of SI moved to DL register

800A INC SI Increments SI by one

800C MOV AL,[SI] Content of SI moved to AL register

800E INC SI Increments SI by one

8010 MOV BL,[SI] Content of SI moved to BL register


8012 CMP AL,BL Compares contents of registers AL and BL

8014 JB LOC1 If below goes to loc1

8016 DEC SI Decrements SI by one

8018 MOV [SI],AL Content of AL moved to SI register

801A MOV AL,BL Content of BL moved to AL register

Page 53
801C JMP LOC2 Jumps to loc2

801E DEC SI Decrements SI by one

8020 MOV [SI],BL Content of BL moved to SI register

8022 INC SI Increments SI by one

8024 DEC DL Decrements DL by one

8026 JNZ LOC3 If not zero jumps to loc3

8028 MOV [SI],AL Content of AL moved to SI register

802A DEC CL Decrements CL by one

802C JNZ LOC4 If not zero jumps to loc4

802E INT 3 End of program

Output Table:
INPUT OUTPUT

MEMORY DATA MEMORY DATA


ADDRESS ADDRESS
9000 04 9000 04

9001 08 9001 09

9002 05 9002 08

9003 09 9003 05

9004 02 9004 02

Page 54
Result:
Thus the numbers are arranged in descending order using 8086 Microprocessor.

EX NO: ANALOG TO DIGITAL CONVERTOR INTERFACING


DATE:

Aim:

To interface analog to digital convertor IC with 8086 microprocessor using 8255

programmable IC.

Algorithm:

1. Ensure the analog input is applied to the ADC.

2. Initialise the 8255 IC as input-mode 0 operation and port A as input and port C upper to

sent write signal.

3. Give the start of conversion (SOC) signal.

4. Read the end of conversion signal.

5. Read the equivalent digital output in the AL register.

Program:

MOV DX,FF26

MOV AL,90

OUT DX,AL

MOV DX,FF24

MOV AL,FF

Page 55
OUT DX,AL

MOV AL,00

OUT DX,AL

MOV AL,FF

OUT DX,AL
CALL DELAY

MOV DX,FF20

IN AL,DX

INT 3

DELAY: MOV CX,FFFF

WAIT: NOP

NOP

DEC CX

JNZ WAIT

RET

Execution table:

Memory Label Mnemonics Comments


address
1000 MOV DX,FF26 Address of control word is loaded in DX register
1001
1002
1003 MOV AL,90

Page 56
1004 Initializing Port A as input and others as output ports
in 8255
1005 OUT DX,AL Out the AL contents to address location FF26 in
8255
1006 MOV DX,FF24 Address of Port C upper is loaded in DX register
1007
1008
1009 MOV AL,FF Load FF in AL register
100A
100B OUT DX,AL Out the AL contents to address location FF24 in
8255
100C MOV AL,00 Start of Conversion
100D
100E OUT DX,AL Out the AL contents to address location FF24 in
8255
100F MOV AL,FF Load FF in AL register
1011
1012 OUT DX,AL Out the AL contents to address location FF24 in
8255
1013 CALL DELAY Calling the DELAY function
1014
1015
1016 MOV DX,FF20 Address of Port A is loaded in DX register
1017
1018
1019 IN AL,DX Contents of Port A is loaded in AL register
101A INT 3 Halt the program
101B DELAY MOV CX,07FF Set CX register to 07FF
101C
101D
101E LABEL1 NOP Does nothing
101F NOP Does nothing
1020 DEC CX Decrement the CX-register
1021 JNZ LABEL1 If zero flag is reset ,jump to LABEL1
1022
1023 RET Return to main program

Output table:

Analog input (V) Digital output (AL register)

0 00

Page 57
1 2C
2.5 6E
4.8 D3

Result:
Thus the Assembly language program to interface analog to digital convertor IC with 8086

microprocessor using 8255 programmable IC is performed.

EX NO: ANALOG TO DIGITAL CONVERTOR INTERFACING


DATE:
Aim:

To interface digital to analog convertor IC with 8086 microprocessor using 8255

programmable IC

Algorithm:

1. Initialize the 8255 IC in input-mode 0 operation and all ports as output ports

2. Write a program to generate the analog output

3. View the equivalent analog output in the display devices like CRO etc

Program:

MOV DX,FF26
MOV AL,80
OUT DX,AL
LOOP: MOV AL,FF
OUT DX,AL
CALL DELAY
MOV AL,00
OUT DX,AL

Page 58
CALL DELAY
JMP LOOP
DELAY: MOV CX,07FF
WAIT: NOP
NOP
DEC CX
JNZ WAIT
RET

Execution table:

Memory Label Mnemonics Comments


address
1001 MOV Address of control word is loaded in DX register
DX,FF26
1002
1003 MOV AL,80 Initializing 8255 in input-mode 0 operation and all
ports as output ports
1004
1005 OUT DX,AL Out the AL contents to address location FF26 in
8255
1006 MOV Address of Port A is loaded in DX register
DX,FF22
1007
1008
1009 LOOP MOV AL,FF Load FF in AL register
100A
100B OUT DX,AL Out the AL contents to address location FF22 in
8255
100C CALL Calling DELAY function
DELAY
100D
100E

Page 59
100F MOV AL,00 Load 00 in AL register
1010
1011 OUT DX,AL Out the AL contents to address location FF22 in
8255
1012 CALL Calling DELAY function
DELAY
1013
1014
1015 JMP LOOP Unconditional jump to location LOOP
1016
1017 DELAY MOV Load 07FF in CX register
CX,07FF
1018
1019
101A BACK NOP No operation
101B NOP No operation
101C DEC CX Decrement the contents in CX register
101D JNZ BACK If zero flag is reset ,jump to location BACK
101E
101E RET Return to the main program

Page 60
Result:

Thus the Assembly language program to interface digital to analog convertor IC with

8086 Microprocessor using 8255 programmable IC is performed

EX NO: STEPPER MOTOR INTERFACING


DATE:
Aim:

To interface the stepper motor with 8086 microprocessor using 8255 programmable IC

Algorithm:

1. Initialize the 8255 IC as input-mode 0 operation and all port s as output ports

2. Load the port A address with data value and out it

3. Call the delay function and repeats the same procedure

4. Run the loop infinitely

5. View the stepper motor rotations and direction of rotation

Program:

MOV DX,FF26
MOV AL,80
OUT DX,AL
WAIT: MOV DX,FF20

Page 61
MOV AL,05
OUT DX,AL
CALL DELAY
MOV AL,07
OUT DX,AL
CALL DELAY
MOV AL,06
OUT DX,AL
CALL DELAY
MOV AL,04
OUT DX,AL
CALL DELAY
JMP WAIT
DELAY: MOV BX,0010
BACK: MOV AL,FF
BACK1: NOP
NOP
NOP
NOP
DEC AL
JNZ BACK1
DEC BX
JNZ BACK
RET
Execution table:

Memory
address Label Mnemonics Comments
1000 MOV Address of control word is loaded in DX register
1001 DX,FF26
1002
1003 MOV AL,80

Page 62
1004 Initializing 8255 in input-mode 0 operation and all
ports as output ports
1005 OUT DX,AL Out the AL contents to address location FF26 in
8255
1006 WAIT MOV Address of Port A is loaded in DX register
1007 DX,FF20
1008
1009 MOV AL,05 Load 05 in AL register
100A
100B OUT DX,AL Out the AL contents to address location FF20 in
8255
100C CALL Calling DELAY function
100D DELAY
100E
100F MOV AL,07 Load 07 in AL register
1010
1011 OUT DX,AL Out the AL contents to address location FF20 in
8255
1012 CALL Calling DELAY function
1013 DELAY
1014
1015 MOV AL,06 Load 06 in AL register
1016
1017 OUT DX,AL Out the AL contents to address location FF20 in
8255
1018 CALL Calling DELAY function
1019 DELAY
101A
101B MOV AL,04 Load 04 in AL register
101C
101D OUT DX,AL Out the AL contents to address location FF20 in
8255
101E CALL Calling DELAY function
101F DELAY
1020
1021 JMP WAIT Unconditional jump to location WAIT
1022
1023 DELAY MOV Load 0010 in BX register
1024 BX,0010
1025
1026 BACK1 MOV AL,FF Load FF in AL register
1027
1028 BACK2 NOP Does nothing
1029 NOP Does nothing
102A NOP Does nothing

Page 63
102B NOP Does nothing
102C DEC AL Decrement the contents in AL register
102D JNZ BACK2 If zero flag is reset ,jump to BACK2
102E
102F
1030 DEC BX Decrement the contents in BX register
1031 JNZ BACK1 If zero flag is reset ,jump to BACK1
1032
1033 RET Return to main program

Result:

Thus the Assembly language program to interface the stepper motor with 8086

microprocessor using 8255 programmable IC is performed.

EX NO: KEYBOARD AND DISPLAY INTERFACING


DATE:

Aim:
To interface keyboard and display with 8086 microprocessor using 8279

keyboard/display controller

Algorithm:

1. Initialise the 8279 IC in 8-bit character Right entry-encoded scan,N-key roll over (input)

mode

2. Get the scanned key position into the AL-register

3. View the scanned key-code in AL-register

Program:

Page 64
MOV AL,12
MOV DX,FF52
OUT DX,AL
MOV AL,3E
OUT DX,AL
MOV AL,A0
OUT DX,AL
WAIT : IN AL,DX
AND AL,07
JZ WAIT
MOV DX,FF50
IN AL,DX
AND AL,3F
INT 3
Execution table:

MEMORY
LABEL MNEMONICS COMENTS
ADDRESS
1000
MOV AL,12 Eight 8-bit character right entry mode
1001
1002
Address of control word is loaded in DX
1003 MOV DX,FF52
register
1004
Out the AL contents to status register in
1005 OUT DX,AL
8279
1006
MOV AL,3E For frequency division
1007
Out the AL contents to status register in
1008 OUT DX,AL
8279
1009
MOV AL,A0 encoded scan, N-key roll over mode
100A
Out the AL contents to status register in
100B OUT DX,AL
8279
Get the status register contents in AL
100C WAIT IN AL,DX
register
100D Logical AND of 07 with contents of AL
AND AL,07
100E register

Page 65
100F
JZ WAIT If zero flag is set ,jump to location WAIT
1010
1011
Initialising DX register with data register
1012 MOV DX,FF50
address
1013
Get the data register contents in AL
1014 IN AL,DX
register
1015 Logical AND of 3F with contents of AL
AND AL,3F
1016 register
1017 INT 3 Halt the program

Hex Codes of Keys:

21 22 23 24
19 1A 1B 1C
11 12 13 14
09 0A 0B 0C

Page 66
Result:

Thus the Assembly language program to interface keyboard and display with 8086

microprocessor using 8279 keyboard/display controller is performed.

Page 67
EX NO: ADDITION AND SUBTRACTION USING 8051
DATE: MICROCONTROLLER
Aim:

To perform addition and subtraction of two numbers using 8051 microcontroller

Algorithm:

1. Load the values in the corresponding registers.

2. Using the appropriate commands perform the operations.

3. Store the results of the operation.

4. Execute the program.

Program:

MOV DPTR, #8600


MOVX A,@DPTR
MOV R0, A
INC DPTR
MOVX A,@DPTR
MOV R1, A
ADD A, R0
INC DPTR
MOVX @DPTR, A
MOV A, R1
INC DPTR
SUBB A, R0
MOVX @DPTR, A
LCALL 00BB

Page 68
Execution table:

Label Mnemonics Comments


MOV DPTR, #8600 Move immediate value 8600 in dptr
MOVX A, @DPTR Loads the content of memory stored in
dptr
MOV R0, A Copies value of A to R0
INC DPTR Increments the value of dptr
MOVX A, @DPTR Loads the content of memory stored in
dptr
MOV R1, A Copies value of A to R1
ADD A, R0 Adds the content of A with R0 and
stores the result in A
INC DPTR Increments dptr
MOVX @DPTR, A Moves the content of A to the memory
address in dptr
MOV A, R1 Copies the content of R1 to A
INC DPTR Increments dptr
SUBB A, R0 Subtracts the value of A from R0
MOVX @DPTR,A Moves the content of A to the memory
address in dptr
LCALL 00BB Halts the program

Output:

Memory address Values


8600 20
8601 10
8602 30
8604 10

Page 69
Result:

Thus the program to perform addition and subtraction using 8051 is verified.

EX NO: LARGEST NUMBER IN AN ARRAY


DATE:
Aim:

To find the largest number in an array using 8051 microcontroller.

Algorithm:

1. Load the values in the memory locations.

2. Compare the values with each other and load the larger value in the accumulator.

3. Do the comparison for all the values.

4. Finally move the result to R0.

5. Execute the program.

Program:

MOV DPTR, #98


MOV R2, #05
MOVX A, @DPTR
MOV R0, A
DEC R2
LOC2: INC DPTR
MOVX A, @DPTR
MOV 00, R0
CJNE A, 00, LOC1

Page 70
LOC1: JC LOC3
MOV R0, A
LOC3: DJNZ R2, LOC2
LCALL 00BB

Execution table:

Label Mnemonics Comments


MOV DPTR, #98 Moves immediate value 98 to dptr
MOV R2, #05 Moves immediate value 05 to R2
MOVX A, @DPTR Loads the content of memory stored in dptr to
A
MOV R0, A Copies A to R0
DEC R2 Decrements R2 by 1
LOC 2 INC DPTR Increments dptr
MOVX A, @DPTR Loads the content of memory stored in dptr to
A
MOV 00, R0 Copies R0 to internal memory 00
CJNE A, 00, LOC1 Compares A with 00 and if the result is not
zero it jumps to LOC 1
LOC 1 JC LOC 3 If it results in carry then jump to LOC 3
MOV R0, A Moves A to R0
LOC 3 DJNZ R2, LOC2
LCALL OOBB Halts the program

Output table:

Memory location Data value


9800 59
9801 09
9802 87
9803 03
9804 0A

Page 71
Register R0:87

Result:

Thus, largest number in the array is calculated using 8051 microcontroller.

EX NO: FIBONACCI SERIES USING 8051


DATE:
Aim:

To generate the Fibonacci series for N terms using 8051 microcontroller.

Algorithm:

1. Get the number of terms in Accumulator.

2. Store the first and second number in consequent memory locations.

3. Add the two numbers and store it in next location .

4. Decrease the content of accumulator by 1.

5. Add the last and previous number and store it in next location.

6. Decrease the accumulator content by 1.

7. Continue the steps till the accumulator content reaches 0.

8. End the program.

Program:

MOV DPTR, #8000

Page 72
MOV X A, @DPTR
MOV R0, A
INC DPTR
MOV R1, #00
MOV A, R1
MOVX @DPTR, A
INC DPTR
MOV R2, #01
MOV A, R2
MOVX @DPTR, A

REPEAT: INC DPTR;


MOV A, R2
ADD A, R1
MOV R3, A
MOVX @DPTR, A
MOV A, R2
MOV R1, A
MOV A, R3
MOV R2, A
DJNZ R0, REPEAT
LCALL 00BB
Execution table:

Label Mnemonics Comments


MOV DPTR, #8800 Moves immediate value 8800 to dptr
MOVX A,@DPTR Moves the content of the memory
location in dptr to A
MOV R0, A Copies A to R0
INC DPTR Increments dptr

Page 73
MOV R1, #00 Loads 00 in R1
MOV A, R1 Moves R1 to A
MOVX @DPTR, A Moves value in A to memory location in
dptr
INC DPTR Increments dptr
MOV R2, #01 Loads 01 in R2
MOV A, R2 Copies R2 to A
MOVX @DPTR, A Moves value in A to memory location in
dptr
REPEAT INC DPTR Increments dptr
MOV A, R2 Copies R2 to A
ADD A, R1 Adds A with R1
MOV R3, A Moves A to R3
MOVX @DPTR, A Moves value in A to memory location in
dptr
MOV A, R2 Moves R2 to A
MOV R1, A Moves A to R1
MOV A, R3 Moves R3 to A
MOV R2, A Moves A to R2
DJNZ R0, REPEAT Control is transferred to REPEAT
LCALL OOBB Halts the program

Output table:

Memory location Data value


8800 0A
8801 00
8802 01
8803 01
8804 02

Page 74
8805 03
8806 05
8807 08
8808 0D
8809 15
880A 22
880B 37

Result:
Thus, Fibonacci series is computed using 8051 microcontroller.

Page 75
Page 76
Page 77

You might also like