Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views106 pages

MPMC Lab Manual

The document is a laboratory record for experiments conducted in the Department of Electrical and Electronics Engineering at Jai Shriram Engineering College. It includes detailed procedures for performing arithmetic operations (addition, subtraction, multiplication, division) on 8-bit and 16-bit numbers using the Microprocessor 8085, along with algorithms, flowcharts, and assembly language programs. Each experiment outlines objectives, algorithms, and results, serving as a practical guide for students preparing for university examinations.

Uploaded by

reloadid20
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)
7 views106 pages

MPMC Lab Manual

The document is a laboratory record for experiments conducted in the Department of Electrical and Electronics Engineering at Jai Shriram Engineering College. It includes detailed procedures for performing arithmetic operations (addition, subtraction, multiplication, division) on 8-bit and 16-bit numbers using the Microprocessor 8085, along with algorithms, flowcharts, and assembly language programs. Each experiment outlines objectives, algorithms, and results, serving as a practical guide for students preparing for university examinations.

Uploaded by

reloadid20
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
You are on page 1/ 106

JAI SHRIRAM ENGINEERING COLLEGE

DHARAPURAM ROAD,AVINASHIPALAYAM,TIRUPPUR – 638 660


Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai
Recognized by UGC & Accredited by NAAC and NBA (CSE and ECE)

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

LABORATORY RECORD

Certificate that this a bonafide record of work done by

Name :…………………………………………………………………

Register Number :…………………………………………………………………

Branch & Semester :………………………………………………………………….

Course Code :………………………………………………………………….

Course Name :………………………………………………………………….

Course In-charge Head of the Department

Place:

Date :

Submitted for the University Practical Examination Held on………………………………

Internal Examination External Examination


CONTENTS
S.No Date Experiment Name Page No Marks Sign
EX:NO: 8 BIT ADDITION

DATE:

AIM:

To add two 8 bit numbers stored at consecutive memory locations.

OBJECTIVE:

1. Addition of two 8 bit numbers stored in memory


2. To familiarize Instructions of Microprocessor 8085
3. Addressing mode of Microprocessor 8085.
4. Flag register of Microprocessor 8085

ALGORITHM:

1. Initialize memory pointer to data location.


2. Get the first number from memory in accumulator.
3. Get the second number and add it to the accumulator.
4. Store the answer at another memory location.

.
FLOW CHART:

START

[C] 00H

[HL] 4500H

[A] [M]

[HL] [HL]+1

[A] [A]+[M]

NO

Is there a
Carry ? YES

YES
[C] [C]+1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START MVI C, 00 Clear C reg.
4101
4102 LXI H, 4500 Initialize HL reg. to
4103 4500
4104
4105 MOV A, M Transfer first data to
accumulator
4106 INX H Increment HL reg. to
point next memory
Location.
4107 ADD M Add first number to
acc. Content.
4108 JNC L1 Jump to location if
4109 result does not yield
410A carry.
410B INR C Increment C reg.
410C L1 INX H Increment HL reg. to
point next memory
Location.
410D MOV M, A Transfer the result from
acc. to memory.
410E INX H Increment HL reg. to
point next memory
Location.
410F MOV M, C Move carry to memory
4110 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
4500 4502
4501 4503

RESULT:

Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.
EX:NO: 8 BIT SUBTRACTION

DATE:

AIM:

To subtract two 8 bit numbers stored at consecutive memory locations.

OBJECTIVE:

1. Subtraction of two 8 bit numbers stored in memory


2. To familiarize Instructions of Microprocessor 8085
3. Addressing mode of Microprocessor 8085.
4. Flag register of Microprocessor 8085
.

ALGORITHM:

1. Initialize memory pointer to data location.


2. Get the first number from memory in accumulator.
3. Get the second number and subtract from the accumulator.
4. If the result yields a borrow, the content of the acc. is complemented and 01H is added to it (2‟s
complement). A register is cleared and the content of that reg. is incremented in case there is a
borrow. If there is no borrow the content of the acc. is directly taken as the result.
5. Store the answer at next memory location.
FLOW CHART:
START

[C] 00H

[HL] 4500H

[A] [M]

[HL] [HL]+1

[A] [A]-[M]

Is there a NO
Borrow ?

YES
Complement [A]
Add 01H to [A]

[C] [C]+1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START MVI C, 00 Clear C reg.
4102
4102 LXI H, 4500 Initialize HL reg. to
4103 4500
4104
4105 MOV A, M Transfer first data to
accumulator
4106 INX H Increment HL reg. to
point next mem.
Location.
4107 SUB M Subtract first number
from acc. Content.
4108 JNC L1 Jump to location if
4109 result does not yield
410A borrow.
410B INR C Increment C reg.
410C CMA Complement the Acc.
content
410D ADI 01H Add 01H to content of
410E acc.
410F L1 INX H Increment HL reg. to
point next mem.
Location.
4110 MOV M, A Transfer the result from
acc. to memory.
4111 INX H Increment HL reg. to
point next mem.
Location.
4112 MOV M, C Move carry to mem.
4113 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
4500 4502
4501 4503

RESULT:

Thus the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored at 4502 & 4503.
EX:NO: 8 BIT MULTIPLICATION

DATE:

AIM:

To multiply two 8 bit numbers stored at consecutive memory locations and store the result in
memory.

OBJECTIVE:

1. To get the 8-bit values from an address to specified internal registers by means of Data
Transfer Instructions.
2. To perform multiplication operation of two 8-bit numbers by means of repeated
Addition technique and by using jump instructions.
3. To familiarize Instructions of Microprocessor 8085
4. Addressing mode of Microprocessor 8085.
5. Flag register of Microprocessor 8085

ALGORITHM:

LOGIC: Multiplication can be done by repeated addition.

1. Initialize memory pointer to data location.


2. Move multiplicand to a register.
3. Move the multiplier to another register.
4. Clear the accumulator.
5. Add multiplicand to accumulator
6. Decrement multiplier
7. Repeat step 5 till multiplier comes to zero.
8. The result, which is in the accumulator, is stored in a memory location.
FLOW CHART:

START

[HL] 4500

B M

[HL]  [HL]+1

A  00

C  00

[A]  [A] +[M]

Is there NO
any carry

YES
C  C+1

B  B-1

NO
IS B=0

YES

A
A

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START LXI H, 4500 Initialize HL reg. to 4500
4103 MOV B, M Transfer first data to reg. B
4104 INX H Increment HL reg. to point next
mem. Location.
4105 MVI A, 00H Clear the acc.
4107 MVI C, 00H Clear C reg for carry
4109 L1 ADD M Add multiplicand multiplier times.
410A JNC NEXT Jump to NEXT if there is no carry
410D INR C Increment C reg
410E NEXT DCR B Decrement B reg
410F JNZ L1 Jump to L1 if B is not zero.
4112 INX H Increment HL reg. to point next
mem. Location.
4113 MOV M, A Transfer the result from acc. to
memory.
4114 INX H Increment HL reg. to point next
mem. Location.
4115 MOV M, C Transfer the result from C reg. to
memory.
4116 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
4500 4502
4501 4503

RESULT:

Thus the 8-bit multiplication was done in 8085p using repeated addition method.
EX:NO: 8 BIT DIVISION

DATE:

AIM:

To divide two 8-bit numbers and store the result in memory.

OBJECTIVE:

1. To get the 8-bit values from an address to specified internal registers by means of Data
Transfer Instructions.
2. To perform division operation of two 8-bit numbers by means of repeated
Subtraction technique and by using jump instructions.
3. To familiarize Instructions of Microprocessor 8085
4. Addressing mode of Microprocessor 8085.
5. Flag register of Microprocessor 8085

ALGORITHM:

LOGIC: Division is done using the method Repeated subtraction.


1. Load Divisor and Dividend
2. Subtract divisor from dividend
3. Count the number of times of subtraction which equals the quotient
4. Stop subtraction when the dividend is less than the divisor .The dividend now becomes the
remainder. Otherwise go to step 2.
5. Stop the program execution.
FLOWCHART:
START

B  00

[HL] 4500

A M

[HL]  [HL]+1

M  A-M

