Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 51

Microprocessor &

Interfacing LAB
(BECP 501)

LAB MA NUAL

V SEMESTER

Department of Electronics & Communication


Engineering, Roorkee Institute of Technology,
Roorkee
DO’S and DON’T S in Laboratory
• Come fully prepared for the experiment in the laboratory.
• Check for appropriate power supply before connecting to the equipment.
• Decide the appropriate range of the measuring instruments on the basis of quantity to
be measured.
• Make the connections without connecting the leads to the supply.
• Re-check the connections and show it to the teacher/instructor before switching on the
power supply to the circuit.
• Energize the circuit only with the permission of the teacher/instructor.
• After the experiment, disconnect the connection sand put back the connecting
wires/leads at appropriate place.
• Return all the apparatus to the lab-staff.
• In case of shock, switch-off the power supply immediately.
• Strictly follow the Instructions.
• Avoid loose connections.
• Don’t touch the main power supply leads with bare hand and avoid body earth.
• Don’t use the mobile phones during laboratory.
LIST OF EXEPRIMENTS

Sl .No. Name of the Experiments


1 To Perform Addition and Multiplication of two 8 bit numbers.

2 To find the maximum value in an array.

3
To perform BCD To HEX Conversion and HEX to BCD
Conversion.

4
To Design Counter Using Timer

5 Programming with 8086-16 bit, 32 bit Multiplication /


Division.

6
Interfacing with 8085/8086-8279, 8251.

7 Interfacing with 8085/8086-8279, 8251.

8
Stepper motor Interfacing and Seven Segment Display
Interfacing using 8051.
Experiment -1( a)
Objective: To Perform Addition and Multiplication of two 8 bit numbers.

ALGORITHM:
1. Initialize memory pointer to data location.
2. Get the first number from memory in accumulator.
3. Get the second number and perform Addition from the accumulator.
4. If the result yields a carry, the content of the acc. is maintained and 01H is
added to Reg C. Reg. C is a register is cleared and the content of that reg. is
incremented in case there is a Carry. If there is no carry the content of the acc.
is directly taken as the result.
5. Store the answer at next memory location.

Flow Chart:
RESULT:
Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.

OBSERVATION:
Experiment-1(b)

To multiply two 8 bit numbers stored at consecutive memory locations


and store the result in memory.

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.


PROGRAM:

OBSERVATION:

RESULT:

Thus the 8-bit multiplication was done in 8085p using repeated addition
method.
Experiment-2

Objective: To find the maximum value in an array.

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.


PROGRAM :

OBSERVATION:

RESULT:
Thus the largest number in the given array is found out.
Experiment-3(a)

Objective – To perform BCD To HEX Conversion and HEX to BCD


Conversion ALGORITHM.

ALGORITHM:
1. Initialize memory pointer to 2050
2. Get the most significant digit
3. Multiply the MSD by 10 using repeated addition
4. Add LSD to result obtained in above step
5. Store the converted result in memory 2052

Flow Chart:
PROGRAM:

ADDRESS OPCODE LABLE MNEMONICS OPRAND COMMENT


2000 LXI H  load the HL pair register with the
address 2050 of memory location .
2001 50
2002 20
2003 MOV A, M copies the content of memory into
register A
2004 ADD A add the content of accumulator with
itself.
2005 MOV B, A move the content of accumulator into
register B.
2006 ADD A add the content of accumulator with
itself.
2007 ADD A add the content of accumulator with
itself.
2008 ADD B dd the content of accumulator with
register B and store the result in
accumulator.
2009 INX H increment register pair HL.

200A ADD M add the content of accumulator with


memory and store the result in
accumulator.
200B INX H increment register pair HL.

200C MOV M, A copies the content of accumulator


into memory
200D HLT STOP

OBSERVATION:

INPUT OUTPUT

2000 200C

2001
Experiment-3(b)

3(b) To perform HEX to BCD Conversion

