Вы находитесь на странице: 1из 19

S.

VEERASMY CHETTIAR COLLEGE OF ENGINEERING & TECHNOLOGY

Department of Electronics and Communication Engineering

MICROPROCESSORS AND
MICROCONTROLLERS LABORATORY
MANUAL

Subject : Microprocessors and Microcontrollers Lab


Code : EC58
Semester : V
Year : 2011-2012

Prepared by: Approved by:

(D.R.Ramji, Lect / ECE) (Mrs. K. Muthulakshmi, HOD/ECE)

1
Syllabus:

EC58 MICROPROCESSOR AND MICROCONTROLLER LAB (V SEM ECE)


1. Programs for 16 bit Arithmetic operations (Using 8086).
2. Programs for Sorting and Searching (Using 8086).
3. Programs for String manipulation operations (Using 8086).
4. Programs for Digital clock and Stop watch (Using 8086).
5. Interfacing ADC and DAC.
6. Parallel Communication between two MP Kits using Mode 1 and Mode 2 of 8255.
7. Interfacing and Programming 8279, 8259, and 8253.
8. Serial Communication between two MP Kits using 8251.
9. Interfacing and Programming of Stepper Motor and DC Motor Speed control.
10. Programming using Arithmetic, Logical and Bit Manipulation instructions of
8051microcontroller.
11. Programming and verifying Timer, Interrupts and UART operations in 8031
microcontroller.
12. Communication between 8051 Microcontroller kit and PC.

LIST OF LAB EXPERIMENTS:

1. Addition of two 16-bit data using 8086 Microprocessor


2. Subtraction of two 16 bit numbers using 8086 microprocessor
3. Multiplication of two 16-bit number using 8086 microprocessor
4. Division of 32-bit data by 16-bit data using 8086 microprocessor
5. Sort an array in Ascending order using 8086 microprocessor
6. Sort an array in Descending order using 8086 microprocessor
7. String Move
8. String Manipulation
9. Square Wave Generator using 8253
10. Addition of two 16 bit numbers using 8051 Microcontroller
11. Subtraction of two 16 bit numbers using 8051 Microcontroller
12. Multiplication of two 8- bit numbers using 8051 Microcontroller
13. Division of two 8- bit numbers using 8051 Microcontroller
14. Timer and Interrupt using 8051 Microcontroller
15. Serial Mode Communication using 8051 Microcontroller and PC
16. Interfacing of 8279 to Display a Rolling Word

Note: Students should come prepared with complete Programme/Algorithm/


Flowchart before hand for the experiment to be done on that day. They should
complete the experiment, write the result and get signature in observation note from
staff in-charge individually. They should complete the record work before coming to
next lab class

2
Experiment No.1(a):

Addition of two 16-bit data using 8086 Microprocessor

Aim: To write an assembly language program to add numbers of 16-bit data

Apparatus Required: 8086 P kit, 12 V power supply.

16 bit Addition
Algorithm:
Step-1: Load the first data in AX register.
Step-2: Load the second data in BX register.
Step-3: Clear CL register.
Step-4: ADD two data and get the sum in AX register.
Step-5: Store the sum in memory.
Step-6: Check for carry, if carry flag is set then go to next step, otherwise go to step-8.
Step-7: Increment CL register.
Step-8: Store the carry in memory.
Step-9: Stop.

Program:

Address Op-Code Label Mnemonics Operands Comments


8000 88 10 09 MOV AX 1009 ; Get the first data in AX register.
8003 BB 10 01 MOV BX 1001 ; Get the second data in BX register.
8006 B1 00 MOV CL,00 ; Clear CL register.
8008 03 C3 ADD AX BX ; Add two data, sum is stored in the
AX register.
800A A3 00 84 MOV [8400] AX ; Store the sum in memory 8400.
800D 73 02 JNC AHEAD ; if carry is not exist then jump to
AHEAD
800F FE C1 INC CL ; If carry flag is set, increment CL by
one.
8011 88 0E AHEAD MOV [8402] CL ; Store the carry in memory 8402.
02 84
8015 F4 HLT ; Stop the program

Result :
Thus an assembly language program to add two 16-bit data is executed and output was
verified.

3
Flow Chart:

Start

Load the first data in AX register

Load the second data in BX register

Clear CL register

Get the sum in AX register

Store the sum(AX register) in memory

YES
IF
CF=
1 Increment CL register
NO

Store CL register(carry) in memory

Stop

Output:
Input Data
Data 1: 1009

Data 2: 1001

Memory Location Content


Sum : 8400

8401

Carry:8402

4
Experiment No.1(b):

Subtraction of two 16 bit numbers using 8086 microprocessor

Aim: To write an assembly language program to subtract two numbers of 16-bit data.

Apparatus Required: 8086 P kit, 12 V power supply.