[B]  [B] +1

NO
IS A<0
YES
A  A+ M

B  B-1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [B]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 MVI B,00 Clear B reg for quotient
4101
4102 LXI H,4500 Initialize HL reg. to
4103 4500H
4104
4105 MOV A,M Transfer dividend to acc.
4106 INX H Increment HL reg. to point
next mem. Location.
4107 LOOP SUB M Subtract divisor from dividend
4108 INR B Increment B reg
4109 JNC LOOP Jump to LOOP if result does
410A not yield borrow
410B
410C ADD M Add divisor to acc.
410D DCR B Decrement B reg
410E INX H Increment HL reg. to point
next mem. Location.
410F MOV M,A Transfer the remainder from
acc. to memory.
4110 INX H Increment HL reg. to point
next mem. Location.
4111 MOV M,B Transfer the quotient from B
reg. to memory.
4112 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4500 4502
4501 4503
4500 4502
4501 4503

RESULT:

Thus an ALP was written for 8-bit division using repeated subtraction method and executed using
8085 p kits
EX:NO:
16 BIT ADDITION
DATE:

AIM:

To add two 16-bit numbers stored at consecutive memory locations.

OBJECTIVE:

1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform addition operation of two 16-bit numbers .
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.

ALGORITHM:

1. Initialize memory pointer to data location.


2. Get the first number from memory and store in Register pair.
3. Get the second number in memory and add it to the Register pair.
4. Store the sum & carry in separate memory locations.
FLOW CHART:
START

[L] [4150 H]
[H] [4151 H]

[DE] [HL]

[L] [4152H]
[H] [4153H]

[A] 00H

[HL] [HL]+[DE]

NO
Is there a
Carry?

YES
[A] [A]+1

[4154] [ L]

[4155] [H]

[4156] [A]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START LHLD 4150H Load the augend in DE
4101 pair through HL pair.
4102
4103 XCHG
4104 LHLD 4152H Load the addend in HL
4105 pair.
4106
4107 MVI A, 00H Initialize reg. A for
4108 carry
4109 DAD D Add the contents of HL
Pair with that of DE
pair.
410A JNC LOOP If there is no carry, go
410B to the instruction
410C labeled LOOP.
410D INR A Otherwise increment
reg. A
410E LOOP SHLD 4154H Store the content of HL
410F Pair in 4154H(LSB of
4110 sum)
4111 STA 4156H Store the carry in
4112 4156H through Acc.
4113 (MSB of sum).
4114 HLT Stop the program.

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150H 4154H
4151H 4155H
4152H 4156H
4153H

RESULT:

Thus an ALP program for 16-bit addition was written and executed in 8085p using special
instructions.
EX:NO:
16 BIT SUBTRACTION
DATE:

AIM:

To subtract two 16-bit numbers stored at consecutive memory locations.

OBJECTIVE:

1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform subtraction of two 16-bit numbers.
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.

ALGORITHM:

1. Initialize memory pointer to data location.


2. Get the subtrahend from memory and transfer it to register pair.
3. Get the minuend from memory and store it in another register pair.
4. Subtract subtrahend from minuend.
5. Store the difference and borrow in different memory locations.
FLOW CHART:

START

[L] [4150 H]
[H] [4151 H]

[DE] [HL]

[L] [4152H]
[H] [4153H]

[HL] [HL]-[DE]

Is there a NO
borrow?

YES
[C] [C]+1

[4154] [ L]

[4155] [H]

[4156] [C]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 START MVI C, 00 Initialize C reg.
4102 LHLD 4150H Load the subtrahend in DE reg.
4105 XCHG Pair through HL reg. pair.
4106 LHLD 4152H Load the minuend in HL reg.
Pair.
4109 MOV A, L Move the content of reg. L to
Acc.
410A SUB E Subtract the content of reg. E
from that of acc.
410B MOV L, A Move the content of Acc. to
reg. L
4100C MOV A, H Move the content of reg. H to
Acc.
410D SBB D Subtract content of reg. D with
that of Acc.
410E MOV H, A Transfer content of acc. to reg.
H
410F SHLD 4154H Store the content of HL pair in
memory location 4154H.
4112 JNC NEXT If there is borrow, go to the
instruction labeled NEXT.
4115 INR C Increment reg. C
4116 NEXT MOV A, C Transfer the content of reg. C
to Acc.
4117 STA 4156H Store the content of acc. to the
memory location 4156H
411A HLT Stop the program execution.

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150H 4154H
4151H 4155H
4152H 4156H
4153H

RESULT:

Thus an ALP program for subtracting two 16-bit numbers was written and executed.
EX:NO:
16 BIT MULTIPLICATION
DATE:

AIM:

To multiply two 16 bit numbers and store the result in memory.

OBJECTIVE:

1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform multiplication of two 16-bit numbers using repeated addition method.
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.

ALGORITHM:

1. Get the multiplier and multiplicand.


2. Initialize a register to store partial product.
3. Add multiplicand, multiplier times.
4. Store the result in consecutive memory locations.
FLOWCHART:

START

L [4150]
H [4151]

SP HL

L [4152]
H [4153]

DE HL

HL 0000
BC 0000

HL HL+SP

NO
Is Carry
flag set?

YES

BC BC+1

DE DE+1

NO
Is Zero flag
set?
YES

A
A

[4154] L
[4155] H

[4156] C
[4157] B

STOP
PROGRAM:
ADDRESS LABEL MNEMONICS OPERAND COMMENTS
4100 START LHLD 4150 Load the first No. in stack pointer
4103 SPHL through HL reg. pair
4104 LHLD 4152 Load the 2ndin HL reg. pair
4107 XCHG &Exchange with DE reg. pair.
4108 LXI H, 0000H Clear HL & DE reg. pairs.
410B LXI B, 0000H
410E LOOP DAD SP Add SP with HL pair.
JNC NEXT If there is no carry, go to the
410F
instruction labeled NEXT
4112 INX B Increment BC reg. pair
4113 NEXT DCX D Decrement DE reg. pair.
4114 MOV A,E Move the content of reg. E to Acc.
4115 ORA D OR Acc. with D reg.
JNZ LOOP If there is no zero, go to
4116
instruction labeled LOOP
4119 SHLD 4154 Store the content of HL pair in
411A memory locations 4154 & 4155.
411C MOV A, C Move the content of reg. C to Acc.
STA 4156 Store the content of Acc. in
411D
memory location 4156.
4120 MOV A, B Move the content of reg. B to Acc.
STA 4157 Store the content of Acc. in
4121
memory location 4157.
4124 HLT Stop program execution

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4154
4151 4155
4152 4156
4153 4157

RESULT:

Thus the 16-bit multiplication was done in 8085p using repeated addition method.
EX:NO:
16- BIT DIVISION
DATE:

AIM:

To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.

OBJECTIVE:

1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.

2. To use two pairs of internal 8-bit registers to save a 16-bit registers.


3. To perform subtraction of two 16-bit numbers using repeated subtraction method.
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.

ALGORITHM:

1. Get the dividend and divisor.


2. Initialize the register for quotient.
3. Repeatedly subtract divisor from dividend till dividend becomes less than divisor.
4. Count the number of subtraction which equals the quotient.
5. Store the result in memory.
FLOWCHART:

START

L [4151]
H [4152]

HL DE

L [4150]
H [4151]

BC 0000H

A L; A A- E
L A

A H
A A- H- Borrow
H A

BC BC+ 1

Is Carry NO
flag set ?

YES

A
A

BC BC- 1
HL HL+DE

L [4154]
H [4155]

A C

[4156] A

A B