ALGORITHM:
1).Initialize memory pointer to 5000 H
2. Get the Hexa decimal number in C – register
3. Perform repeated addition for C number of times
4. Adjust for BCD in each step
5. Store the BCD data in Memory

Flow Chart:
ADDRESS OPCODE LABLE MNEMONICS OPRAND COMMENT
F000 LXI H Initialize memory pointer

F001 00
F002 80
F003 MVI D Clear D- reg for Most significant Byte

F004 00 .
F005 XRA A Clear Accumulator

F006 Get HEX data


MOV C, M

F007 loop ADI Count the number one by one.

F008 01
F009 DAA Adjust for BCD count
F00A SKIP JNC Jump to SKIP.
F00D INR D Increase D
F00E SKIP DCR C Decrease C register
F00F Loop JNZ Jump to LOOP
F012 MOV L, A Load the Least Significant Byte
F013 MOV H, D Load the Most Significant Byte
F014 SHLD 8050H Store the BCD
F017 HLT Terminate the program
F016
PROGRAM:

OBSERVATION

INPUT OUTPUT

5020

RESULT: BCD To HEX Conversion and HEX to BCD Conversion has


been studid
Experiment-4

Objective- Programming with 8086-16 bit, 32 bit Multiplication / Division

FLOW CHART:

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.

PROGRAM:
OBSERVATION:

RESULT:

Thus an ALP was written for 8-bit division using repeated subtraction method
and executed using 8085p kits.
Experiment-5

Objective: Programming with 8086-16 bit, 32 bit Multiplication / Division.


Algorithm –
1. Initialize the MSBs of difference to 0

2. Get the first number

3. Subtract the second number from the first number.

4. If there is any borrow, increment MSBs of difference by 1.

5. Store LSBs of difference

6. Store MSBs of difference

Flow chart
Program

ADDRESS OPCODE LABLE MNEMONICS OPRAND COMMENT


2000 MOV Initialize memory pointer

2001 00
2002 80
2003 MVI D Clear D- reg for Most significant Byte

2004 00 .
2005 XRA A Clear Accumulator

2006 Get HEX data


MOV C, M

2007 loop ADI Count the number one by one.


01
DAA Adjust for BCD count

SKIP JNC Jump to SKIP.


INR D Increase D
SKIP DCR C Decrease C register
Loop JNZ Jump to LOOP
MOV L, A Load the Least Significant Byte
MOV H, D Load the Most Significant Byte
SHLD 8050H Store the BCD
HLT Terminate the program
Experiment-4

Objective- Programming with 8086-16 bit, 32 bit Multiplication / Division

FLOW CHART:

LOGIC: Division is done using the method Repeated subtraction.


6. Load Divisor and Dividend.

7. Subtract divisor from dividend.

8. Count the number of times of subtraction which equals the quotient

9. Stop subtraction when the dividend is less than the divisor .The dividend now becomes the
remainder. Otherwise go to step 2.

10. Stop the program execution.

PROGRAM:
OBSERVATION:

RESULT:

Thus an ALP was written for 8-bit division using repeated subtraction method
and executed using 8085p kits.
FLOW CHART:
RESULT:
Thus an ALP program for 16-bit addition was written and executed in 8085p
using special instructions.

Experiment-4(b)

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


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.

PROGRAM:
RESULT:
Thus an ALP program for subtracting two 16-bit numbers was written and
executed.

Experiment-5(a)

Aim: To multiply two 16 bit numbers and store the result in memory.
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.

FLOW CHART:
PROGRAM:
RESULT:
Thus the 16-bit multiplication was done in 8085p using repeated addition
method.
Experiment-5(b)

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

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.
PROGRAM:
FLOW CHART:
OBSERVATION:

RESULT:
Thus the 16-bit Division was done in 8085p using repeated subtraction
method.
Experiment-6(a)

To find the largest element in an array.