16 bit Subtraction
Algorithm:
Step-1: Load the first data in AX register.
Step-2: Subtract the second data from first data where the second data is accessed through its
address, store the result in AX registers
Step-3: Move the result AX register to destination address
Step-4: Stop.

5
Experiment No.1(c):

Multiplication of two 16-bit number using 8086 microprocessor

Aim: To write an assembly language program to multiply two numbers of 16-bit data.

Apparatus required: 8086 P kit, 12 V power supply.

16 bit Multiplication
Algorithm:
Step-1: Load the address of the first data in AX register.
Step-2: Multiply the second data with first data, where the second data is accessed through its
address and store the result in AX register.
Step-3: Move the first 16 bit result from AX register to the destination address
Step-4: Move the second 16 bit result from BX register to the destination address
Step-5: Stop

6
Experiment No.1(d):

Division of 32-bit data by 16-bit data

Aim: To write an assembly language program to divide 32 bit data by 16-bit data.

Apparatus Required: 8086 P kit, 12 V power supply.

16 bit Division
Algorithm:
Step-1: Load the address of the first data in AX register
Step-2: Divide the first data by second data, where the second data is accessed through its
address and store the result in AX register.
Step-3: Move the quotient to the destination address AX register.
Step-4: Move the remainder to the destination address from BX register.
Step-5: Stop.

7
Experiment No. 2(a):

Sort an array in Ascending order using 8086 microprocessor


Aim:
To write an assembly language program to arrange numbers in ascending order

Apparatus Required: 8086 P kit, 12 V power supply.


Algorithm:

Arrange the Numbers in Ascending Order


Algorithm:
Step-1: Load the address of the input data in the stack index.
Step-2: Load the count value of the input data.
Step-3: Load the input data for the desired count value.
Step-4: Increment the stack index
Step-5: Move the first data from stack index to the accumulator and increment the stack index.
Step-6: Compare the stack index and accumulator.
Step-7: If carry will exist, exchange the accumulator and stack index else increment CH.
Step-8: If carry will not exist then decrement CL else repeat step 5.
Step-9: Stop.

8
Experiment No. 2(b):
Sort an array in Descending order using 8086 microprocessor
Aim:
To write an assembly language program to Sort an array in Descending order

Apparatus Required: 8086 P kit, 12 V power supply.


Algorithm:

Arrange the Numbers in Descending Order


Algorithm:
Step-1: Load the address of the input data in the stack index.
Step-2: Load the count value of the input data.
Step-3: Load the input data for the desired count value.
Step-4: Increment the stack index
Step-5: Compare the stack index to the accumulator.
Step-6: If carry is not exist then decrement the stack index and set required at 0
Step-7: Exchange the accumulator and stack index.
Step-8: If carry is exist then go to step 5 and repeat the process till stack index gets zero.
Step-9: Stop.

9
Experiment No. 3(a):

String Move
Aim:
To write an assembly language program to start a string moving an array of
memory location

Apparatus Required: 8086 P kit, 12 V power supply.


Algorithm:

String Move
Algorithm:
Step-1: Move the length of the string source index address 2000H to SI.
Step-2: Move the length of the string destination index address 2100H to DI.
Step-3: Store the string value in CX register.
Step-4: Store the byte string in a destination memory address.
Step-5: If count = 0 then string go to step 5
Step-6: Move the all data 2000H and 2100H
Step-7: Stop.

10
Experiment No. 3(b):

String Manipulation
Aim:
To write an assembly language program to store a string moving in an array of
memory location

Apparatus Required: 8086 P kit, 12 V power supply.


Algorithm:

String Manipulation
Algorithm:
Step-1: Store the hexadecimal count in CX register
Step-2: Store destination index offset S-array in a memory address
Step-3: Store the string value in accumulator
Step-4: Clear direction flag.
Step-5: Store the byte string in a destination memory address.
Step-6: If count =0 then go next step else go to step 5.
Step-7: Stop.

11
Experiment No. 4:

Square Wave Generator using 8253


Aim:
To write an assembly language program to generate Square Wave using
programmable interval timer 8253

Apparatus Required: 8086 P kit, 8253 programmable interval timer, CRO, 12 V power
supply.
Algorithm:
Step-1: Start the program
Step-2: Load the data into AL register
Step-3: Read the output of the AL to AX register
Step-4: Repeat the above steps 1 and 3
Step-5: Stop.

12
Experiment No.5(a):

Addition of two 16 bit numbers using 8051 Microcontroller