[4157] A

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 START LHLD 4152 Load the first No. in stack pointer
4103 XCHG through HL reg. pair
4104 LHLD 4150 Load the second No. in HL reg. pair
& Exchange with DE reg. pair.
4107 LXI B, 0000H Clear BC reg. pair.
4108 Loop Address
4109
410A LOOP MOV A, L Move the content of reg. L to Acc.
410B SUB E Subtract reg. E from that of Acc.
410C MOV L, A Move the content of Acc to L.
410D MOV A, H Move the content of reg. H Acc.
410E SBB D Subtract reg. D from that of Acc.
410F MOV H, A Move the content of Acc to H.
4110 INX B Increment reg. Pair BC
4111 JNC LOOP If there is no carry, go to the location
labeled LOOP.
4112 Loop Address
4113
4114 DCX B Decrement BC reg. pair.
4115 DAD D Add content of HL and DE reg. pairs.
4116 SHLD 4154 Store the content of HL pair in 4154 &
4155.
4119 MOV A, C Move the content of reg. C to Acc.
411A STA 4156 Store the content of Acc. in memory
4156
411D MOV A, B Move the content of reg. B to Acc.
411E STA 4157 Store the content of Acc. in memory
4157.
4121 HLT Stop the program execution.

OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4154
4151 4155
4152 4156
4153 4157

RESULT:

Thus the 16-bit Division was done in 8085p using repeated subtraction method.
EX:NO:
LARGEST ELEMENT IN AN ARRAY

DATE:

AIM:
To find the largest element in an array.

OBJECTIVE:

1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the largest number is moved to Accumulator.
3. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
4. To familiarize Instructions of Microprocessor 8085
5. Addressing mode of Microprocessor 8085.

ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.
2. Fetch the first element from the memory location and load it in the accumulator.
3. Initialize a counter (register) with the total number of elements in an array.
4. Decrement the counter by 1.
5. Increment the memory pointer to point to the next element.
6. Compare the accumulator content with the memory content (next element).
7. If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
FLOW CHART:
START

[HL]  [4150H]

[B]  04H

[A]  [HL]