ALGORITHM:
10. Place all the elements of an array in the consecutive memory locations.
11. Fetch the first element from the memory location and load it in the accumulator.
12. Initialize a counter (register) with the total number of elements in an array.
13. Decrement the counter by 1.
14. Increment the memory pointer to point to the next element.
15. Compare the accumulator content with the memory content (next element).
16. If the accumulator content is smaller, then move the memory content (largest element)
to the accumulator. Else continue.
17. Decrement the counter by 1.
18. Repeat steps 5 to 8 until the counter reaches zero
10.Store the result (accumulator content) in the specified memory location.

OBSERVATIONS:

RESULT:
Thus the largest number in the given array is found out.
Aim:
Experiment-6(b)

To find the smallest element in an array.

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.

PROGRAM:
OBSERVATION:

RESULT:

Thus the smallest number in the given array is found out.

Experiment-7(a)

To sort the given number in the ascending order using 8085


microprocessor.

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
interchange 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.

PROGRAM:
Aim:

OBSERVATION:

RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending
order.
Experiment-7(b)

To sort the given number in the descending order using 8085


microprocessor.

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 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.

PROGRAM:
Aim:
OBSERVATION:

RESULT:
Thus the descending order program is executed and thus the numbers are arranged in
descending order.
Experiment-8(a)

To convert a given decimal number to hexadecimal.

ALGORITHM:
6. Initialize the memory location to the data pointer.
7. Increment B register.
8. Increment accumulator by 1 and adjust it to decimal every time.
9. Compare the given decimal number with accumulator value.
10. When both matches, the equivalent hexadecimal value is in B register.
11. Store the resultant in memory location.

FLOW CHART:
Aim:
PROGRAM:

OBSERVATION:

RESULT:
Thus an ALP program for conversion of decimal to hexadecimal was written
and executed.

Experiment-8(b)

To convert a given hexadecimal number to decimal.

ALGORITHM:
1. Initialize the memory location to the data pointer.
2. Increment B register.
3. Increment accumulator by 1 and adjust it to decimal every time.
4. Compare the given hexadecimal number with B register value.
5. When both match, the equivalent decimal value is in A register.
6. Store the resultant in memory location.
FLOW CHART:

PROGRAM:
Aim:

OBSERVATION:

RESULT:
Thus an ALP program for conversion of hexadecimal to decimal has been written and
executed.
Experiment-9(a)

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

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. Adjust the accumulator value to the proper BCD value using DAA instruction.
5. Store the answer at another memory location.

PROGRAM:
Aim:
OBSERVATION:

RESULT:
Thus the 8 bit BCD numbers stored at 4500 &4501 are added and the result
stored at 4502 & 4503.
Experiment-9(b)

To Subtract two 8 bit BCD numbers stored at consecutive memory


locations.

ALGORITHM:

1. Load the minuend and subtrahend in two


registers.
2. Initialize Borrow register to 0. 3. Take the
100’s complement of the subtrahend.
4. Add the result with the minuend which yields the result.
5. Adjust the accumulator value to the proper BCD value using DAA
instruction. If there is a carry ignore it.
6. If there is no carry, increment the carry register by 1
7. Store the content of the accumulator (result)and borrow register in the
specified memory location.

PROGRAM:
Aim:

OBSERVATION:

RESULT:
Thus the 8 bit BCD numbers stored at 4500 &4501 are subtracted and the result
stored at 4502 & 4503.
Experiment-10

To perform the 2 x 2 matrix multiplication.

ALGORITHM:
1. Load the 2 input matrices in the separate address and initialize the HL and the DE
register pair with the starting address respectively.
2. Call a subroutine for performing the multiplication of one element of a matrix with
the other element of the other matrix.
3. Call a subroutine to store the resultant values in a separate matrix.

PROGRAM:
Aim:

FLOW CHART:
OBSERVATION:

RESULT:
Thus the 2 x 2 matrix multiplication is performed and the result is stored at 4700,
4701 , 4702 & 4703.

You might also like