Aim: To write an assembly language program for adding two 16-bit number using 8051
microcontroller.
Apparatus Required: 8051 C kit, 12 V power supply.
Algorithm:
Step-1: Initialize the starting address.
Step-2: Move the first data to a accumulator.
Step-3: Add the second data with accumulator.
Step-4: Move the destination address to data pointer
Step-5: Increment the data pointer.
Step-6: move the third data to accumulator.
Step-7: Add the data with accumulator
Step-8: Move the content to the accumulator.
Step-9: Start jump to starting address.
Step-10: Stop

13
Experiment No.5(b):

Subtraction of two 16 bit numbers using 8051 Microcontroller


Aim: To write an assembly language program for subtract two 16-bit number using 8051
microcontroller.
Apparatus Required: 8051 C kit, 12 V power supply.
Algorithm:
Step-1: Initialize the starting address.
Step-2: Move the first data to a accumulator.
Step-3: Subtract the second data with accumulator.
Step-4: Move the result to the accumulator
Step-5: Increment the data pointer.
Step-6: Move the third data to accumulator.
Step-7: Subtract the fourth data with accumulator
Step-8: Move the content to the accumulator.
Step-9: Start jump to starting address.
Step-10: Stop

14
Experiment No.5(C):

Multiplication of two 8 bit numbers using 8051 Microcontroller


Aim: To write an assembly language program for multiply two 8-bit number using 8051
microcontroller.
Apparatus Required: 8051 C kit, 12 V power supply.
Algorithm:
Step-1: Store the first data in A register.
Step-2: Store the second data in B register.
Step-3: Multiply the two register content A & B.
Step-4: Store the data pointer address as 4500
Step-5: move the content of A register in DPTR address.
Step-6: increment DPTR.
Step-7: Move the content of B register into A register.
Step-8: Repeat all the above steps.
Step-9: Stop

15
Experiment No.5(d):

Division of two 8 bit numbers using 8051 Microcontroller


Aim: To write an assembly language program for divide two 8-bit number using 8051
microcontroller.
Apparatus Required: 8051 C kit, 12 V power supply.
Algorithm:
Step-1: Store the first data in A register.
Step-2: Store the second data in B register.
Step-3: Divide A register content by B register..
Step-4: Store the data pointer address as 4500
Step-5: Move the content of A register into DPTR.
Step-6: Increment the DPTR.
Step-7: Move the content of A register into DPTR address.
Step-8: Repeat all the above steps.
Step-9: Stop

16
Experiment No.6:

Timer and Interrupt using 8051 Microcontroller


Aim: To write an assembly language program for timer and interrupt using 8051
microcontroller.
Apparatus Required: 8051 C kit, 12 V power supply.
Algorithm:
Step-1: Start the program
Step-2: Set the Mode 0 and Mode 1.
Step-3: Set the interrupt enabler
Step-4: Set the timer for high level
Step-5: Set the timer for low level
Step-6: Set the bit for timer 1
Step-7: if > MB is exist, NO clear the mode 1, YES go for over flow of Mode 1
Step-8: Go to vector interrupt so go and perform the specified task
Step-9: Set the vector interrupt address as 5030
Step-10: Get the data in A register
Step-11: Set the DPTR address as 4500
Step-12: move all the content of A register into DPTR address
Step-13: Repeat all the above steps
Step-14: Stop

17
Experiment No.7:

Serial Mode Communication using 8051 Microcontroller and PC


Aim: To write an assembly language program Serial Mode Communication using 8051
Microcontroller and PC using 8051 microcontroller.
Apparatus Required: 8051 C kit, RS232 cable PC, 12 V power supply.
Algorithm:
Step-1: Connect PC and Microcontroller using RS232 Cable
Step-2: In PC , Go to Start All Programs Accessories Communication Hyperterminal
Step-3: Give a name for Hyperterminal and set bitrate as 9600 bits/Second
Step-4: In microcontroller set SM(Serial Mode)
Step-5: In PC press a and press enter, then set the origin as 4100
Step-6: Write the addition of two numbers program in PC
Step-7: Execute the program in PC
Step-8: In microcontroller, by typing U copy the program from PC and execute the program.
Step-9: Verify the output in destination address
Step-10: Stop

18
Experiment No.8:

Interfacing of 8279 to Display a Rolling Word


Aim: To write an assembly language program to display a word or sentence by using 8279
interface for a microprocessor.
Apparatus Required: 8086 p kit, 8279 kit, 12 V power supply.
Algorithm:
Step-1: Initialize the stack index in a memory address
Step-2: Initialize the CX register
Step-3: Store the data in AL register
Step-4: Store the output as AL register counted in CX register
Step-5: Repeat the step3 and step4 for all datas
Step-6: Move the content in SI
Step-7: Set the display time for the data display to set the delay, go to step 10
Step-8: Increment the SI
Step-9: Repeat all the above steps
Step-10: Initialize the DX register
Step-11: Decrement the DX register
Step-12: If decrement is Zero then stop the program else step 11

19

Вам также может понравиться