[HL  [HL] + 1

NO IS
[A] < [HL]?

YES

[A] [HL]

[B]  [B]-1

IS NO
[B] = 0?

YES

[4155]  [A]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 LXI H,4150 Initialize HL reg. to
4101 4150H
4102
4103 MVI B,04 Initialize B reg with no. of
4104 comparisons(n-1)
4105 MOV A,M Transfer first data to acc.
4106 LOOP1 INX H Increment HL reg. to point
next memory location
4107 CMP M Compare M & A
4108 JNC LOOP If A is greater than M then
410A go to loop
410B
410C MOV A,M Transfer data from M to A
reg
410D LOOP DCR B Decrement B reg
410E JNZ LOOP1 If B is not Zero go to loop1
410F
4110
4111 STA 4155 Store the result in a
4112 memory location.
4113
4114 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4155
4151
4152
4153
4154

RESULT:
Thus the largest number in the given array is found out.
EX:NO:
SMALLEST ELEMENT IN AN ARRAY
DATE:

AIM:
To find the smallest element in an array.

OBJECTIVE:
1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
4. To familiarize Instructions of Microprocessor 8085
5. Addressing mode of Microprocessor 8085.

ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.
2. Fetch the first element from the memory location and load it in the accumulator.
3. Initialize a counter (register) with the total number of elements in an array.
4. Decrement the counter by 1.
5. Increment the memory pointer to point to the next element.
6. Compare the accumulator content with the memory content (next element).
7. If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
FLOW CHART:
START

[HL]  [4150H]

[B]  04H

[A]  [HL]

[HL  [HL] + 1

YES IS
[A] < [HL]?

NO

[A] [HL]

[B]  [B]-1

IS NO
[B] = 0?

YES

[4105]  [A]

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 LXI H,4100 Initialize HL reg.
4101 to
4102 4100H
4103 MVI B,04 Initialize B reg
4104 with no. of
comparisons(n-1)
4105 MOV A,M Transfer first data
to acc.
4106 LOOP1 INX H Increment HL
reg. to point next
memory location
4107 CMP M Compare M & A
4108 JC LOOP If A is lesser than
410A M then go to loop
410B
410C MOV A,M Transfer data
from M to A reg
410D LOOP DCR B Decrement B reg
410E JNZ LOOP1 If B is not Zero
410F go to loop1
4110
4111 STA 4105 Store the result in
4112 a memory
4113 location.
4114 HLT Stop the program

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4105
4151
4152
4153
4154

RESULT:
Thus the smallest number in the given array is found out.
EX:NO:
ASCENDING ORDER
DATE:

AIM:
To sort the given number in the ascending order using 8085 microprocessor.

OBJECTIVE:

1. To get the 8-bit data one by one and it will be saved in the specified registers like
an array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To use the conditional jump instruction and compare instructions the 8-bit data‟s
are arranged internally in the ascending order.
4. To store the instruction from a register to specified address in a memory unit by
Data Transfer Instructions.

ALGORITHM:

1. Get the numbers to be sorted from the memory locations.


2. Compare the first two numbers and if the first number is larger than second then
change the number.
3. If the first number is smaller, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
FLOWCHART:
START

[B]  04H

[HL]  [4150H]

[C]  04H

[A]  [HL]

[HL  [HL] + 1

YES IS
[A] < [HL]?

NO

[D] [HL]

[HL]  [A]

[HL]  [HL] - 1

[HL]  [D]

[HL]  [HL] + 1

[C]  [C] – 01 H

A
A

IS NO
[C] = 0?

YES
[B]  [B]-1

IS NO
[B] = 0?

YES

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS

4100 MVI B,04 Initialize B reg


4101 with number of
comparisons (n-
1)
4102 LOOP 3 LXI H,4150 Initialize HL reg.
4103 to
4104 4150H
4105 MVI C,04 Initialize C reg
4106 with no. of
comparisons(n-1)
4107 LOOP2 MOV A,M Transfer first data
to acc.
4108 INX H Increment HL
reg. to point next
memory location
4109 CMP M Compare M & A
410A JC LOOP1 If A is less than
410B M then go to
410C loop1
410D MOV D,M Transfer data
from M to D reg
410E MOV M,A Transfer data
from acc
to M
410F DCX H Decrement HL
pair
4110 MOV M,D Transfer data
from D to M
4111 INX H Increment HL
pair
4112 LOOP1 DCR C Decrement C reg
4113 JNZ LOOP2 If C is not zero go
4114 to loop2
4115
4116 DCR B Decrement B reg
4117 JNZ LOOP3 If B is not Zero
4118 go to loop3
4119
411A HLT Stop the program
OBSERVATION:

INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4150 4150
4151 4151
4152 4152
4153 4153
4154 4154

RESULT:

Thus the ascending order program is executed and thus the numbers are arranged in ascending
order.
EX:NO:
DESCENDING ORDER
DATE:

AIM:
To sort the given number in the descending order using 8085 microprocessor.

OBJECTIVE:

1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To use the conditional jump instruction and compare instructions the 8-bit data‟s are
Arranged internally in the descending order.
4. To store the instruction from a register to specified address in a memory unit by
Data

ALGORITHM:

1. Get the numbers to be sorted from the memory locations.


2. Compare the first two numbers and if the first number is smaller than second then I
interchange the number.
3. If the first number is larger, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
FLOWCHART:
START

[B]  04H

[HL]  [4150H]

[C]  04H

[A]  [HL]

[HL  [HL] + 1

NO IS
[A] < [HL]?

YES

[D] [HL]

[HL]  [A]

[HL]  [HL] - 1

[HL]  [D]

[HL]  [HL] + 1

[C]  [C] – 01 H

A
A

NO

IS
[C] = 0?
YES

[B]  [B]-1

NO
IS
[B] = 0?

YES

STOP
YES
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 MVI B,04 Initialize B reg with
number of comparisons
(n-1)
4102 LOOP 3 LXI H,4150 Initialize HL reg. to
4103 4150H
4104
4105 MVI C,04 Initialize C reg with no.
4106 of comparisons(n-1)
4107 LOOP2 MOV A,M Transfer first data to acc.
4108 INX H Increment HL reg. to
point next memory
location
4109 CMP M Compare M & A
410A JNC LOOP1 If A is greater than M
410B then go to loop1
410C
410D MOV D,M Transfer data from M to
D reg
410E MOV M,A Transfer data from acc to
M
410F DCX H Decrement HL pair
4110 MOV M,D Transfer data from D to
M
4111 INX H Increment HL pair
4112 LOOP1 DCR C Decrement C reg
4113 JNZ LOOP2 If C is not zero go to
4114 loop2
4115
4116 DCR B Decrement B reg
4117 JNZ LOOP3 If B is not Zero go to
4118 loop3
4119
411A HLT Stop the program
OBSERVATION:

INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4150 4150
4151 4151
4152 4152
4153 4153
4154 4154

RESULT:

Thus the descending order program is executed and thus the numbers are arranged in descending
order.
EX:NO:
BIT MANIPULATION
DATE:

AIM:

To perform bit manipulation using 8085.

OBJECTIVE:
1. Students will able to understand the usage of bit manipulation instruction like rotate
right with or without carry and rotate left with or without carry.

ALGORITHM:

1. Start the program


2. Load the input to the accumulator.
3. Mask off the bits.
4. Store the result in memory location.
5. Stop the program

PROGRAM:

ADDRESS MNEMONICS OPERAND COMMENT


4100 LDA 4150 Load the data
4101 ANI 0F Perform AND
operation
4104 RLC Rotate left
4105 RLC
4106 RLC
4107 RLC
4108 STA 4151 Store the result
410A HLD

RESULT:
Thus the ALP was written to perform bit manipulation and executed successfully.
EX:NO:
CODE CONVERSION –ASCII TO DECIMAL
DATE:

AIM:

To convert the ASCII number in memory to its equivalent decimal number.

THEORY:

Any ASCII number can be converted to decimal number by subtracting 30 from it.

OBJECTIVE:
1. Students will able to write the assembly language program for code conversion from ASCII code to
Decimal.

ALGORITHM:

1. Start.
2. Enter the data at 4150.
3. Subtract the data from 30H.
4. If the decimal number is valid, store the result at 4151 or if the decimal number is not valid, store
FF at 4151.
5. Halt.
FLOWCHART:

START

GET DATA

DATA = DATA - 30

NO YES YES
IS
DATA >
09 H?

RESULT = FF H RESULT = DATA

STOP
PROGRAM:

ADDRESS LABELS MNEMONICS OPERAND COMMENTS


4100 LXI H,4150 Point to data
4103 MOV A,M Get operand
4104 SUI 30 Convert to
decimal
4106 CPI 0A Check whether
it is a valid
decimal number
4108 JC LOOP Yes, store the
result
410B MVI A,FF No, make result
= FF
410D LOOP INX H
410E MOV M,A (A) => (4151)
410F HLT

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4151

RESULT:

Thus the ALP was written to convert ASCII number to Decimal number and executed successfully.
EX:NO:
BCD TO HEX CONVERSION

DATE:

6.(b)

AIM:

To convert the BCD numbers in memory to the equivalent hex number.

OBJECTIVE:
1. Students will able to write the assembly language program for code conversion from BCD to HEX
conversion.

ALGORITHM:

1. Start.
2. Enter the data at 4150 and 4151 for execution.
3. Execute the program and check for result at 4152.
4. Stop.
FLOWCHART:

START

GET MOST
SIGNIFICANT DIGIT
(MSD)

MSD = MSD * 10

HEX DATA = MSD + LSD

STORE HEX DATA

STOP
PROGRAM:

ADDRESS MNEMONICS OPERAND COMMENTS

4100 LXI H,4150 Initialize memory pointer to 4150H


4103 MOV A,M (A) = (4150) – (MSD)
4104 ADD A MSD * 2
4105 MOV B,A Save MSD * 2
4106 ADD A MSD * 4
4107 ADD A MSD * 8
4108 ADD B MSD * 10
4109 INX H Point to LSD
410A ADD M Add to form Hex equivalent
410B INX H (A) => (4152)
410C MOV M,A
410D HLT

OBSERVATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4152
4151

RESULT:

Thus the ALP was written to convert BCD to Hex number and executed successfully.
EX:NO:
HEX TO DECIMAL CONVERSION
DATE:

AIM:

To convert the hex number in memory to its equivalent decimal number.

OBJECTIVE:

The hex number should be converted to its equivalent decimal number using the following logic:
First count the number of hundreds, the number of tens and units present in that hex number. Using these
three, add up to get the equivalent decimal number.

ALGORITHM:
1. Start.
2. Enter data at 4150 for execution.
3. Execute the program and check for the result.
4. Stop.
FLOW CHART:
START

GET DATA
HUNDREDS = 0
TENS = 0

DATA = DATA - 100

IS NO HUNDREDS =
CARRY HUNDREDS + 1
=1?
YES

DATA = DATA + 100

DATA = DATA - 10

NO
IS TENS = TENS + 1
CARRY
=1?

YES
DATA = DATA - 10

UNITS = DATA

STORE HUNDREDS,
TENS, UNITS

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 LXI H, 4150 Point to data
4103 LXI B, 0000 Initialize hundreds = 0, Tens = 0.
4106 MOV A, M Get hex data to A.
4107 LOOP SUI 64
4109 JC LOOP1
410C INR B Hundreds = Hundreds + 1
410D JMP LOOP
4110 LOOP1 ADI 64 If subtracted extra, add it clear carry
Fag.
4112 LOOP2 SUI 0A
4114 JC LOOP3
4117 INR C Tens = Tens + 1
4118 JMP LOOP2
411B LOOP3 ADI 0A If subtracted extra add it again
411D INX H A = units
411E MOV M, B Store hundreds
411F MOV B, A Combine Tens in C and units In A to
4120 MOV A, C form a single 8-bit number.
4121 RLC
4122 RLC
4123 RLC
4124 RLC
4125 ADD B
4126 INX H
4127 MOV M, A Store Tens and units.
4128 HLT

OBSERVATIONS:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4152
4151

RESULT:
Thus the ALP was written to convert Hex number to decimal number and executed successfully.
EX:NO:
HEX TO BINARY CONVERSION
DATE:

AIM:
To convert an 8-bit hex number to its binary form and store in memory.

OBJECTIVE:

1. First to get the data and rotate it right.


2. Depending upon carry, store either 0 or 1 in memory.
3. Do the rotation 8 times for the 8 bits in that number.

ALGORITHM:
1. Start.
2. Enter the hex number and execute the program.
3. Check for results at locations 4150 through 4157.
4. Stop.
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENTS


4100 LXI H, 4150 Initialize memory pointer
4103 MVI B,08 Counter for 8-bits
4105 MVI A, 5A
4107 LOOP RRC Check least significant bit
4108 JC LOOP1
410B MVI M, 00 Store zero if no carry
410D JMP COMMON
4110 LOOP1 MVI M, 01 Store one if there is a carry
4112 COMMON INX H
4113 DCR B Check for counter
4114 JNZ LOOP
4117 HLT

OBSERVATION:

OUTPUT
ADDRESS DATA
4150
4151
4152
4153
4154
4155
4156
4157

RESULT:

Thus the ALP was written to convert Hex to Binary number and executed successfully.
EX:NO:
HEX TO BINARY CONVERSION

AIM:
To initialize ADC by means of software and the analog input is given to channel 0 and the digital
outputs are visualized at the LED‟s accordingly.

OBJECTIVE:
To compute the analog to digital data using an 8085 program and hardware
Interface.

APPARATUS REQUIRED:
8085 kit, ADC interface board and power cord.

PROCEDURE:
Initializing the analog to digital conversion process by means of software is sometimes necessary.
Execute the program, which starts from the location 4100H and converts the output through LED‟s.
The jumper settings are accordingly changed for the software initialization.
FLOWCHART:

START

SELECT CHANNEL &


INPUT ANALOG DATA

OUTPUT
DIGITAL DATA

GENERATE SOC PULSE

STOP
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 3E MVI A, 10 SELECT CHANNEL
0
4102 D3
4103 OUT F0
4105 MVI A, 18
4107 IN C8 INPUT ANALOG
DATA
4109 MVI A,01
410B OUT D0
410D XRA A
410E XRA A
410F XRA A
4110 MVI A,100H
4112 OUT D0
4114 LOOP IN 008H INPUT DATA TO
ACC.
4116 ANI 01 ADD IMMEDIATE
WITH ACC.
4118 CPI 01 COMPARE
IMMEDIATE WITH
ACC.
411A JNZ LOOP
411D IN C8H INPUT DATA TO
ACC.
411F STA 4150H STORE CONTENT
OF ACC.
4122 HLT

RESULT:
Thus the program to initialize ADC by means of software and to convert analog data at channel 0 to
digital form was written and executed.
EX:NO:
INTERFACING OF DAC WITH 8085
DATE: SQUARE WAVE GENERATION

AIM:
To generate a square wave at the DAC2 output.

OBJECTIVE:
1. To generate Square wave and observe it on the C.R.O
2. To learn the working of 8255.

ALGORITHM:
1. Initialize accumulator with 00H
2. Call delay subroutine
3. Initialize accumulator with FFH
4. Output the data to DAC2.
FLOW CHART:

START

INITIALIZE ACC. WITH 00H

OUTPUT THE DATA TO DAC2

CALL DELAY SUBROUTINE

INITIALIZE ACC. WITH FF H

OUTPUT THE DATA TO DAC2


PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START MVI A, 00 INITIALZE THE
ACC.
4102 OUT 0C8H OUTPUT DATA IN
DAC
4104 CALL DELAY CALL SUBROUTINE
4107 MVI A,0FF INITIALIZE THE
ACC.
4109 OUT 0C8H OUTPUT DATA IN
DAC 1.
410B CALL DELAY CALL SUBROUTINE
410E JMP START
4111 DELAY MVI B,05H INITIALISE B REG.
WITH 05H
4113 L1 MVI C,0FF H INITIALIZE C REG.
WITH FF H
4115 L2 DCR C DEC. C REGISTER
4116 JNZ L2 CHECK IF C IS NOT
EQUAL TO 0.
4119 DCR B DEC. B ELSE
CONTINUE L2.
411A JNZ L1 CHECK b IS NOT EQUAL
TO 0. IF NO RETURN
THE MAIN PROGRAM
ELSE REPEAT L1.
411D RET RETURN THE MAIN
PROGRAM

RESULT:
Thus a square wave was generated at DAC 2 using DAC interface.
EX:NO:
INTERFACING WITH 8085
DATE: SAW TOOTH WAVE GENERATION

AIM:
To generate saw tooth wave at the output of DAC 1.
ALGORITHM:
1. Initialize accumulator with 00H.
2. Call delay subroutine.
3. Increment accumulator.
4. Output the data to DAC 1.
5. Check if the content of accumulator equal to FF H. if yes go to step 1 else to step 3.
6. Stop.
FLOW CHART:

START

INITIALIZE ACC. WITH 00 H

OUTPUT THE DATA TO DAC 1

INCREMENT
ACCUMULATOR

YES NO
IS
ACC.=
FFH?
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT

4100 START MVI A, 00 INITIALZE THE


ACC.
4102 L1 OUT 0C0H OUTPUT DATA IN
DAC
4104 INR A INC. THE ACC.

4105 JNZ L1 JUMP ON NO ZERO


TO L1
4108 JMP START JUMP TO START

RESULT:
Thus the saw tooth wave was generated at the output of DAC 1.
EX:NO:
INTERFACING WITH 8085
DATE: TRIANGULAR WAVE GENERATION

AIM:
To generate a triangular wave at the DAC 2 output.

APPARATUS REQUIRED:
8085 microprocessor kit, 8-bit DAC interface board and power cord.

ALGORITHM:
1. Initialize L register with 00H.
2. Copy contents of L reg. to accumulator.
3. Out the data in DAC.
4. Increment content of H reg.
5. Initialize L reg. with 0FF H.
6. Move the contents of L reg. to A.
7. Out data in DAC.
8. Decrement L reg.
9. Jump on no zero to L2.
10. Jump to start.
FLOWCHART:

START

INITIALIZE L REG. WITH 00H

COPY CONTENTS OF L REG TO ACC.

OUT DATA IN DAC

INCREMENT THE CONTENT OF L REG.

INITIALIZE L REG. WITH 0FFH

OUT DATA IN DAC

DECREMENT L REG.

YES NO
IF NO
ZERO
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT

4100 START MVI L, 00 INITIALZE THE L


REG WITH 00H.
4102 L1 MOV A,L COPY CONTENTS OF
L TO
ACCUMULATOR
OUTPUT DATA IN
DAC.
4104 OUT 0C8H
4107 INR L INCREMENT
CONTENT OF L REG.
4109 JNZ L1
410B MVI L,0FFH INITIALIZE L REG.
WITH OFFH.
410E L2 MOV A,L MOVE CONTENTS
OF L REG TO A
OUTPUT DATA IN
DAC
4111 OUT 0C8H INITIALISE B REG.
WITH 05H
4113 DCR L DECREMENT L REG.
4115 JNZ L2
4116 JMP START

RESULT:
Thus the triangular wave at DAC 2 output was generated.
EX:NO:
INTERFACING 8251 WITH 8085
DATE:

AIM:

To initialize 8253 and 8251 and to check the transmission and receiving of a character.

APPARATUS REQUIRED:

S.NO APPARATUS REQUIRED QUANTITY


1 Microprocessor kit-8085 2
2 Interfacing board – 8251 1

ALGORITHM :

For Transmitter:

1. Start the program.


2. Initialize instruction, command and status word.
3. Initialize the 8085 and 8251.
4. Out the initialized things through port OUT 08.
5. Check the receiver for ready to receive.
6. Stop the program.

For Receiver:

1. Start the program.


2. Enable the receiver.
3. Get the data from transmitter.
4. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 STRAT MVI A,36 Mode Set For 8253
4102 OUT 0CEH
4104 MVI A,0A
4106 OUT 0C8H
4108 MVI A,00
410A OUT 0C8H
410C MVI A,4E Mode set for 8251
410E OUT 0C2H
4110 MVI A,37 Command instruction
4112 OUT 0C2H
4114 MVI A,41 Send the data
4116 OUT 0C0H
4118 RST 1

ISR:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4200 IN 0C0H
4202 STA 4150
4205 RST 1

RESULT:

Thus the program was written to interface two 8085 using 8251 and executed successfully.
EX:NO:
INTERFACING 8279 WITH 8085
DATE:

AIM:

To write a program to interface 8279 (keyboard and display controller) with 8085/8086.

ALGORITHM:

1. Start the program.


2. Specifies the number of the input.
3. Transfer control word to set display mode.
4. Transfer control to clear the display of 8279.
5. Transfer the input to 8279.
6. Execute the delay routine.
7. Decrement the number of input by 1.
PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 START LXI H,412C Set pointer=412C H
4103 MVI D,0FH Initialise counter
4105 MVI A,10H
4107 OUT CNT Set mode and display
4109 MVI A,OCCH Clear display
410B OUT CNT
410D MVI A,90H Write display
410F OUT CNT
4111 LOP MOV A,M
4112 OUT DAT
4114 CALL DELAY
4117 INX H Increment the pointer
4118 DCR D Decrement the counter
4119 JNZ LOP Jump if non-zero to
display the next chr.
411C JMP STRAT
411F DELAY MVI B,0A0H
4121 LOP1 MVI C,0FFH
4123 LOP2 DCR C
4124 JNZ LOP2
4127 DCR B
4128 JNZ LOP1
412B RET

LOOKUP TABLE:

412C FF FF FF FF
4130 FF FF FF FF
4134 98 68 7C C8
4138 1C 29 FF FF

OBSERVATION:

HELP US

RESULT:

Thus the program was written to interface 8279 with 8085 and executed successfully.
EX:NO:
INTERFACING 8253 TIMER WITH 8085
DATE:

AIM:

To interface 8253 Interface board to 8085 p and verify the operation of 8253in six different modes.

APPARATUS REQUIRED:

8085 p kit, 8253 Interface board, DC regulated power supply, VXT parallel bus, CRO.

Mode 0 – Interrupt on terminal count:

The output will be initially low after mode set operations. After loading the counter, the output will be
remaining low while counting and on terminal count; the output will become high, until reloaded again.
Let us set the channel 0 in mode 0. Connect the CLK 0 to the debounce circuit by changing the
jumper J3 and then execute the following program.

PROGRAM:

ADDRESS LABEL MNEMONIC OPERANDS COMMENTS


4100 START: MVI A, 36 Channel 0 in mode 0
4102 OUT CE Send Mode Control word
4104 MVI A, 0A LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT C8 Write count to register
410C HLT

It is observed in CRO that the output of Channel 0 is initially LOW. After giving six clock pulses, the
output goes HIGH.

Mode 1 – Programmable ONE-SHOT:

After loading the counter, the output will remain low following the rising edge of the gate input.
The output will go high on the terminal count. It is retriggerable; hence the output will remain low for the
full count, after any rising edge of the gate input.
Example:

The following program initializes channel 0 of 8253 in Mode 1 and also initiates triggering of Gate
0. OUT 0 goes low, as clock pulse after triggering the goes back to high level after 5 clock pulses. Execute
the program, give clock pulses through the debounce logic and verify using CRO.

PROGRAM:

Address Label Mnemonic Operands Comments


4100 START: MVI A, 32 Channel 0 in mode 1
4102 OUT CE Send Mode Control word
4104 MVI A, 05 LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT C8 Write count to register
410C OUT D0 Trigger Gate0
4100 HLT

Mode 2 – Rate Generator:

It is a simple divide by N counter. The output will be low for one period of the input clock. The
period from one output pulse to the next equals the number of input counts in the count register. If the
count register is reloaded between output pulses the present period will not be affected but the subsequent
period will reflect the new value.
Example:
Using Mode 2, Let us divide the clock present at Channel 1 by 10. Connect the CLK1 to PCLK.
PROGRAM:
Address Opcodes Label Mnemonic Operands Comments
4100 3E 74 START: MVI A, 74 Channel 1 in mode 2
4102 D3 CE OUT CE Send Mode Control word
4104 3E 0A MVI A, 0A LSB of count
4106 D3 CA OUT CA Write count to register
4108 3E 00 MVI A, 00 MSB of count
410A D3 CA OUT CA Write count to register
410C 76 HLT

In CRO observe simultaneously the input clock to channel 1 and the output at Out1.

Mode 3 Square wave generator:

It is similar to Mode 2 except that the output will remain high until one half of count and go low for
the other half for even number count. If the count is odd, the output will be high for (count + 1)/2 counts.
This mode is used of generating Baud rate for 8251A (USART).

Example:

We utilize Mode 0 to generate a square wave of frequency 150 KHz at channel 0.


PROGRAM:

Address Opcodes Label Mnemonic Operands Comments


4100 3E 36 START: MVI A, 36 Channel 0 in mode 3
4102 D3 CE OUT CE Send Mode Control word
4104 3E 0A MVI A, 0A LSB of count
4106 D3 C8 OUT C8 Write count to register
4108 3E 00 MVI A, 00 MSB of count
410A D3 C8 OUT C8 Write count to register
410C 76 HLT

Set the jumper, so that the clock 0 of 8253 is given a square wave of frequency 1.5 MHz. This program
divides this PCLK by 10 and thus the output at channel 0 is 150 KHz.

Vary the frequency by varying the count. Here the maximum count is FFFF H. So, the square
wave will remain high for 7FFF H counts and remain low for 7FFF H counts. Thus with the input clock
frequency of 1.5 MHz, which corresponds to a period of 0.067 microseconds, the resulting square wave has
an ON time of 0.02184 microseconds and an OFF time of 0.02184 microseconds.

To increase the time period of square wave, set the jumpers such that CLK2 of 8253 is connected to
OUT 0. Using the above-mentioned program, output a square wave of frequency 150 KHz at channel 0.
Now this is the clock to channel 2.

Mode 4: Software Triggered Strobe:

The output is high after mode is set and also during counting. On terminal count, the output will go
low for one clock period and becomes high again. This mode can be used for interrupt generation.
The following program initializes channel 2 of 8253 in mode 4.

Example:
Connect OUT 0 to CLK 2 (jumper J1). Execute the program and observe the output OUT 2.
Counter 2 will generate a pulse after 1 second.

PROGRAM:

Address Label Mnemonic Operands Comments


4100 START: MVI A, 36 Channel 0 in mode 0
4102 OUT CE Send Mode Control word
4104 MVI A, 0A LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT C8 Write count to register
410C MVI A, B8 Channel 2 in Mode 4
410E OUT CE Send Mode control Word
4110 MVI A, 98 LSB of Count
4112 OUT CC Write Count to register
4114 MVI A, 3A MSB of Count
4116 OUT CC Write Count to register
4118 HLT
EX:NO:
EX:NO:
STEPPER MOTOR CONTROLLER INTERFACE

Mode 5 Hardware triggered strobe:

Counter starts counting after rising edge of trigger input and output goes low for one clock period
when terminal count is reached. The counter is retriggerable.

Example:
The program that follows initializes channel 0 in mode 5 and also triggers Gate 0. Connect CLK 0 to
debounce circuit.
Execute the program. After giving Six clock pulses, you can see using CRO, the initially HIGH
output goes LOW. The output ( OUT 0 pin) goes high on the next clock pulse.

PROGRAM:

Address Label Mnemonic Operands Comments


4100 START: MVI A, 1A Channel 0 in mode 5
4102 OUT CE Send Mode Control word
4104 MVI A, 05 LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT D0 Trigger Gate 0
410C HLT

Result:
Thus the 8253 has been interfaced to 8085 p and six different modes of 8253 have been studied.
EX:NO: STEPPER MOTOR CONTROLLER INTERFACE

AIM:

To run a stepper motor at different speed in two directions.

APPARATUS REQUIRED:

1. 8085 MP kit
2. Stepper motor interface kit.
3. Stepper motor.
4. Interface bus

ALGORITHM:

1. Enter the above program starting from the location 4100.


2. Execute the same.
3. The stepper motor rotates.
4. Speed can be varied by varying the count at DE pair.
5. Direction can be varied by entering the data in the look-up table in the reverse order.

PROGRAM:

Address Label Mnemonic Operands Comments


4100 START LXI H,LOOK
UP
4103 MVI B,04 Initialize the counter
4105 REPT MOV A,M
4106 OUT 0C0H
4108 LXI D,0303H Enter the speed
410B DELAY NOP
410C DCX D
410D MOV A,E
410E ORA D
410F JNZ DELAY
4112 INX H
4113 DCR B
4114 JNZ REPEAT
4117 JMP START
411A LOOK UP

RESULT:
Thus the ALP was written to run a stepper motor at different speed in two directions.
EX:NO:
ARITHMETIC OPERATIONS OF 8051

DATE:

AIM:

To write the ALP to perform arithmetic operations using 8051.

OBJECTIVE:

1. To Perform the arithmetic operations (addition, subtraction, multiplication and


Division).
2. Instructions of Microprocessor 8051
3. Addressing modes of Microprocessor 8051
4. Flag register of Microprocessor 8051

ALGORITHM:

1. Start.
2. Get the inputs.
3. Perform the arithmetic operations (addition, subtraction, multiplication and division).
4. Stop.

PROGRAM:

ADDITION:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 MOV DPTR, #4200 Move content of 4200 to DPTR
4102 MOVX A, @DPTR Move DPTR content to acc
4104 MOV B, A Move content of A to B reg
4106 INC DPTR Increment DPTR
4108 MOVX A, @DPTR Move DPTR content to acc
410A ADD A,B Add content of B with A
410C MOV DPTR, #4500 Move 4500 content to DPTR
410E MOVX @DPTR, A Move A reg content to DPRT
4110 HERE SJMP HERE Stop the program
OBSERVATION:

INPUT OUTPUT
4200 4500
4201

SUBTRACTION:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 CLR C
4100 MOV A,#DATA1 Move the data1 to A
4103 SUBB A,#DATA2 Subtract data2 with A
4104 MOV DPTR,#4500 Move the DPTR from 4500
4105 MOVX @DPTR,A Move the content A to DPTR
4106 HERE SJMP HERE Stop the program

INPUT OUTPUT
4200 4500
4201

MULTIPLICATION:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 MOV DPTR,#4200H Move the content 4200 to DPTR
4103 MOVX A,@DPTR Move DPTR content to acc
4104 MOV B,A Move A reg to B reg
4106 INC DPTR Increment DPTR
4107 MOVX A,@DPTR Move DPTR content to A
4108 MUL A,B Multiply A&B reg
4109 MOV DPTR,#4500 Move 4500 to DPTR
410C MOVX @DPTR,A Move A reg to DPTR
410D INC DPTR Increment DPTR
410E MOV A,B Move B to A reg
4110 MOVX @DPTR,A Move A to DPTR
4111 HERE SJMP HERE Stop the program

INPUT OUTPUT
4200 4500
4201
DIVISION:

ADDRESS LABEL MNEMONICS OPERAND COMMENT


4100 MOV DPTR,#4200H Move the content 4200 to DPTR
4103 MOVX A,@DPTR Move DPTR content to acc
4104 MOV B,A Move A reg to B reg
4106 INC DPTR Increment DPTR
4107 MOVX A,@DPTR Move DPTR content to A
4108 DIV AB Divide A&B reg
4109 MOV DPTR,#4500 Move 4500H to DPTR
410C MOVX @DPTR,A Move A reg to DPTR
410D INC DPTR Increment DPTR
410E MOV A,B Move B to A reg
4110 MOVX @DPTR,A Move A to DPTR
4111 HERE SJMP HERE Stop

INPUT OUTPUT
4200
4500
4201

RESULT:

Thus the ALP was written to perform arithmetic operations using 8051.
STEPPER MOTOR INTERFACING WITH 8051
AIM:
To interface a stepper motor with 8051 microcontroller and operate it.

THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a stepper
motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the next. Stepper
Motors are used very wisely in position control systems like printers, disk drives, process control machine
tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles has
its own winding. The excitation of any one winding generates a North Pole. A South Pole gets induced at
the diametrically opposite side. The rotor magnetic system has two end faces. It is a permanent magnet with
one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, and B2 are cyclically excited with a DC current to run the
motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise stepping
can be obtained.

2-PHASE SWITCHING SCHEME:


In this scheme, any two adjacent stator windings are energized. The switching scheme is shown in
the table given below. This scheme produces more torque.

ANTICLOCKWISE CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA
1 1 0 0 1 09H 1 1 0 1 0 0AH
2 0 1 0 1 05H 2 0 1 1 0 06H
3 0 1 1 0 06H 3 0 1 0 1 05H
4 1 0 1 0 0AH 4 1 0 0 1 09H

ADDRESS DECODING LOGIC:


The 74138 chip is used for generating the address decoding logic to generate the device select
pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor driving
circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry that
generates the driving pulses use silicon darlington pair transistors. The inputs for the interface circuit are
TTL pulses generated under software control using the Microcontroller Kit. The TTL levels of pulse
sequence from the data bus is translated to high voltage output pulses using a buffer 7407 with open
collector.

RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at various
speeds.
Source Program 1:
 MVI A, 80H : Initialize 8255, port A and port B
 OUT 83H (CR) : in output mode
 START: MVI A, 09H
 OUT 80H (PA) : Send data on PA to glow R1 and R2
 MVI A, 24H
 OUT 81H (PB) : Send data on PB to glow G3 and G4
 MVI C, 28H : Load multiplier count (40ıο) for delay
 CALL DELAY : Call delay subroutine
 MVI A, 12H
 OUT (81H) PA : Send data on Port A to glow Y1 and Y2
 OUT (81H) PB : Send data on port B to glow Y3 and Y4
 MVI C, 0AH : Load multiplier count (10ıο) for delay
 CALL: DELAY : Call delay subroutine
 MVI A, 24H
 OUT (80H) PA : Send data on port A to glow G1 and G2
 MVI A, 09H
 OUT (81H) PB : Send data on port B to glow R3 and R4
 MVI C, 28H : Load multiplier count (40ıο) for delay
 CALL DELAY : Call delay subroutine
 MVI A, 12H
 OUT PA : Send data on port A to glow Y1 and Y2
 OUT PB : Send data on port B to glow Y3 and Y4
 MVI C, 0AH : Load multiplier count (10ıο) for delay
 CALL DELAY : Call delay subroutine
 JMP START

Delay Subroutine:

 DELAY: LXI D, Count : Load count to give 0.5 sec delay


 BACK: DCX D : Decrement counter
 MOV A, D
 ORA E : Check whether count is 0
 JNZ BACK : If not zero, repeat
 DCR C : Check if multiplier zero, otherwise repeat
 JNZ DELAY
 RET : Return to main program

RESULT:

Thus the ALP was written to interface stepper motor using 8051microcontroller.
8051 - SUM USING STACK
AIM:
To find the sum of elements in an array using stack.
ALGORITHM:
1. Start
2. Move the data to stack pointer
3. Move the data to accumulator
4. Move the data to reg B
5. Move the data to DPL
6. Push the value of A to stack
7. Push the value of B to stack
8. Push the value of DPL to stack
9. Halt
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100 MOV SP, #67 67
4103 MOV A, #88 88
4105 MOV B, #66 66
4108 MOV DPL, #43 43
410B PUSH A
410D PUSH B
410F PUSH DPL
4111 SJMP

RESULT:
The sum of elements in an array is calculated.
8051 - SUM USING CALL OPTION
AIM:
To find the sum of elements in an array using call option.
ALGORITHM:
1. Start
2. Move the data to DPTR
3. Move the data to accumulator
4. Adjacent call 4200
5. Add A & R0
6. Move the 16 bit data from A to DPTR
7. Move the data to accumulator
8. Move the data to R0
9. Return to 4107
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100 MOV DPTR,# 4300 43,00
4103 MOV A, # 00 00
4105 ACALL 4200 42,00
4108 ADD A, R0
410B MOVX @DPTR,A 80
410D SJMP
410F MOVA,#02 02
4111 MOV R0, #01 01
RET

OBSERVATION:
INPUT OUTPUT
4200 4300
4202

RESULT:

The sum of elements in an array using call option is calculated is calculated.


TRAFFIC LIGHT CONTROLLER

Statement: Design a microprocessor system to control traffic lights. The traffic light arrangement is as shown in
Fig. The traffic should be controlled in the following manner.

1) Allow traffic from W to E and E to W transition for 20 seconds. 2) Give transition period of 5 seconds (Yellow

bulbs ON) 3) Allow traffic from N to 5 and 5 to N for 20 seconds 4) Give transition period of 5 seconds (Yellow

bulbs ON) 5) Repeat the process.

HARDWARE FOR TRAFFIC LIGHT CONTROL

Fig. shows the interfacing diagram to control 12 electric bulbs. Port A is used to control lights on N-S road and Port

B is used to control lights on W-E road. Actual pin connections are listed in Table 1 below.
The electric bulbs are controlled by relays. The 8255 pins are used to control relay on-off action with the help of

relay driver circuits. The driver circuit includes 12 transistors to drive 12 relays. Fig. also shows the interfacing of

8255 to the system.

INTERFACING DIAGRAM
SOFTWARE FOR TRAFFIC LIGHT CONTROL
FLOW CHART:

Source code:

MVI A,10
OUT C8
MVI A,18
OUT C8
MVI A,10
OUT D0
XRA A
XRA A
XRA A
MVI A,00
OUT D0
LOOP IN D8
ANI 01
CPI 01
JNZ LOOP
IN C0
STA 4150
HLT

RESULT:

Thus an assembly language program to simulate the traffic light at an intersection using a traffic light
interfaces was written and implemented.
Introduction to Software Tools
MPLAB, PROTEUS, and QL-2006 programmer

Aim:

1. To be familiar with some software tools like MPLAB, PROTEUS, and IC-
PROG.
2. To know how to make a project using MPLAB and then get the hex file of
the software program of the project.
3. How to simulate the hex file using PROTEUS.

Introduction

These programs are the backbone of the microprocessor and microcontroller based
systems; since using MPLAB we can build the software of the project using C or Assembly
language, and then we can simulate the project virtually using PROTEUS, finally we can
download the program on the microcontroller and see the results practically using IC-
PROG.
So this experiment includes all the knowledge the student will need to get started to these
programs.

1. MPLAB Program

• What is MPLAB?

MPLAB is a software program that runs on your PC to provide a development


environment for your embedded system design.
In other words it is a Windows program package that makes writing and developing
a program easier. It could best be described as developing environment for a
standard program language that is intended for programming microcontrollers.
• Get started to MPLAB
1. Open the program by double clicking on its icon on the desktop.
2. From the project menu choose project wizard.
3. Choose PIC 16F84A.
4. Brows and name the project.
5. From view menu choose project; to view the project.
6. Then add a file to the source files by right clicking on source files, and
choose add files and then name the file anyName.asm.
2. PROTEUS Program

• What is PROTEUS?

Proteus contains everything you need to develop, test and virtually prototype your
embedded system designs based around the Microchip Technologies™ PIC16 series
of microcontrollers. The unique nature of schematic based microcontroller simulation
with Proteus facilitates rapid, flexible and parallel development of both the system
hardware and the system firmware. This design synergy allows engineers to evolve
their projects more quickly, empowering them with the flexibility to make hardware or
firmware changes at will and reducing the time to market.
Proteus VSM models will fundamentally work with the exact same HEX file as you
would program the physical device with, binary files (i.e. Intel or Motorola Hex files)
produced by any assembler or compiler.

• How to setup PROTEUS?

1. Start-up the Microsoft Windows.


2. Place the ECOM 4315 CD into CD ROM drive.
3. Double click on the software tools folder and then choose Proteus Simulator after
that double click Proteus 7.1 folder and run the setup.
4. Press next until you reach the window which ask for the key.
5. From browse for key; browse until you reach the same folder where the setup
exists, and then open the second folder and chose the MAXIM_LICENCE folder.
6. Then click on the top icon which is MAXIM and then press install.
7. Then choose yes and then close the window, after that browse and install the
program.
8. After that run the patch which exist in the same folder where the
MAXIM_LICENCE exists.
9. Then browse for c:\Program files\Labcenter electronics \Proteus.
10. Finally chose next, and then finish.

• Get started to PROTEUS

1. From start menu chose the PROTEUS, and then chose ISIS(blue).
2. To get a part click on Devices ( P ).
3. Write the name of the PIC16F84A.
4. To get LED write led then chose green led.
5. To get a resistor write 1k and chose the first part.
3. QL-2006 programmer

QL-2006 programmer is the high-speed programmer designed specially


for development and production programming of PIC single chip
microcomputer (SCM) by Shenzhen Qianlongsheng Electronic
Technology Co., Ltd. The product is featured with small volume, low
power consumption, high reliability as well as easy and convenient
operation. QL-2006 is applicable for almost all PIC10/12/16/18 series
SCMs except 16C5X. It also supports memories in 24XX series and
93XX series.

 Hardware Installation
There is no special requirement for installation of this programmer.
Connect programmer to PC through serial port cable or USB cable
and power up, then the programmer works. (This programmer supports
direct USB power supply. If USB cable is connected, you may not
connect external power. However, if current through USB interface is
very low – less than 200MA and insufficient to drive programmer,
connection to external power is required to enable the programmer to
work regularly.)

 Software Installation

Find file QL-PROGvXXen.EXE under root directory of CD, double


click this file to access installation interface of application software, and
operate according to prompts to finish the installation. Its shortcut will
appear on desktop automatically after installation.

 Running of Software
After proper installation, shortcut of this software will appear on
desktop.We can double click it to run the software.
Result:
Thus the Programming PIC architecture with software tools was done .
EXPERIMENT 11

AIM:
Write a program for blinking of Led using 8051 microcontroller.
HARDWARE USED:
Microcontroller kit, Power supply, connecting wires.
SOFTWARE USED:
Keil µVision 4, Flash Magic.
WORKING OF SOFTWARE:
1. Keil µVision:

The µVision IDE combines project management, run-time environment, build facilities, source
code editing, and program debugging in a single powerful environment. µVision is easy-to-use and
accelerates your embedded software development. µVision supports multiple screens and allows
you to create individual window layouts anywhere on the visual surface.
Procedure of using Keil:
Step 1: Download the Keil Uvision IDE

For learning purposes, you can try the evaluation version of Keil which has code limitation of 2K
bytes. You must download the C51 version for programming on 8051 microcontroller
architecture.

Step 2: To initiate the programming you must create a project using the keil Uvision IDE
The option to create a new project will be available under the project tab in the toolbar. Next, you
have to store the project in a folder and give a suitable name to it.

Step 3: Selecting the type of device you are working with


The device selection dialog provides you with the option to select the 8051 derivatives for which
you want to develop the program. If you are not sure about your device you can refer to
the description of the devices which is displayed on the left pane of the dialog. Accordingly, select
your device and click OK to confirm.

Step 4: Adding C files to your project

You must add C file to your project before you begin coding. This can be done by right-clicking
on your project from the project pane and selection “Add a new item to source group 1”. In the
next dialog box, you will be given with the choice on what type of file you want to add such as C,
C++, header, text etc. Since here we are dealing with Embedded C programming, select C File (.c)
option. Provide the necessary name, location and click on add.
Step 5: Coding in C

The main part has finally arrived, so now you can go along with programming in C with your
respective microcontroller.

Example: Blinking of LED connected to Port 1 of 8051(or any other Intel family controller like
Atmel controller in laboratory).

#include <reg51.h>
//delay function declaration
void delay(void);
void main(void)
{
//an infinite loop
while(1)
{
// Turn ON all LED's connected to
Port1 P1 = 0xFF;
delay();
// Turn OFF all LED's connected to
Port1 P1 = 0x00;
delay();
}
}
//delay function definition
void delay(void)
{
int i,j;
for(i=0;i<0xff;i+
+)
for(j=0;j<0xff;j++);
}

Step 6 : Compiling and building the C project using Keil Uvision IDE

In order to build recently created C program go to Project tab and click on Build Target on the
menu bar. An alternate way to do this is by pressing the F7 key. If the code that you have written
is correct, the code will successfully compile without any errors. You can check your output in the
Build Output pane.
Step 7: Generating the hex file using Keil Uvision IDE

The code you compiled cannot be directly fed to the microcontroller, it is not possible. For that
purpose, we have to generate the hex code for your respective file.

In order to generate the hex code, right click on the „Target 1‟ folder and select options for target
„Target 1‟. Select the Output tab in the target „Target 1‟ dialog box. Make sure Create Hex File
option is checked and the HEX format should be HEX-80. Click OK.

Again rebuild your project by pressing F7. Your required hex file would have been generated with
the same as your project in the Objects folder.

If you wish you can also view your hex code by using a notepad.

Step 8: Burning the hex code into 8051 microcontroller


In order to burn the hex code to your microcontroller, there are two ways which are specific to the
device you are working with. Some devices, for example, P89V51 they have their own built- in
bootloader and you can burn the hex code directly through the serial port. Mostly you will require
a specific programmer for your 8051 microcontroller through which you can easily upload your
hex code by connecting the programmer via normal USB port.
2. Flash Magic

Flash Magic is a PC tool for programming flash based microcontrollers from NXP using a serial
or Ethernet protocol while in the target hardware.

Procedure for using Flash Magic:

1. Select the IC from Select Menu.


2. Select the COM Port. Check the device manager for detected Com port.
3. Select Baud rate from 9600-115200
4. Select None Isp Option.
5. Oscillator Freq 12.000000(12Mhz).
6. Check the Erase blocks used by Hex file option
7. Browse and Select the hex file.
8. Check the Verify After Programming Option.
9. If DTR and RTS are used then go to Options->Advanced Options-> Hardware
Configuration and select the Use DTR and RTS Option.
10. Hit the Start Button to flash the hex file.
11. Once the hex file is flashed, Reset the board. Now the controller should run your
application code.
PROGRAM:

#inclu
de<re
g51.h
>void
main()
{
unsigned int x;

for(;;)
{

P
2
=
0
x
5
5
;
for( x=0;x<400;x++);
{
}

P
2
=
0
x
A
A
;

for( x=0;x<400;x++);
{
}
}
}
Result
Thus execution of the program the Led start blinking alternatively at odd and
even positions, after some delay.

You might also like