EC8681 MPMC Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 259

____________________________________________________________________________

Thanthai Periyar Government


Institute of Technology, Vellore
Department of Electronics and
Communication Engineering

Lab Manual

Subject Code: EC8681


Subject Title: Microprocessors and Microcontrollers
Laboratory
Semester : VI
Year : III
Department : Electronics and Communication
Engineering

___________________________________________________________________________________________
____________________________________________________________________________

___________________________________________________________________________________________
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSOR AND MICROCONTROLLERS LABORATORY

OBJECTIVES: The student should be made to:


 To Introduce ALP concepts and features
 Write ALP for arithmetic and logical operations in 8086 and 8051
 Differentiate Serial and Parallel Interface
 Interface different I/Os with Microprocessors
 Be familiar with MASM

LIST OF EXPERIMENTS:
8086 Programs using kits and MASM
1. Basic arithmetic and Logical operations
2. Move a data block without overlap
3. Code conversion, decimal arithmetic and Matrix operations.
4. Floating point operations, string manipulations, sorting and searching
5. Password checking, Print RAM size and system date
6. Counters and Time Delay

Peripherals and Interfacing Experiments


7. Traffic light control
8. Stepper motor control
9. Digital clock
10. Key board and Display
11. Printer status
12. Serial interface and Parallel interface
13. A/D and D/A interface and Waveform Generation

8051 Experiments using kits and MASM


14. Basic arithmetic and Logical operations
15. Square and Cube program, Find 2‟s complement of a number
16. Unpacked BCD to ASCII

TOTAL: 60 PERIODS

OUTCOMES:
At the end of the course, the student should be able to:
 Write ALP Programmes for fixed and Floating Point and Arithmetic
 Interface different I/Os with processor
 Generate waveforms using Microprocessors
 Execute Programs in 8051
 Explain the difference between simulator and Emulator

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 1


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 2


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

CONTENTS

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS USING


8086 7
a) 16 BIT ADDITION (8086) ................................................................................... 7
b) 16 BIT SUBTRACTION (8086) .......................................................................... 11
c) 16 BIT MULTIPLICATION (8086) ...................................................................... 15
d) 16 BIT DIVISION (8086) .................................................................................. 19
2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS USING 8086 . 23
a) 16 BIT AND OPERATION ................................................................................. 23
b) 16 BIT OR OPERATION ................................................................................... 27
c) 16 BIT XOR OPERATION ................................................................................. 31
d) 16 BIT NOT OPERATION ................................................................................. 35
3. MOVE A DATA BLOCK WITHOUT OVERLAP............................ 39
4. CODE CONVERSION TECHNIQUE ........................................... 43
a) BCD TO HEXA DECIMAL ................................................................................ 43
b) HEXA DECIMAL TO BCD ................................................................................ 45
5. DECIMAL ARITHMETIC OPERATIONS .................................... 47
a)ADDITION: ....................................................................................................... 47
b)SUBTRACTION: ................................................................................................ 49
6. MATRIX OPERATIONS ........................................................... 51
a)ADDITION ........................................................................................................ 51
b)SUBTRACTION: ................................................................................................ 55
7. FLOATING POINT OPERATIONS ............................................. 59
a) ADDITION ....................................................................................................... 59
b) SUBTRACTION: ............................................................................................... 61
8. PROGRAMS FOR SORTING AND SEARCHING USING 8086 ...... 63
a) SORTING IN ASCENDING ORDER (8086) ........................................................ 63
b) SORTING IN DESCENDING ORDER (8086)...................................................... 67
c) SEARCHING LARGEST NUMBER IN AN ARRAY ............................................... 71
d) SEARCHING SMALLEST NUMBER IN AN ARRAY............................................. 75

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 3


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

e) SEARCHING A GIVEN DATA IN AN ARRAY ....................................................... 79


9. PROGRAMS FOR STRING MANIPULATION USING 8086........... 85
a) COPYING A STRING OF DATA WORDS ............................................................ 85
b) COPYING A STRING OF DATA BYTES .............................................................. 89
c) EXCHANGING THE DATA STRINGS BETWEEN TWO LOCATIONS.................... 93
d) COMPARING TWO STRINGS ........................................................................... 97
e) MOVING A STRING OF DATA : ....................................................................... 101
f) STRING REVERSAL ........................................................................................ 105
10. WAVEFORMS GENERATION BY INTERFACING A DAC CARD
WITH 8086 MICROPROCESSOR .................................................. 109
11. ADC INTERFACE CARD WITH 8086 ...................................... 117
12. INTERFACING AND PROGRAMMING KEYBOARD DISPLAY
CONTROLLER 8279 USING 8086................................................. 123
a) KEYBOARD SCAN:......................................................................................... 129
b) BLINKING DISPLAY: ..................................................................................... 133
c) ROLLING DISPLAY: ....................................................................................... 137
13. INTERFACING AND PROGRAMMING PROGRAMMABLE
INTERVAL TIMER (Intel 8253) USING 8086 ................................. 141
14. SERIAL COMMUNICATION INTERFACE - UART (Intel 8251)
USING 8086 ................................................................................ 147
15. INTERFACING AND PROGRAMMING OF STEPPER MOTOR
CONTROL USING 8086 ............................................................... 159
a) SPEED CONTROL: ......................................................................................... 163
b) TO RUN IN BOTH FORWARD AND REVERSE: ............................................... 165
c) TO RUN FOR A REQUIRED ANGLE: ............................................................... 169
16. PARALLEL COMMUNICATION BETWEEN TWO
MICROPROCESSOR KITS USING 8255 ........................................ 173
17. PROGRAM FOR DIGITAL CLOCK USING 8086 ...................... 179
18. PROGRAM FOR TRAFFIC LIGHT CONTROL USING 8086 ....... 185
19. PROGRAM FOR PRINTING USING 8086 ................................ 193
20. PASSWORD CHECKING ........................................................ 197
21. SYSTEM DATE ..................................................................... 203
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 4
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

22. DISPLAY RAM SIZE ............................................................. 209


PC PROGRAMMING WITH ASSEMBLY LANGUAGE USING MASM .. 215
23. PROGRAMMING USING ARITHMETIC INSTRUCTIONS OF 8051
MICROCONTROLLER .................................................................. 219
a) 16 BIT ADDITION .......................................................................................... 219
b) 8 BIT SUBTRACTION..................................................................................... 223
c) 8 BIT MULTIPLICATION ................................................................................. 227
d ) 8 BIT DIVISION ............................................................................................ 229
24. PROGRAMMING USING LOGICAL INSTRUCTIONS OF 8051 ... 233
a) 2’S COMPLEMENTA ...................................................................................... 233
b)AND/OR/XOR OPERATION OF TWO 8 BIT DATA ........................................... 237

CONTENT BEYOND SYLLABUS

25. DC MOTOR CONTROL AND SPEED MEASUREMENT ............. 243


26. STUDY OF 8259 PROGRAMMABLE INTERRUPT CONTROLLER ...
.................................................................................. 249

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 5


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 6


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS USING


8086

a) 16 BIT ADDITION (8086)

AIM:

To write and execute an assembly language program for performing the addition
operation of 16 bit numbers with carry.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: Initialize carry register.

Step 5: Add the contents of the two registers

Step 6: If carry is generated increment the carry register.

Step 7: Store the contents of accumulator and carry register in memory.

Step 8: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 7


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 8


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1550H

MOV AX, [SI]

MOV CX, 0000H

ADD AX,
[SI+02]

JNC L1
L1
INC CX

MOV SI, 1700H

MOV [SI], AX
END
MOV [SI+02], CX

HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 9


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 10


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) 16 BIT SUBTRACTION (8086)

AIM

To write and execute an assembly language program for performing the


subtraction operation of 16 bit numbers with borrows.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: Initialize borrow register.

Step 5: Subtract the contents of the register pair from the accumulator.

Step 6: If borrow is generated increment the borrow register.

Step 7: Store the contents of accumulator and borrow register in memory.

Step 8: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 11


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 12


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1400H

MOV AX, [SI]

MOV CX, 0000H

SUB AX, [SI+02]

JNC L1

L1 INC CX

MOV SI, 1600H

MOV [SI], AX

MOV [SI+02], CX

MOV AH, 4CH

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 13


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 14


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) 16 BIT MULTIPLICATION (8086)

AIM:

To write and execute an assembly language program for performing the


multiplication operations of 16 bit numbers with carry.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Move the first data into the accumulator.

Step 3: Move the second data in some register pair

Step 4: Multiply the contents of the register pair by the content of the accumulator

Step 5: Store the contents of accumulator in memory.

Step 6: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 15


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 16


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AX, 000FH

MOV BX, 0002H

MOV CX, 0000H

MUL BX

JNC L1

INC CX

L1 MOV SI, 1200H

MOV [SI], AX

INC SI

INC SI

MOV AX, CX

MOV [SI], AX

MOV [SI+02], CX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 17


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 18


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

d) 16 BIT DIVISION (8086)

AIM:

To write and execute an assembly language program for performing 16 bit


division.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: Divide the contents of the register pair by the content of the accumulator

Step 5: Store the contents of accumulator in memory.

Step 6: Store the quotient in memory

Step 7: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 19


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 20


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRES LABEL MNEMONICS


S

1000 START MOV SI, 1500H

MOV AX, [SI]

MOV CX, [SI+2]

DIV CX

MOV [SI+04], AX

MOV [SI+06], DX

END HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 21


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the assembly language programs for the addition, subtraction,


multiplication & division using 8086 were done and the results were verified.

VIVA QUESTIONS

1. Explain the logic behind the programs for arithmetic operations.

2. What is the max size of memory that can be connected with 8086
microprocessor?

3. What are the general purposes registers available in 8086?


4. What are the functional units in 8086 and state the purpose of each unit.
5. Mention the index registers of 8086 and their use.
6. What is the use of IP & base pointer register?
7. What are the 8086 instructions used for BCD arithmetic?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 22


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS USING 8086

a) 16 BIT AND OPERATION

AIM:

To write and execute an assembly language program for performing the logical AND
operation of 16 bit numbers.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: AND the contents of the two registers

Step 5: Store the contents of accumulator in memory.

Step 6: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 23


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 24


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AX,[3000h]

MOV BX,[3002h]

AND AX,BX

MOV SI,3100h

MOV [SI],AX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 25


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 26


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) 16 BIT OR OPERATION

AIM:

To write and execute an assembly language program for performing the logical OR
operation of 16 bit numbers.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: OR the contents of the two registers

Step 5: Store the contents of accumulator in memory.

Step 6: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 27


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 28


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AX,[3000h]

MOV BX,[3002h]

OR AX,BX

MOV SI,3100h

MOV [SI],AX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 29


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 30


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) 16 BIT XOR OPERATION

AIM:

To write and execute an assembly language program for performing the logical XOR
operation of 16 bit numbers.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the first data into the accumulator.

Step3: Move the second data in some register pair

Step 4: XOR the contents of the two registers

Step 5: Store the contents of accumulator in memory.

Step 6: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 31


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 32


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AX,[3000h]

MOV BX,[3002h]

XOR AX,BX

MOV SI,3100h

MOV [SI],AX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 33


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 34


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

d) 16 BIT NOT OPERATION

AIM:

To write and execute an assembly language program for performing the logical NOT
operation of 16 bit number.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Start

Step 2: Move the data into the accumulator.

Step 3: Perform NOT operation of the contents of the accumulator

Step 4: Store the contents of accumulator in memory.

Step 5: Terminate the process

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 35


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 36


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS COMMENTS

1000 START MOV AX,[3000h]

NOT AX

MOV SI,3100h

MOV [SI],AX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the assembly language programs for the logical AND, OR, XOR and NOT
using 8086 were done and the results were verified.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 37


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 38


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

3. MOVE A DATA BLOCK WITHOUT OVERLAP


AIM:

To move block of data from one location into another location without overlap.

ALGORITHM:

Step 1: Initialize source and destination pointers and count register.

Step 2: Move data from source to destination for count stored.

Step 3: Halt the program.

PROGRAM:
ADDRESS LABEL MENMONICS

1000 Start ORG 1000H

MOV SI,1100h

MOV DI,1200h

MOV CX,05h

L1: MOV AX,[SI]

MOV [DI],AX

INC SI

INC SI

INC DI

INC DI

LOOP L1

Stop HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 39


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 40


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus the assembly language programs to transfer a data block without overlap
using 8086 was done and the results were verified

INPUT:
1100 :01(LSB)
00(MSB)
02
00
03
00
04
00
05
06
OUTPUT:
1200 :01(LSB)
00(MSB)
02
00
03
00
04
00
05
06

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 41


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 42


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

4. CODE CONVERSION TECHNIQUE

a) BCD TO HEXA DECIMAL

AIM:

To convert the hexadecimal number into its equivalent decimal (BCD) value.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Initialize in memory pointer to store the output.


Step2: Load the data in AL register.
Step 3: Separate higher nibbles to lower nibbles.
Step 4: Move the higher nibbles to lower nibbles position.
Step 5: Multiply AL by10.
Step 6: Add lower nibble.
Step 7: Store the result.

PROGRAM:

BCD TO HEXA DECIMAL

ADDRESS LABEL MENMONICS

1000 Start MOV AL,[1200]

MOV AL,BL

AND AH,OF

MOV BL,AH

AND AL,OFO

MOV CL,04

MOV AL,BL

MUL BH

ADD AL,BL

MOV [1400],AL

Stop HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 43


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 44


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) HEXA DECIMAL TO BCD

AIM:

To convert the given BCD number into its equivalent hexadecimal number.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Move the BCD number to BL register.

Step 2: Clear the accumulator.

Step 3: Increment AL register and decimal adjust accumulator after every increment.

Step 4: Decrement BL

Step 5: If BL equals zero, store the contents to destination else goto Step 3.

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 Start MOV BL,[1350]

L1 MOV AX,0000

ADD AL,01

DAA

DEC BL

JNZ L1

MOV [1300],AX

Stop HLT

Result:

Thus the program to convert hexadecimal to BCD and BCD to hexadecimal are
written and verified for 8086.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 45


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 46


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

5. DECIMAL ARITHMETIC OPERATIONS

a)ADDITION:

AIM:
To perform a addition operations between two decimal numbers.

APPARATUS REQUIRED:
8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Get the two numbers from mentioned address using MOV instruction.
Step 2: Add the two values and use decimal adjust after addition.
Step 3: Store the result.

PROGRAM:
ADDRESS LABEL MNEMONICS

1000 Start MOV SI,1100h

MOV AL,[SI]

INC SI

MOV BL,[SI]

ADD AL,BL

DAA

INC SI

MOV [SI],AL

Stop HLT

RESULT:
Thus the program to add two decimal numbers is written and verified using
8086 kit.

INPUT
1100 : 05
1101 : 06
OUTPUT
1102 : 11

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 47


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 48


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b)SUBTRACTION:

AIM:
To perform a subtraction operations between two decimal numbers.

APPARATUS REQUIRED:
8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Get the two numbers from mentioned address using MOV instruction.
Step 2: Subtract the two values and use decimal adjust after subtraction.
Step 3: Store the result.

PROGRAM:
ADDRESS LABEL MNEMONICS
1000 Start MOV SI,1100h
MOV AL,[SI]
INC SI
MOV BL,[SI]
SUB AL,BL
DAS
INC SI
MOV [SI],AL
Stop HLT

RESULT:
Thus the program to subtract two decimal numbers is written and verified
using 8086 kit.

INPUT
1100 : 15
1101 : 07
OUTPUT
1102 : 08

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 49


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 50


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

6. MATRIX OPERATIONS

a)ADDITION

AIM:

To perform addition of two 3*3 matrix

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Get the two 3*3 matrices from mentioned address using MOV instructions.

Step 2: ADD two 3*3 matrices The values from two matrices are added one by one
using INC source and destination index.

Step 3: Store the resultant value in the destination address.

PROGRAM:
ADDRESS LABEL MNEMONICS
1000 Start MOV CL,09

MOV SI,1100h

MOV DI,1150h

L1 MOV AL,[SI]

MOV BL,[DI]

ADD AL,BL

MOV [DI],AL

INC DI

INC SI

DEC CL

JNZ L1

Stop HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 51


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 52


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:
Thus the program to add two 3*3 matrices is written and verified using 8086
kit.

INPUT
1100 : 02
1101 : 02
1102 : 02
1103 : 02
1104 : 02
1105 : 02
1106 : 02
1107 : 02
1108 : 02

INPUT
1150 : 02
1151 : 02
1152 : 02
1153 : 02
1154 : 02
1155 : 02
1156 : 02
1157 : 02
1158 : 02

OUTPUT
1150 : 04
1151 : 04
1152 : 04
1153 : 04
1154 : 04
1155 : 04
1156 : 04
1157 : 04
1158 : 04

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 53


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 54


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b)SUBTRACTION:

AIM:

To perform a subtraction operations between two 3*3 matrix

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Get the two 3*3 matrices from mentioned address using MOV instructions.

Step 2: Subtract the two 3*3 matrices. The values from two matrices are subtracted
one by one using INC source and destination index.

Step 3: Store the resultant value in the destination address.

PROGRAM:
ADDRESS LABEL MNEMONICS
1000 Start MOV CL,09

MOV SI,1100h

MOV DI,1150h

L1 MOV AL,[SI]

MOV BL,[DI]

SUB AL,BL

MOV [DI],AL

INC DI

INC SI

DEC CL

JNZ L1

Stop HLT

RESULT:
Thus the program to subtract two 3*3 matrices is written and verified using
8086 kit.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 55


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 56


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INPUT
1100 : 02
1101 : 02
1102 : 02
1103 : 02
1104 : 02
1105 : 02
1106 : 02
1107 : 02
1108 : 02

INPUT
1150 : 02
1151 : 02
1152 : 02
1153 : 02
1154 : 02
1155 : 02
1156 : 02
1157 : 02
1158 : 02

OUTPUT
1150 : 0
1151 : 0
1152 : 0
1153 : 0
1154 : 0
1155 : 0
1156 : 0
1157 : 0
1158 : 0

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 57


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 58


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

7. FLOATING POINT OPERATIONS

a) ADDITION

AIM:

To perform addition between two floating point numbers

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

THEORY:

Conversion of float into hex using Q8 format


FLOATING POINT OPERATION:(Q8 FORMAT)
INPUT:
FLOAT HEX
0.2 0.2*256=51.2D=33H
0.4 0.4*256=102,4D=66H
After addition the resultant hex value is converted into floating value.
OUTPUT:
HEX DECIMAL FLOAT
99 153 153/256=0.6

PROGRAM:
ADDRESS LABEL MNEMONICS
1000 Start MOV AL,66h
MOV BL,33h
ADD AL,BL
MOV SI,1100h
MOV [SI],AL
INC SI
MOV [SI],AH
Stop HLT

OUTPUT:

1100: 99

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 59


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 60


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) SUBTRACTION:

AIM:

To perform subtraction between two floating point numbers

APPARATUS REQUIRED:
8086 Trainer kit, Key board, power supply

THEORY:

Conversion of float into hex using Q8 format


FLOATING POINT OPERATION:(Q8 FORMAT)

INPUT:
FLOAT HEX
0.4 0.4*256=102,4D=66H
0.2 0.2*256=51.2D=33H
Subtract one from another using SUB instruction. The resultant hex value is
converted into floating value

OUTPUT:
HEX DECIMAL FLOAT
33 51 51/256=0.2

PROGRAM:
ADDRESS LABEL MNEMONICS
1000 Start MOV AL,66h
MOV BL,33h
SUB AL,BL
MOV SI,1100h
MOV [SI],AL
INC SI
MOV [SI],AH
Stop HLT

OUTPUT:

1100: 33

1101: 00

RESULT:

Thus the program to add and subtract two floating point numbers were written
in 8086 assembly language and verified.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 61


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 62


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

8. PROGRAMS FOR SORTING AND SEARCHING USING 8086

a) SORTING IN ASCENDING ORDER (8086)

AIM:

To write and execute an assembly language program to sort a given set of


numbers in ascending order

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Store the total number of elements in C registers.

Step 3: Store the data in accumulator

Step 4: Compare the first element with the second element, which is placed after two

bytes.

Step 5: If second element is greater, continue comparison with next data else

exchange both the elements.

Step 6: Decrement the count value

Step 7: Continue until count value becomes zero.

Step 8: Store the contents in memory location.

Step 9: Halt

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 63


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 64


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS COMMENTS

1000 START MOV SI, 1100H

MOV CL, [SI]

DEC CL

L2 MOV SI, 1100H


MOV CH, [SI]

DEC CH

INC SI

L3 MOV AL, [SI]

INC SI

CMP AL, [SI]

JC L4

XCHG AL, [SI]


XCHG AL, [SI-1]
L4 DEC CH

JNZ L3

DEC CL

JNZ L2
END HLT

TABULAR COLUM
INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 65


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 66


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) SORTING IN DESCENDING ORDER (8086)

AIM:

To write and execute an assembly language program to sort a given set of


numbers in ascending order

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Store the total number of elements in C registers.

Step 3: Store the data in accumulator

Step 4: Compare the first element with the second element, which is

placed after two bytes.

Step 5: If second element is smaller, continue comparison with next

data else exchange both the elements.

Step 6: Decrement the count value

Step 7: Continue until count value becomes zero.

Step 8: Store the contents in memory location.

Step 9: Halt

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 67


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 68


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1100H

MOV CL, [SI]

DEC CL
L2
MOV SI, 1100H

MOV CH, [SI]

DEC CH

INC SI
L3
MOV AL, [SI]

INC SI

CMP AL, [SI]

JNC L4

XCHG AL, [SI]

L4 XCHG AL, [SI-1]

DEC CH

JNZ L3

DEC CL

END JNZ L2

HLT

TABULAR COLUMN
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 69
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INPUT OUTPUT

ADDRESS DATA
ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 70


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) SEARCHING LARGEST NUMBER IN AN ARRAY

AIM:

To write and execute an assembly language program to search largest number in a


given array

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Store the total number of elements in CL register.

Step 3: Load the starting address of the array in SI register

Step 4: Load the address of the result in DI register.

Step 5: Increment the array pointer (SI register) and get the first data in
accumulator. Step 6: Decrement the count value and increment SI.

Step 7: Get the next data in BL register and compare the content of AL and BL and
move the

largest to the accumulator.

Step 8: Decrement the count and increment SI, if count is non zero, go to step 7

Step 9: Store the content of the accumulator in the memory pointed by DI.

Step 10: Halt

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 71


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 72


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1100H


MOV DI, 1200H

MOV CL, [SI]

INC SI

MOV AL, [SI]

DEC CL
L2
INC SI

MOV BL, [SI]


CMP AL, BL

JNC L3
L3 MOV AL, BL

DEC CL

JNZ L2

MOV [DI], AL

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 73


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 74


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

d) SEARCHING SMALLEST NUMBER IN AN ARRAY

AIM: To write and execute an assembly language program to search smallest


number in a given array

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Store the total number of elements in CL register.

Step 3: Load the starting address of the array in SI register.

Step 4: Load the address of the result in DI register.

Step 5: Increment the array pointer (SI register) and get the first data in
accumulator.

Step 6: Decrement the count value and increment SI.

Step 7: Get the next data in BL register and compare the content of AL and BL and
move the

smallest to the accumulator.

Step 8: Decrement the count and increment SI, if count is non zero, go to step 7

Step 9: Store the content of the accumulator in the memory pointed by DI.

Step 10: Halt

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 75


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 76


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1100H

MOV DI, 1200H

MOV CL, [SI]

INC SI
MOV AL, [SI]
DEC CL
L2
INC SI

MOV BL, [SI]

CMP AL, BL

JC L3

MOV AL, BL
L3 DEC CL

JNZ L2

MOV [DI], AL
END HLT

TABULAR COLUMN

INPUT OUTPUT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 77


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 78


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

e) SEARCHING A GIVEN DATA IN AN ARRAY

AIM:

To write and execute an assembly language program to search a given data in an


array.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step 1: Start

Step 2: Load the starting address of the array in SI register.

Step 3: Load the starting address of the data in DI register.

Step 4: Get the data to search in DL register.

Step 5: Let BL register keep track of the position. Initialize the position count as one.

Step 6: Get an element of array in AL.

Step 7: Compare the content of AL and DL, if they are equal go to step 11.

Step 8: Increment the array pointer (SI register) and the position count (BL).

Step 9: Get the next element in the array in AL and compare with the end marker
(ex.20H). If they are not equal go to step 7.

Step 10: Clear CX register and store CX register in four consecutive memory
locations after the given data and go to step 12.

Step 11: Move FF to BH and store content of BH, BL and SI in memory.

Step 12: Halt

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 79


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 80


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1100H

MOV DI,1200H

MOV DL, [DI]

MOV BL,01H

MOV AL, [SI]


L2
CMP AL, DL

JZ L4

INC SI

INC BL

MOV AL,[SI]

CMP AL,20H

JNZ L2
L3
MOV CX,0000H

MOV [DI+1],CX

MOV [DI+3],CX

JMP END
L4
MOV BH,0FFH

MOV [DI+1],BH

MOV [DI+2],BL

MOV [DI +3],SI


END
HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 81


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

TABULAR COLUMN

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 82


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus the assembly language programs for the searching & sorting using 8086
were done and the results were verified.

VIVA QUESTIONS

1. Explain the logic behind the programs for sorting and searching operations.

2. What is the purpose of segment register & what are the segment registers in
8086?
3. What are the different flags in 8086 and give their function?
4. How the effective 20 bit address is calculated in 8086 processor?
5. What is the purpose of the following commands in 8086 (i) AAD (ii)RCL
6. Give examples of instructions which are used to affect the flag register?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 83


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 84


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

9. PROGRAMS FOR STRING MANIPULATION USING 8086

a) COPYING A STRING OF DATA WORDS

AIM:

To write and execute an assembly language program to copy a string of data


words from one location to another.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Set SI as a pointer to source location and DI as pointer to destination address,


CX as count register to store the number of data.

Step2: Using move string word instruction moves the data from source location to
destination location.

Step3: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 85


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 86


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 MOV SI,1100H

MOV DI,1200H

MOV CX,COUNT

REP MOVSW

HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 87


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 88


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) COPYING A STRING OF DATA BYTES

AIM: To write and execute an assembly language program to copy a string of data
bytes

from one location to another.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Set SI as a pointer to source location and DI as pointer to destination address,


CX as

count register to store the number of datas.

Step2: Using move string byte instruction move the data from source location to
destination

location.

Step3: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 89


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 90


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI,1100H

MOV DI,1200H

MOV CX,COUNT

REP MOVSB

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA
ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 91


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 92


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) EXCHANGING THE DATA STRINGS BETWEEN TWO LOCATIONS

AIM:

To write and execute an assembly language program to exchange data strings


between two memory locations.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Set SI and DI as pointer to the two addresses, CX as count register to store
the number

of data in the string.

Step2: Move the content of address pointed by SI to AL and the content of address
pointed by

DI to BL.

Step3: Move the content of AL to DI address and the content of BL to SI address .

Step4: Increment SI, DI and decrement count.

Step5: If count is not zero, go to step2

Step6: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 93


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 94


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV CX,COUNT

MOV SI,1200H

MOV DI,1300H

L1 MOV AL,[SI]

MOV BL,[DI]

MOV [DI], AL

MOV [SI], BL

INC SI

INC DI

DEC CX

JNZ L1

END HLT

TABULAR COLUMN

INPUT

ADDRESS DATA

OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 95


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 96


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

d) COMPARING TWO STRINGS

AIM:

To write and execute an assembly language program to compare the data strings

in two memory locations and find the number of equal values in corresponding

location.

APPARATUS REQUIRED:

8086 Trainer kit, Key board, power supply

ALGORITHM:

Step1: Set SI as a pointer to source location and DI as pointer to destination address,


CX as

count register to store the number of datas.

Step2: Using move string byte instruction move the data from source location to
destination

location.

Step3: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 97


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 98


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI, 1100H

MOV DI,1200H

MOV BX,0000H

MOV CX,COUNT

L1 COMPSB

JNZ L2

INC BX

L2 DEC CX

JNZ L1

MOV SI,1300H

MOV [SI],BX

END HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 99


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 100


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

e) MOVING A STRING OF DATA :

AIM:

To write and execute an assembly language program to move a data string from
one

location to another.

APPARATUS REQUIRED:

8086 Trainer kit

ALGORITHM:

Step1: Set SI and DI as pointer to the two addresses, CX as count register to store
the number of datas in the string.

Step2: Move the content of address pointed by SI to AL and and store 00 to BL.

Step3: Move the content of AL to DI address and the content of BL to SI address .

Step4: Increment SI,DI and decrement count.

Step5: If count is not zero, go to step2

Step6: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 101


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 102


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV CX,COUNT


MOV SI,1200H
MOV DI,1300H
L1
MOV AL,[SI]
MOV [DI],AL
MOV BL,00H
MOV [SI],BL
INC SI
INC DI
DEC CX
JNZ L1
HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA
ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 103


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 104


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

f) STRING REVERSAL

AIM:
To write and execute an assembly language program to perform string reversal
using 8086.

APPARATUS REQUIRED:
8086 Trainer Kit.Keyboard,power supply

ALGORITHM:
Step1: Load count in CX register and use SI register to store source address and DI
to store result address.

Step2: Add the content of CX with DI and decrement DI.

Step3: Move the first data using move string byte instruction.

Step4: Decrement 02H from DI register and decrement CX, if it is not a zero go to
step 3.

Step5: Halt.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 105


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 106


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV CX,COUNT


MOV SI,1200H
MOV DI,1300H
ADD DI,CX
DEC DI
L1 MOV SB
SUB DI,02H
LOOP L1
HLT

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus, the assembly language programs for string manipulation using 8086 were
done and the results were verified.

VIVA QUESTIONS:

1. Explain the logic behind the programs for string manipulations

2. What are the different sting manipulation instructions in 8086?


3. What is the purpose of QUEUE in 8086 processor?
4. How the 8086 instructions are grouped?
5. What is register indirect addressing mode?Give examples.
6. Why is the 8086 memory organized in to two banks of even and odd
addresses?
7. What are Tri-state devices?
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 107
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 108


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

10. WAVEFORMS GENERATION BY INTERFACING A DAC


CARD WITH 8086 MICROPROCESSOR

AIM:

To generate different types of waveforms by interfacing a DAC card with


microprocessor trainer kit.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit, DAC Interface Card, 26-pin flat Cable Connector,
CRO with probe

COMPONENT DESCRIPTION:

The Digital to Analog conversion is obtained with a simple R-2R ladder circuit.

The DAC card design involves three sections DAC 800, Current to Voltage circuitry
using Op Amp 741. DAC 800 is a monolithic 8-bit high-speed complimentary current
output DAC. It has a typical settling time of 100 nsec. The digital input to the DAC is
provided through the Port A and Port B of 8255. The reference voltage needed for the
DAC is obtained from a onboard voltage regulator 6A 723. The output from the DAC
vary between 0 to 5 V corresponding to values between 00 to FF H. Different types of
waveforms can be observed at the op-amp output depending upon the digital input
pattern.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 109


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

BLOCK DIAGRAM:

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 110


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PIN DIAGRAM: DAC 0800

MODEL GRAPH:

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 111


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ALGORITHM:

Square wave:

Step1: Start

Step2: Move the low value to the DAC address and call delay

Step3: Move the high value to the DAC address and call delay.

Step4: Go to step2

Triangular wave:

Step1: Start

Step2: Move the low value to the DAC address and start incrementing and move

each data to DAC address until it becomes zero.

Step3: Move the high value to the DAC address and start decrementing and move
each data

to DAC address until it becomes zero.

Step4: Go to step2

Saw tooth wave:

Step1: Start
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 112
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

Step2: Move the low value to the DAC address and start incrementing and move each
data to

DAC address until it becomes zero.

Step3: Go to step2

DAC INPUT AND OUTPUT:

Corresponding
Input data in Hex Output voltage in volts

00 -5.00
7F 0.00
FF +5.00

PORT ADDRESS:

PORT ADDRESS

DAC1 C0

DAC2 C8

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 113


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAMS:

SQUARE WAVE GENERATION

ADDRESS LABEL MNEMONICS

1000 START MOV AL,00

OUT C8,AL

CALL DELAY

MOV AL,FF

OUT C8,AL

CALL DELAY

JMP START

DELAY MOV CX,COUNT

L1 DEC CX

JNZ L1

RET

TABULAR COLUMN

Delay Count Amplitude Time Period


Time Value (volts) (ms)

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 114


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

DELAY CALCULATION:

Reqd. delay Time = no. of T-states outside the loop + (no. of T-states inside the
loop *

count)

MOV CX, COUNT = 4T

L1: DEC CX =2T

JNZ L1 =16T/4T

RET =8T

= 12T+ (18T * count – 12T)

Where T = 1/ Clock frequency =1/4.77MHz

TRIANGULAR WAVE GENERATION

ADDRESS LABEL MNEMONICS

1000 START MOV BL,00

L1
MOV AL,BL
OUT C8,AL
INC BL
JNZ L1
MOV BL,FF

L2
MOV AL,BL
OUT C8,AL
DEC BL
JNZ L2
JMP START

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 115


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

TABULAR COLUMN:

Amplitude(v) Time
Period(ms)

SAW TOOTTH WAVEFORM GENERATION

ADDRESS LABEL MNEMONICS

1000 START MOV AL,00

L1 OUT C8,AL

INC AL

JNZ L1

JMP START

TABULAR COLUMN:

Amplitude(v) Time
Period(ms)

RESULT:

Thus the programs for various wave form generation using were written,
executed and the results were verified.

VIVA QUESTIONS
1. Explain the logic behind the programs using DAC.
2. What are the different I/O port instructions in 8086?
3. Give some conditional jump instructions of 8086?
4. What are addressing modes? What are the different addressing modes in 8086?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 116


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

11. ADC INTERFACE CARD WITH 8086


AIM:

To convert an analog quantity into equivalent digital value by interfacing an ADC


card with the microprocessor trainer kit and to display the digital data obtained in
the seven segment display available in the kit.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit, 26-pin flat Cable Connector, ADC Interface
card, Multimeter, potentio meter

COMPONENT DESCRIPTION:

Most of the real time systems give only analog outputs. To process these signals
using Microprocessor based systems, it is necessary to convert the analog signals to
digital signals. This can be done by either using Analog-to-Digital converters or by
an alternative scheme utilizing a Digital-to-Analog converter and either successive
approximation or counter algorithm implemented in software.
ADC 0809 is a monolithic CMOS device with an 8-bit ADC & channel
multiplier of microprocessor compatible logic. The main features are

 8 bit resolution

 100 µs conversion time

 Low power consumption

 A particular input channel is selected by using decoder. The address is


launched in to decoder on the low to high transition of ALE signal.

The conversion begins on the falling edge of SOC.EOC will go low to indicate
that the conversion is over. Once the conversion is over, the digital data is read from
the SAR register.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 117


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INTERFACING DIAGRAM OF ADC WITH MICROPROCESSOR

PORT ADDRESS:

Content Address

Channel 0 E0
SOC D0
EOC D8
SAR C8

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 118


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PIN DIAGRAM ADC 0809

SELECTION OF CHANNEL:

SELECTED ADDRESS LINE


ANALOG SIGNAL
ADD A ADD B ADD C

IN0 0 0 0
IN1 0 0 1
IN2 0 1 0
IN3 0 1 1
IN4 1 0 0
IN5 1 0 1
IN6 1 1 0
IN7 1 1 1

RESULT VERIFICATION:

V=VREF [L8/21+ L7/22+ L6/23+ L5/24+ L4/25+ L3/26+ L2/27+ L1/28]

VREF=4.63Volts

ALGORITHM:

Step1:Start

Step2:Initialize channel 0 by moving the respective control words

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 119


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

Step3:Set the ALE & SOC pins to high.

Step4:Find whether the conversion is over by checking EOC pin.

Step 5: Read the digital data from SAR register and move it to some location.

Step: Halt

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AL,00


OUT EO,AL
MOV AL,O8
OUT E0,AL
MOV AL,01
OUT ODO,AL
MOV AL,00
OUT ODO,AL
XX
IN AL, 0D8
AND AL,O1
CMP AL,O1
JNZ XX
IN AL,OC8
MOV [4000],AL
END HLT

TABULAR COLUMN:

Analog Digital
input L8 L7 L6 L5 L4 L3 L2 L1 output
voltage
(Volts)
0.5
1
1.5
2
2.5
3
3.5
4
4.5

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 120


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus the program for the conversion of analog voltage in to digital value using
8086 & ADC is written, executed and the result is verified.

VIVA QUESTIONS

1. Explain the logic behind the program using ADC.

2. What are the three modes in which ADC can be interfaced with
microprocessor?

3. What are EOC and SOC?


4. What is the function of SAR register?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 121


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 122


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

12. INTERFACING AND PROGRAMMING KEYBOARD DISPLAY


CONTROLLER 8279 USING 8086
AIM:

To write an assembly language program (1) to display the given message in


rolling fashion (2) blinking fashion; (3) to read a key-press from the keyboard and to
display the key-pressed in the seven segment display.

APPARATUS REQUIRED:

Intel 8086 Trainer Kit, 8279 Keyboard Display interface

COMPONENT DESCRIPTION:

Intel 8279 is a dedicated controller specially developed for keyboard / display


interfacing in 8085/ 8086 / 8088 microprocessor based systems. The 8279 provide
an interface of maximum 64 contact key matrix. Keyboard entries are automatically
debounced and stored in internal FIFO RAM. It generates an interrupt signal for each
key entry, to inform the processor to read the key-code from FIFO. It also provides an
interface a maximum number of Sixteen (16) Seven-segment display. To control the
display, the 8279 supports 16-byte display RAM. The CPU has to load the display
codes in this RAM. Once data is loaded, 8279 takes care of the display and
refreshing.

PIN DIAGRAM

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 123


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

The following commands, program the 8279 operating modes:

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 124


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

An internal prescaler generates all the timings and multiplexing signals for
the 8279. This Prescaler divides the external clock by a programmable integer. Bits
PPPPP determine the value of this integer, which ranges from 2 to 31. Choosing a
divisor that yields 100 KHz will give specified scan and debounce timings.

The CPU sets up the 8279 for a read of the FIFO / Sensor Ram by first writing this
command.
AI – Auto Increment Flag; X – Don’t care; A A A – Address Bits

The CPU sets up the 8279 for a read of the Display RAM by first writing this
command. The address bits A A A A select one of the 16 rows of the display RAM. If
the AI flag is set, this row address will be incremented automatically after each read
from the display RAM.

The CPU sets up the 8279 for a write to the Display RAM by first writing this
command. The address bits A A A A select one of the 16 rows of the display RAM. If
the AI flag is set, this row address will be incremented automatically after each write
to the display RAM.

The IW bits can be used to mask nibble A and nibble B in applications requiring
separate 4-bit display ports. By setting the IW flag for one of the ports, the port
becomes masked, so that the entries to the display RAM from the CPU do not affect

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 125


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

the port. If the user wishes to blank the display, the BL flags are available for each
nibble. The last CLEAR command issued determines the codes to be used as ‘blank’.

7. CLEAR DISPLAY

The Cd bits are available in this command to clear all the rows of the display
RAM to a selectable blanking code as follows.
If the Cf bit is asserted, the FIFO status is cleared and the interrupt output is
reset.
Ca, the Clear All bit has the combined effect of Cd and Cf. It uses the Cd clearing
code on the display RAM and also clears the FIFO status.

For the sensor matrix mode, this command lowers the IRQ line and enables further
writing into the RAM. For N-key roll over mode, if the E bit is programmed to ‘1’ the
chip will operate in the special error mode.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 126


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

9. FIFO Status
FIFO status is used in the keyboard and strobed input mode to indicate the
number of characters in the FIFO and to indicate whether an error has occurred

BLOCK DIAGRAM

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 127


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PORT ADDRESS

REGISTER ADDRESS

Control/
Status reg. C2

Data reg. C0

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 128


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

a) KEYBOARD SCAN:

ALGORITHM

Step1:Start

Step2:Initialize the count in CX register.

Step3: Initialize the Key Board Display control word.

Step4: Initialize the Clear Display control word

Step 5: Initialize Write Display control word

Step6: Clear Display by sending FF and repeat this until the key is pressed.

Step7: Check for key press from the status word

Step8: If key is pressed, initialize FIFO sensor RAM and get the content of data
register to

AL registers.

Step 9: Using Look Up Table Display the pressed key value by sending the value
through

data register.

Step10: Stop.

CONTROL WORD FORMATION:

1) Keyboard/display mode:

0 0 0 0 0 0 0 0
=00H

2) Clear display:

1 1 0 0 1 1 0 0
=CCH

3) Write display RAM:

1 0 0 1 0 0 0 0
=90H

4) Read FIFO sensor RAM:

0 1 0 0 0 0 0 0
=40H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 129


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

5) FIFO status word:

0 0 0 0 0 1 1 1
=07H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 130


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV CX,0008


MOV AL,00
OUT C2,AL
MOV AL,OCC
OUT C2,AL
MOV AL,90
OUT C2,AL
MOV AL,0FH

L1
OUT C0,AL
LOOP L1

L2
IN AL,C2
TEST AL,07
JZ L2
MOV AL, 40
OUT C2,AL
IN AL,C2
AND AL,0F
MOV BL,AL
MOV BH,12
MOV AL,[BX]
OUT C0,AL
JMP L2
END
HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 131


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

LOOK UP TABLE:

Address d c b a dp g f e Hex Letter


code
1200 0 0 0 0 1 1 0 0 0C 0
1201 1 0 0 1 1 1 1 1 9F 1
1202 0 1 0 0 1 0 1 0 4A 2
1203 0 0 0 0 1 0 1 1 0B 3
1204 1 0 0 1 1 0 0 1 99 4
1205 0 0 1 0 1 0 0 1 29 5
1206 0 0 1 0 1 0 0 0 28 6
1207 1 0 0 0 1 1 1 1 8F 7
1208 0 0 0 0 1 0 0 0 08 8
1209 0 0 0 0 1 0 0 1 09 9
120A 1 0 0 0 1 0 0 0 88 A
120B 0 0 1 1 1 0 0 0 38 B
120C 0 1 1 0 1 1 0 0 6C C
120D 0 0 0 1 1 0 1 0 1A D
120E 0 1 1 0 1 0 0 0 68 E
120F 1 1 1 0 1 0 0 0 E8 F

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 132


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) BLINKING DISPLAY:

ALGORITHM

Step1: Start

Step2: Move the address of the Look Up Table to source index register.

Step3: Initialize all the control words ie, Key Board Display, Clear Display and Write
display

RAM.

Step4: Move the count to CX register.

Step 5: Move all the data from look up table to display one by one.

Step6: Call Delay

Step7: Go to step 1.

CONTROL WORD FORMATION:

1) Keyboard/display mode:

0 0 0 0 0 0 0 0
=00H

2) Clear display :

1 1 0 0 1 1 0 0
=CCH

3) Write display RAM:

1 0 0 1 0 0 0 0
=90H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 133


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV SI,1200


MOV AL,00
OUT C2,AL
MOV AL,0CC
OUT C2,AL
MOV AL,90
OUT C2,AL
MOV CX,0006
L1
MOV AL,[SI]
OUT C0,AL
INC SI
LOOP L1
CALL DELAY
MOV AL,00
OUT C2,AL
MOV AL,0CC
OUT C2,AL
MOV AL,90
OUT C2,AL
MOV CX,0006
MOV AL, FF
L2 OUT C0,AL
LOOP L2
CALL DELAY
JMP START
DELAY MOV DX,0FFFF
L3 DEC DX
JNZ L3
RET

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 134


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

LOOK UP TABLE:

Address Hex value Character


1200 98 H
1201 68 E
1202 7C L
1203 C8 P
1204 FF -
1205 1C U
1206 29 S

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 135


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 136


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) ROLLING DISPLAY:

ALGORITHM

Step1: Start

Step2: Move the address of the Look Up Table to source index register.

Step3: Initialize all the control words ie, Key Board Display, Clear Display and Write
display

RAM.

Step4: Move the count to CX register.

Step 5: Move data pointed by source index from look up table to display.

Step6: Call Delay

Step7: Increment source Index register and decrement count.

Step7: Go to step 1.

CONTROL WORD FORMATION:

1) Keyboard/display mode:

0 0 0 0 0 0 0 0
=00H

2) Clear display:

1 1 0 0 1 1 0 0
=CCH

3) Write display RAM:

1 0 0 1 0 0 0 0
=90H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 137


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM

ADDRESS LABEL MNEMONICS

1000 STRAT MOV SI,1200


MOV CX,000F
MOV AL,10
OUT C2,AL
MOV AL,0CC
OUT C2,AL
MOV AL,90
OUT C2,AL
L1
MOV AL,[SI]
OUT CO,AL
CALL DELAY
INC SI
LOOP L1
JMP START

DELAY MOV DX,0FFFF


L2 DEC DX
JNZ L2
RET

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 138


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

LOOK UP TABLE:

Address Hex value Character


1200 98 H
1201 68 E
1202 7C L
1203 C8 P
1204 FF -
1205 1C U
1206 29 S
1207 FF -
1208 FF -
1209 FF -
120A FF -
120B FF -
120C FF -
120D FF -
120E FF -
120F FF -

RESULT:

Thus the programs for the key board display interface (8279) with 8086 is written,
executed and the result is verified.

VIVA QUESTIONS

1. Explain the logic behind the program using 8279.


2. What are the functions of Keyboard and display controller 8279?
3. What are the features of 8279?
4. What are the display modes supported by the 8279 chip?
5. What is 2 key lockout and n key rollover?
6. What is key debouncing? Mention the types.
7. What are the different modes possible with the Key board section of 8279.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 139


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 140


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

13. INTERFACING AND PROGRAMMING PROGRAMMABLE


INTERVAL TIMER (Intel 8253) USING 8086
AIM:

To generate square waveforms by programming the Programmable Interval Timer


(8253) in it’s various modes of operation.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit, 8253 Interface, CRO with Probe

COMPONENT DESCRIPTION:

Intel 8253 is a programmable interval timer. It generates accurate time delays


and can be used for applications such as real time clock, an event counter, a digital
one-shot, and a square wave generator. It is organized as three independent 16-bit
counters, each with a count rate up to 2 MHz. These counters are identical in
operation. Each counter consists of a single 16-bit down counter. The counter can
operate in either binary or BCD and its input, gate and output are configured by the
selection of modes stored in the control word register.

These counters can be operated in any one of the six operating modes. To operate a
counter, a 16-bit count is loaded in its register and on command it begins to
decrement the count until it reaches zero.

At the end of the count it generates a pulse.

Modes of Operation:

Mode 0: Interrupt on Terminal count:

The output will be initially low after the mode set operation. After the count is loaded
into the selected count register the output will remain low and the counter will
count. When terminal count (0000) is reached the output will go high and remain
high until the selected count register is reloaded with the mode or a new count is
loaded.

Mode 1: Programmable One shot:

The output will go low on the count following the rising edge of the gate input. The
output will go high on the terminal count. If a new count is loaded while the output
is low it will not affect the duration of the one shot pulse until the succeeding trigger.

Mode 2: Rate Generator: 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.
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 141
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

Mode 3: Square wave Generator:

The output will remain high until one half of the count has been completed and go
low for the other half of the count. When the counter reaches terminal count the
state of the output is changed and the counter is reloaded with the full count and the
whole process is repeated.

Mode 4: Software Triggered Strobe:

After the mode is set the output will be high. When the count is loaded the counter
will begin counting. On terminal count the output will go low for one input clock
period then will go high again.

Mode 5: Hardware Triggered Strobe:

The counter will start counting after the rising edge of the trigger input and will go
low for one clock period when the terminal count is reached.

BLOCK DIAGRAM

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 142


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PORT ADDRESS

PIN DIAGRAM 8253

MODEL GRAPH

CONTROL WORD FORMATION

COUNTER0:

0 0 1 1 0 1 1 0
=36H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 143


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

COUNTER1:

0 1 1 1 0 1 1 0
=76H

COUNTER2:

1 0 1 1 0 1 1 0
=B6H

ALGORITHM

Step1: Start

Step2: Move the control word to control register.

Step3: Move the count to the corresponding counter.

Step4: Stop.

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AL, 36


OUT CE,AL
MOV AL, COUNT
OUT C8,AL
MOV AL,00
OUT C8, AL
HLT
END

TABULAR COLUMN:

Reqd.frequency count Amplitude(v) Time Obtained


period(µs) frequency

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 144


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

COUNT CALCULATION:

Count=Input clock frequency/Required output frequency

Input frequency=1500khz

RESULT:

Thus the program for square wave generation using 8253 timer is written,
executed and the result is verified.

VIVA QUESTIONS

1. Explain the logic behind the program using 8253.


2. List the operating modes of 8253 timer and their applications.
3. Give the control word format of 8253 timer?
4. What are the applications of 8253?
5. Give the salient features of 8254 Programmable Interval Timer.
6. Which mode of 8253 is used for square wave generation? How?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 145


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 146


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

14. SERIAL COMMUNICATION INTERFACE - UART (Intel 8251)


USING 8086
AIM:

To program the Programmable Communication Interface (8251) to transmit data


serially between two microprocessors.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit, Interface Card for 8251 and 8253, and RS232C Cable

COMPONENT DESCRIPTION

Intel 8251 Universal Synchronous / Asynchronous Receiver / Transmitter


(USART) is designed for synchronous and asynchronous serial data communications
with Intel’s family of microprocessors. The USART accepts data characters from the
CPU in parallel format and then converts them into a continuous serial data stream
for transmission. Simultaneously, it can receive serial data streams and convert
them into parallel data characters for the CPU. The USART will signal the CPU
whenever it can accept a new character for transmission or whenever it has received
a character for the CPU.

To implement serial communication, the CPU must inform the 8251 of all details
such as mode, baud, stop bits, parity etc. Therefore prior to data transfer, a set
control words must be loaded into the control register of the 8251. In addition, the
CPU must check the readiness of a peripheral by reading the status register. The
control word is divided into two formats: Mode word and Control word. The mode
specifies the general characteristics of operation (such as baud, parity, number of
stop bits), the command word enables data transmission and / or reception, and the
status word provides the information concerning register status and transmission
errors.

To initialize the 8251 in the asynchronous mode, a sequence of control words must
be followed. After a Reset operation (system reset or through instruction), a mode
word must be written in the control register followed by a command word. Any
control word written into the control register immediately after a mode word will be
interpreted as a command word. However, the 8251 should be reset prior to writing a
new mode word, and it can be reset by using the Internal Reset bit (D6) in the
command word.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 147


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

CONTROL WORDS FORMAT

MODE WORD (ASYNCHRONOUS MODE)

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 148


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

COMMAND WORD

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 149


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

STATUS WORD

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 150


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INTERFACE BLOCK DIAGRAM

PIN DIAGRAM

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 151


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 152


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ALGORITHM

TRANSMITTER

Step1: Start

Step2: Move the address of the data to be transmitted to source index register.

Step3: Initialize the control words for 8253 (for clock) and 8251.

Step4: Move the count (number of data) to CL register.

Step 5: Check Tx Empty bit of status word, if it is set send the data to USART.

Step6: Increment source Index register and decrement count, if it is non zero jump to
step 5

Step7: stop.

ALGORITHM

RECEIVER

Step1: Start

Step2: Move the address where the data to be stored to source index register.

Step3: Initialize the control words for 8253 (for clock) and 8251.

Step4: Move the count (number of data) to CL register.

Step 5: Check Rx Rdy bit of status word, if it is set read the data from USART.

Step6: Increment source Index register and decrement count, if it is non zero jump to
step 5

Step7: stop.

CONTROL WORD FORMATION

CONTROL WORD (8253)

0 0 1 1 0 1 1 0
=36H

COMMAND WORD (8251) TRANSMITTER

0 1 0 0 0 0 0 0
=40H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 153


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

MODE WORD (8251)

0 1 0 0 1 1 1 0
=4EH

COMMAND WORD (8251) RECEIVER

0 0 1 1 0 1 1 1
=37H

PORT ADDRESS

8253 8251

PORT ADDRESS
PORT ADDRESS
CONTROL 16
CONTROL/STATUS 0A
REG
REG
08
COUNTER0 10
DATA REG
COUNTER1 12

COUNTER2 14

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 154


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

TRANSMITTER

ADDRESS LABEL MNEMONICS

1000 START MOV SI,1500H

MOV AL,36
OUT 16,AL
MOV AL,40
OUT 10,AL
MOV AL,01
OUT 10,AL

LOAD
MOV CL,COUNT
L1 IN AL,OA
AND AL,O4
JZ L1
MOV AL,[SI]
OUT 08,AL
INC SI
CMP AL,3F
JNZ LOAD
DEC CL
JNZ L1
HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 155


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RECEIVER

ADDRESS LABEL MNEMONICS

1000 START MOV SI,1500H

MOV AL,36
OUT 16,AL
MOV AL,40
OUT 10,AL
MOV AL,01
OUT 10,AL
LOAD
MOV CL,COUNT
L1 IN AL,OA
AND AL,O2
JZ L1
IN AL,08
MOV [SI],AL
INC SI
CMP AL,3F
JNZ LOAD
DEC CL
JNZ L1
HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 156


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

TABULAR COLUMN

TRANSMITTER µP RECEIVER µP

ADDRESS DATA ADDRESS DATA

RESULT:
Thus program for the transmission and reception of a set of data between two
microprocessors using UART is written, executed and the result is verified.

VIVA QUESTIONS

1. Explain the logic behind the program using 8251 for serial data transfer.
2. What is baud rate?
3. What is TXD and RXD?
4. How to initialize data transfer in 8251?
5. State different control words and their use.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 157


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 158


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

15. INTERFACING AND PROGRAMMING OF STEPPER MOTOR


CONTROL USING 8086
AIM:

To interface a stepper motor with the microprocessor trainer kit and to write an
assembly language program to rotate the stepper motor in clock-wise direction and
anti-clockwise direction.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit, Stepper motor Interface, Stepper motor, and 26-pin flat
ribbon cable.

COMPONENT DESCRIPTION:

Stepper motor control is very popular application of microprocessors in control area,


as stepper motors are capable of accepting pulses directly from the microprocessor
and act accordingly. There are two types of stepper motors: Permanent magnet
stepper motor and Variable reluctance stepper motor.

A practical permanent magnet stepper motor will have 1.8° step angle and fifty (50)
tooth on its rotor. There are eight (8) main poles and four windings on the stator
having five (5) teeth in the pole face. Permanent magnet stepper motors have three
mode of excitation. (1) Single phase mode – in which only one of the motor windings
is excited at a time, (2) Two phase mode - Both the stator phases are excited at a
time, and (3) Hybrid mode – a combination of single phase and two phase motors.

The Stepper motor available is a reversible stepper motor with a torque of 3kgcm.
The power requirement is ±12V DC @ 1.2 A current per winding at full torque. The
step angle is 1.8° (for every single excitation, the motor shaft rotates by 1.8°). The
stepper motor interface uses four transistor pairs (SL 100 & SN 3055) in a Darlington
pair configuration. Each Darlington pair is used to excite the particular winding of
the motor connected to 4-pin connector on the interface. The inputs to these
transistors are from 8255 PPI I/O lines of a microprocessor trainer kit.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 159


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 160


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PORT ADDRESS

PORT ADDRESS

DATA LATCH 1 C0

DATA LATCH 2 C8

STEPPING SEQUENCE

CLOCK WISE ANTICLOCKWISE


Step A1 A2 A3 A4 HEX Step A1 A2 A3 A4 HEX
1 1 0 0 0 08 1 1 0 0 0 08
2 0 0 1 0 02 2 0 0 0 1 01
3 0 1 0 0 04 3 0 1 0 0 04
4 0 0 0 1 01 4 0 0 1 0 02

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 161


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 162


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

a) SPEED CONTROL:

SPEED CALCULATION:

 Step angle = 1.8

 Number of steps in one rotation=360/1.8

=200steps/rotation

 For speed =20rpm,

20 rotation=1min

20*200steps=60 sec

1 step=60/20*200=15msec

15msec=12T+ (18T*COUNT-12T)

T=1/clock frequency

ALGORITHM

Step1: Start

Step2: Move the address of the stepping sequence to destination index register.

Step3: Move the count (number of data in the stepping sequence) to CL register

Step4: Move the data in the stepping sequence to the data latch of stepper interface.

Step5: Call delay

Step6: Increment destination Index register and decrement count, if it is non zero
jump to

step

Step7: Go to step 1

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 163


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS COMMENTS

1000 START MOV DI,1200

L1 MOV CL,04
MOV AL,[DI]
OUT CO,AL
CALL DELAY
INC DI
LOOP L1
JMP START
1500 DELAY
MOV DX,COUNT
L2
DEC DX
JNZ L2
RET

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 164


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) TO RUN IN BOTH FORWARD AND REVERSE:

COUNT CALCULATION

For 360 degrees(for one full rotation),no. of steps is 200

Therefore, for 180 deg,

=200/360*180=100=64H

Count = 64/4=16H

ALGORITHM

Step1: Start
Step2: Move the count to BL register
Step3: Move the address of the forward stepping sequence to destination index
register.
Step4: Call Rotate sub program
Step5: Decrement count, if it is non zero jump to step 3
Step6:Call delay
Step7: Move the count (number of data in the stepping sequence) to BL register
Step8: Move the address of the reverse stepping sequence to destination index
register.
Step9: Call Rotate sub program
Step10: Decrement count, if it is non zero jump to step 3
Step11: Call delay
Step12: Go to step 1

ROTATE

Step3: Move the count (number of data in the stepping sequence) to CL register
Step4: Move the data in the stepping sequence to the data latch of stepper interface.
Step5: Call delay
Step6: Increment destination Index register and decrement count, if it is non zero
jump to
step 4
Step7: Return to main program

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 165


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 166


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM

ADDRESS LABEL MNEMONICS COMMENTS

1000 START MOV BL, 16


FWD MOV DI,1200
CALL ROTATE
DEC BL
JNZ FWD
CALL DELAY
MOV BL, 16
REV MOV DI,1300
CALL ROTATE
DEC BL
JNZ REV
CALL DELAY
JMP START
ROTATE MOV CL,04
YY MOV AL,[DI]
OUT C0,AL
MOV DX,1010
XX DEC DX
JNZ XX
INC DI
LOOP YY
RET
DELAY MOV DX,0FFF
ZZ DEC DX
JNZ ZZ
RET

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 167


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 168


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) TO RUN FOR A REQUIRED ANGLE:

COUNT CALCULATION:
Count=reqd.angle/step angle
For 180deg,
Count=180/1.8=100=64H
ALGORITHM:
Step1: Start
Step2: Move the count to BL register
Step3: Move the address of the stepping sequence to destination index register.
Step4: Move the count (number of data in the stepping sequence) to CL register
Step5: Move the data in the stepping sequence to the data latch of stepper interface.
Step6: Decrement BL, if it is zero jump to step
Step7: Execute delay
Step8: Increment destination Index register and decrement CL, if it is non zero jump
to Step5
Step9: Go to step 3
Step10: Stop
PROGRAM
ADDRESS LABEL MNEMONICS

1000 START MOV BL,64


MM MOV DI,1200
MOV CL,04
ZZ MOV AL,[DI]
OUT C0,AL
DEC BL
JZ XX
MOV DX,1010
YY DEC DX
JNZ YY
INC DI
LOOP ZZ
JMP MM
XX HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 169


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 170


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus, the programs for stepper motor rotation using 8086 microprocessor were
written, executed and the results were verified.

VIVA QUESTIONS

1. Explain the logic behind the program for stepper motor control.

2. How stepper motor is interfaced with microcontroller?


3. What is the step angle? How to calculate steps per second?
4. Calculate number of steps per revolution for a step angle of 7.5 degrees.
5. What is the effect of introducing a time delay between each step in stepper
motor control?
6. If a motor takes 90 steps to make one complete revol;ution what is the step
angle for this motor?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 171


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 172


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

16. PARALLEL COMMUNICATION BETWEEN TWO


MICROPROCESSOR KITS USING 8255
AIM:

To program the Programmable Peripheral Interface (8255) to transmit data


parallelly between two microprocessors.

APPARATUS REQUIRED:

Intel 8086 based Trainer Kit-2, connecting cable, power supply, key board

COMPONENT DESCRIPTION

The 8255 Programmable Peripheral Interface (PPI) is a very popular and versatile
input / output chip that is easily configured to function in several different
configuration. The configuration tells the 8255 whether ports are input or output and
even some strange arrangements called bi-directional and strobed, but these 'funny'
modes go a little beyond the scope of this tutorial. The 8255 allows for three distinct
operating modes (Modes 0, 1 and 2) as follows:

 Mode 0: Ports A and B operate as either inputs or outputs and Port C is


divided into two 4-bit groups either of which can be operated as inputs or
outputs
 Mode 1: Same as Mode 0 but Port C is used for handshaking and control
 Mode 2: Port A is bidirectional (both input and output) and Port C is used for
handshaking. Port B is not used.

For most applications using this range of cards Mode 0 will be used.

Each of the 3 ports has 8 bits, each of these bits can be individually set on or off, it's
a bit like having 3 banks of 8 light switches. These bits are configured in groups to
be inputs or outputs allowing their function to either read data into the computer or
control data out of the computer. The various modes can be set by sending a value to
the control port. The control port is Base Address + 3 (i.e. 768+3 = 771 Decimal). The
table below shows the different arrangements that can be configured and the values
to be sent to the configuration port.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 173


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

-BLOCK DIAGRAM

CONTROL WORD FORMAT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 174


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PIN DIAGRAM

CONTROL WORD FORMATION


TRANSMITTER

1 0 0 0 0 0 0 0

=80H
RECEIVER

1 0 0 1 1 0 0 0

=98H
PORT ADDRESS

PORT ADDRESS

CONTROL REG 26

PORT A 20

PORT B 22

PORT C 24

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 175


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ALGORITHM

TRANSMITTER

Step 1.Start.

Step 2.Initialize the port A as output port through control word.

Step 3.Send the data to port A.

Step 4.Stop

RECEIVER

Step 1.Start.

Step 2.Initialize the port A as input port through control word.

Step 3.Read the data from port A and store in some memory location.

Step 4.Stop

PROGRAM

TRANSMITTER

ADDRESS LABEL MNEMONICS

1000 START MOV AL, 80H

OUT 26H, AL

MOV AL, data

OUT 20,AL

END HLT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 176


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RECEIVER

ADDRESS LABEL MNEMONICS

1000 START MOV AL, 98H

OUT 26H, AL

IN AL, 20

MOV [1200],AL

END HLT

RESULT

Thus the Programmable Peripheral Interface (8255) is programmed to transmit


data parallely between two microprocessors and the output is verified.

VIVA QUESTIONS

1. Explain the logic behind the program for transferring the data between two
microprocessors using 8255.

2. What is PPI? Give the control word format for I/O mode and BSR mode of
8255?
3. What are the different operating modes of 8255 PPI?
4. How the data transfer is achieved in handshake mode?

5. What are the different data transfer schemes?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 177


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 178


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

17. PROGRAM FOR DIGITAL CLOCK USING 8086


AIM:

To write and execute an assembly language program for performing the Digital
clock operation with 8086.

APPARATUS REQUIRED:

8086 Trainer kit, Keyboard, Power supply, Digital Clock interface card.

PROGRAM

ADDRESS LABEL MNEMONICS

1000 START CALL CONVERT

CALL DISPLAY

DELAY MOV AL,0B0

OUT 16, AL

MOV CL, 07

S2 MOV AL,88H

OUT 14H, AL

MOV AL, 80H

OUT 14H, AL

S1 MOV AL, 80H

OUT 16, AL

NOP

NOP

NOP

NOP

IN AL, 14H

MOV DL, AL

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 179


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

IN AL,14H

OR AL,DL

JNZ S1

DEC CL

JNZ S2

MOV SI, 1500H

MOV AL, [SI]

INC AL

MOV [SI], AL

CMP AL, 3CH

JNZ START

MOV AL, 00H

MOV [SI], AL

INC SI

MOV AL, [SI]

INC AL

MOV [AI], AL

CMP AL, 3CH

JNZ START

MOV AL,0H

MOV [SI], AL

INC SI

MOV AL,[SI]

INC AL

MOV [SI], AL

CMP AL,18H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 180


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

JNZ START

MOV AL,00H

MOV [SI], AL

JMP START

DISPLAY MOV AH, 06H

MOV DX, 1600H

MOV CH, 01H

MOV CL,0H

INT 5

RET

CONVERT MOV SI, 1500H

MOV BX, 1608H

MOV AL, 24H

MOV [BX], AL

MOV AL,[SI] ;

MOV AH,00H

MOV DH, 0AH

DIV DH

ADD AH, 30H

DEC BX

MOV [BX],AH

DEC BX

ADD AL, 30H

MOV [BX], AL

DEC BX

ADD AL, 3AH

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 181


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

MOV [BX], AL

DEC BX

INC SI

MOV AL,[SI]

MOV AH,0H

MOV DH, 0AH

DIV DH

ADD AH, 30H

MOV [BX],AH

DEC BX

ADD AL, 30H

MOV [BX], AL

DEC BX

ADD AL, 3AH

MOV [BX], AL

DEC BX

INC SI

MOV AL,[SI]

MOV AH,0H

MOV DH, 0AH

DIV DH

ADD AH, 30H

MOV [BX],AH

DEC BX

ADD AL, 30H

MOV [BX], AL

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 182


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RET

GETC IN AL, 02H

AND AL,0FF

CMP AL, 0F0

JNC GET C

HLT

RESULT:

Thus an assembly language program for performing the Digital clock operation with
8086 is written and executed.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 183


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 184


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

18. PROGRAM FOR TRAFFIC LIGHT CONTROL USING 8086


AIM:

To write and execute an assembly language program for performing the control of
traffic light.

APPARATUS REQUIRED:

8086 Trainer kit, Keyboard, Power supply, traffic light interface card.

THEORY:

The board is a simple contraption of a traffic control systems wherein the signalling
light are simulated by the blinking or ON-OFF control of light emitting diodes. The

signalling lights for the pedestrian crossing are simulated by the ON-OFF control of
dual colour light emitting.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 185


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

A Model of a four road four lane junction, the board has green, yellow and red LEDs
which are the green, orange and the red signals of an actual system. Twenty LEDs
are used on the board.

In additional eight dual colour LEDs are used which can be made to change either to
red or to green.

The control of the LED is as follows.

The board communicates with the microprocessor trainer by means of a 26 core


cable which is connected to the output of any parallel port of Vi range of trainers.

The outputs are the inputs to buffers 7406 whose output drive LEDs. The buffered
output applied to the anode of the LEDs decides whether it is ON or OFF.

The figure shows the LED positions and the port lines which control each LED.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 186


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 187


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 188


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM

ADDRESS LABEL MNEMONICS

1000 START MOV AL,80H

OUT CNTRL, AL

REPEAT: MOV BX, LOOKUP

MOV SI, LABEL

CALL OUT

MOV AL, [SI]

OUT PORTA, AL

CALL DELAY1

INC SI

INC BX

CALL OUT

MOV AL, [SI]

OUT PORTB, AL

CALL DELAY1

INC SI

INC BX

CALL OUT

MOV AL, [SI]

OUT PORTC, AL

CALL DELAY1

INC SI

INC BX

CALL OUT

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 189


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

MOV AL, [SI]

OUT PORTC, AL

INC SI

MOV AL, [SI]

OUT PORTA, AL

CALL DELAY1

JMP REPEAT

OUT: MOV AL, [BX]

OUT PORTC, AL

INC BX

MOV AL, [BX]

OUT PORTB,AL

INC BX

MOV AL, [BX]

OUT PORTA, AL

CALL DELAY

RET

DELAY: MOV DI, 00040H

A: MOV DX, 0FFFFH

A1: DEC DX

JNZ A1

DEC D1

JNZ A

RET

DELAY1: MOV DI, 00015H

B: MOV DX,0FFFFH

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 190


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

B1: DEC DX

JNZ B1

DEC D1

JNZ B

RET

LOOKUP: DB
12H,27H,44H,10H

DB
2BH,92H,10H,9DH

DB
84H,48H,2EH,84H

LABEL: DB
48H,4BH,20H,49H

04H

END

RESULT:

Thus an assembly language program for performing the control of the traffic light
with 8086 is written and executed.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 191


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 192


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

19. PROGRAM FOR PRINTING USING 8086


AIM:

To write and execute an assembly language program for performing the printing
over Centronics printer.

APPARATUS REQUIRED:

8086 Trainer kit, Keyboard, Power supply, Printer interface card.

THEORY:

Assuming the printer has been initialized,

1. First check busy signal pin to see if the printer is ready to receive data.

2. If this signal is low, indicating the printer is ready (not busy), you send an ASCII

code on the eight parallel data lines.

character has been sent.

4. The STROBE signal going low causes the printer to assert it BUSY signal high.

5. After a minimum time of 0.5 µs the STROBE signal can be raised high again.

6. The data must be held valid on the data lines for atleast 0.5 µs after the STROBE

signal is made high.

7. When the printer is ready to receive the next character, it asserts its ACKNLG

signal low for about 5 µs.

8. The rising edge of ACKNLG signal tells the micro computer that it can send the

next character.

9. The rising edge of ACKNLG also resets the busy signal from the printer. BUSY

signal being low is another indication that the printer is ready to accept the next

character.

CONTROL WORD : DOh

DATA : C8h

STATUS : C0h
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 193
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INPUT PORT SELECTION : D8h

PROGRAM:

00C8 DATA EQU 00C8H

00D0 CONTL EQU 00D0H

00C0 STUS EQU 00C0H

ROUTINE TO INITIALISE THE PRINTER *******************************************

1000 ORG 1000H

1000 B0 05 MOV AL,05H

1002 E6 D0 OUT CONTL,AL

1004 E4 C0 IN AL,STUS

1006 24 20 AND AL,20H

1008 3C 20 CMP AL,20H

100A 75 44 JNZ ERR

100C B0 41 MOV AL,41H ;ROUTINE TO PRINT A

100E E8 06 00 CALL PRINT ;SINGLE CHARACTER

1011 B0 0A MOV AL,0AH

1013 E8 01 00 CALL PRINT

1016 F4 HLT

1017 PRINT:

1017 8A D8 MOV BL,AL

1019 E8 10 00 CALL CHECK

101C STAS:

101C 8A C3 MOV AL,BL

101E E6 C8 OUT DATA,AL

1020 B0 01 MOV AL,01H

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 194


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1022 E6 D0 OUT CONTL,AL

1024 90 NOP

1025 90 NOP

1026 90 NOP

1027 B0 05 MOV AL,05H

1029 E6 D0 OUT CONTL,AL

102B C3 RET

102C CHECK:

102C E4 C0 IN AL,STUS

102E 24 20 AND AL,20H

1030 74 FA JZ CHECK

1032 E4 C0 IN AL,STUS

1034 24 80 AND AL,80H

1036 3C 80 CMP AL,80H

1038 75 E2 JNZ STAS

103A EB F0 JMP CHECK

103C F4 HLT

1050 ORG 1050H

1050 ERR:

1050 CD 02 INT 2

1052 END

RESULT:

Thus the program to print data in Centronics printer interface using 8086 is written
and executed.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 195


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 196


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

20. PASSWORD CHECKING


AIM:

To check whether the password is correct or not.

APPARATUS REQUIRED:

8086 microprocessor kit, power supply.

THEORY:

Steps to be followed

i)initialization of lcd

ii)display “ENTER PASSWORD”

iii)store the password key value

iv)get the key value from keyboard and compare to it stored value

v)if password matched display ” PASSWORD OK”

vi) if password mismatched display ” PASSWORD NOT OK”

vii)clear the key value to be stored

CPLD ADDRESSES TO BE USED:

LCD DATA/COMMAND :04H

RS :06H

KEYBOARD :02H

PROGRAM:

0000 code segment


assume cs:code,ds:code
1000 org 1000h
1000 E8 1105 R CALL L10
1003 E8 110C R CALL L11
1006 B0 38 MOV AL,38h
1008 E6 04 OUT 04h,AL

100A E8 1105 R CALL L10


100D E8 110C R CALL L11
1010 B0 0E MOV AL,0Eh
1012 E6 04 OUT 04h,AL
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 197
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1014 E8 1105 R CALL L10


1017 E8 110C R CALL L11
101A B0 01 MOV AL,01h
101C E6 04 OUT 04h,AL

101E E8 1105 R CALL L10


1021 E8 110C R CALL L11
1024 B0 06 MOV AL,06h
1026 E6 04 OUT 04h,AL

1028 E8 1105 R CALL L10


102B E8 110C R CALL L11
102E B0 80 MOV AL,80h
1030 E6 04 OUT 04h,AL

1032 E8 1105 R CALL L10


1035 E8 110C R CALL L11
1038 B0 0C MOV AL,0Ch
103A E6 04 OUT 04h,AL

103C B1 10 MOV CL,10h


103E BE 111C R MOV SI,offset mess
1041 E8 1105 R L7: CALL L10
1044 E8 1111 R CALL L12
1047 8A 04 MOV AL,[SI]
1049 E6 04 OUT 04h,AL
104B FE C9 DEC CL
104D 83 C6 01 ADD SI,01h
1050 8A C1 MOV AL,CL
1052 2C 01 SUB AL,01h
1054 75 EB JNZ L7

1056 E8 1105 R CALL L10


1059 E8 110C R CALL L11
105C B0 C4 MOV AL,0C4h
105E E6 04 OUT 04h,AL

1060 BF 1220 MOV DI,1220h


1063 E4 02 L6: IN AL,02h
1065 24 FF AND AL,0FFh
1067 3C F0 CMP AL,0F0h
1069 75 F8 JNZ L6
106B E8 1116 R CALL L13
106E E4 02 IN AL,02h
1070 24 FF AND AL,0FFh
1072 3C 5A CMP AL,5Ah
1074 74 11 JZ LA
1076 88 05 MOV [DI],AL
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 198
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1078 83 C7 01 ADD DI,01h

107B E8 1105 R CALL L10


107E E8 1111 R CALL L12
1081 B0 2A MOV AL,2Ah
1083 E6 04 OUT 04h,AL

1085 EB DC JMP L6

1087 BE 1240 LA: MOV SI,1240h


108A BF 1220 MOV DI,1220h
108D B7 06 MOV BH,06h
108F FE CF L5: DEC BH
1091 8A C7 MOV AL,BH
1093 0C 00 OR AL,00h
1095 74 33 JZ LF
1097 8A 04 MOV AL,[SI]
1099 8A 1D MOV BL,[DI]
109B 83 C6 01 ADD SI,01h
109E 83 C7 01 ADD DI,01h
10A1 3A C3 CMP AL,BL
10A3 74 EA JZ L5

10A5 E8 1105 R CALL L10


10A8 E8 110C R CALL L11
10AB B0 C0 MOV AL,0C0h
10AD E6 04 OUT 04h,AL

10AF B1 0F MOV CL,0Fh


10B1 BE 1137 R MOV SI,offset mess2

10B4 E8 1105 R L4: CALL L10


10B7 E8 1111 R CALL L12
10BA 8A 04 MOV AL,[SI]
10BC E6 04 OUT 04h,AL
10BE FE C9 DEC CL
10C0 83 C6 01 ADD SI,01h
10C3 8A C1 MOV AL,CL
10C5 0C 00 OR AL,00h

10C7 75 EB JNZ L4
10C9 F4 HLT

10CA E8 10CD R LF: CALL L14

10CD L14:
10CD E8 1105 R CALL L10
10D0 E8 110C R CALL L11
10D3 B0 C0 MOV AL,0C0h
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 199
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

10D5 E6 04 OUT 04h,AL


10D7 B1 0C MOV CL,0Ch
10D9 BE 112B R MOV SI,offset mess1
10DC E8 1105 R L2: CALL L10
10DF E8 1111 R CALL l12
10E2 8A 04 MOV AL,[SI]
10E4 E6 04 OUT 04h,AL
10E6 FE C9 DEC CL
10E8 83 C6 01 ADD SI,01h
10EB 8A C1 MOV AL,CL
10ED 0C 00 OR AL,00h
10EF 75 EB JNZ L2

10F1 BE 1220 MOV SI,1220h


10F4 B1 05 MOV CL,05h
10F6 B0 00 L1: MOV AL,00h
10F8 88 04 MOV [SI],AL
10FA 83 C6 01 ADD SI,01h
10FD FE C9 DEC CL
10FF 8A C1 MOV AL,CL
1101 0C 00 OR AL,00h
1103 75 F1 JNZ L1

1105 L10 :
1105 B0 4F MOV AL,4Fh
1107 2C 01 L3: SUB AL,01h
1109 75 FC JNZ L3
110B C3 RET

110C L11:
110C B0 00 MOV AL,00h
110E E6 06 OUT 06h,AL
1110 C3 RET

1111 L12:
1111 B0 01 MOV AL,01h
1113 E6 06 OUT 06h,AL

1115 C3 RET

1116 L13:
1116 B9 0FFF MOV CX,0FFFh
1119 E2 FE HE: LOOP HE
111B C3 RET

111C 20 45 4E 54 45 52 mess db " ENTER PASSWORD"


20 50 41 53 53 57
4F 52 44
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 200
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

112B 50 41 53 53 57 4F mess1 db "PASSWORD OK "


52 44 20 4F 4B 20
1137 50 41 53 53 57 4F mess2 db "PASSWORD NOT OK"
52 44 20 4E 4F 54
20 4F 4B

1146 code ends


End

RESULT:
Thus the program to verify the password is written and checked using
8086 microprocessor.

;password set input :1240 :16(1)

:1e(2)

:26(3)

:25(4)

:2e(5)

After executing type the password via keyboard and press enter button the lcd
show the output.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 201


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 202


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

21. SYSTEM DATE


AIM:

To display the date using VBMB -15 kit.

APPARATUS REQUIRED:

8086 microprocessor, DC motor interface, Connecting cables

THEORY:

Interfacing VBMB-15 to 8086

Steps to be followed in program

i) set 24 hours format


ii) set time(23:55:55)
iii) set date(dd:mm:yy)
iv) read time &date

CODE:
0000 code segment
assume cs:code,ds:code
1000 org 1000h

1000 B0 05 MOV AL,05H


1002 E6 DE OUT 0DEH,AL

1004 B0 04 MOV AL,04H


1006 E6 DE OUT 0DEH,AL

1008 BE 1200 MOV SI,1200H


100B 8A 04 MOV AL,[SI]
100D E6 C0 OUT 0C0H,AL

100F 46 INC SI
1010 8A 04 MOV AL,[SI]
1012 E6 D0 OUT 0D0H,AL

1014 46 INC SI
1015 8A 04 MOV AL,[SI]
1017 E6 C2 OUT 0C2H,AL

1019 46 INC SI
101A 8A 04 MOV AL,[SI]
101C E6 D2 OUT 0D2H,AL

101E 46 INC SI
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 203
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

101F 8A 04 MOV AL,[SI]


1021 E6 C4 OUT 0C4H,AL

1023 46 INC SI
1024 8A 04 MOV AL,[SI]
1026 E6 D4 OUT 0D4H,AL

1028 46 INC SI
1029 8A 04 MOV AL,[SI]
102B E6 C6 OUT 0C6H,AL

102D 46 INC SI
102E 8A 04 MOV AL,[SI]
1030 E6 D6 OUT 0D6H,AL

1032 46 INC SI
1033 8A 04 MOV AL,[SI]
1035 E6 C8 OUT 0C8H,AL

1037 46 INC SI
1038 8A 04 MOV AL,[SI]
103A E6 D8 OUT 0D8H,AL

103C 46 INC SI
103D 8A 04 MOV AL,[SI]
103F E6 CA OUT 0CAH,AL

1041 46 INC SI
1042 8A 04 MOV AL,[SI]
1044 E6 DA OUT 0DAH,AL

1046 BE 1300 LOOP: MOV SI,1300H


1049 E4 D6 IN AL,0D6H
104B 24 0F AND AL,0FH
104D 88 04 MOV [SI],AL

104F E4 C6 IN AL,0C6H
1051 24 0F AND AL,0FH
1053 46 INC SI
1054 88 04 MOV [SI],AL

1056 E4 D8 IN AL,0D8H
1058 24 0F AND AL,0FH
105A 46 INC SI
105B 88 04 MOV [SI],AL

105D E4 C8 IN AL,0C8H
105F 24 0F AND AL,0FH
1061 46 INC SI
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 204
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1062 88 04 MOV [SI],AL

1064 E4 DA IN AL,0DAH
1066 24 0F AND AL,0FH
1068 46 INC SI
1069 88 04 MOV [SI],AL

106B E4 CA IN AL,0CAH
106D 24 0F AND AL,0FH
106F 46 INC SI
1070 88 04 MOV [SI],AL

1072 BE 1300 MOV SI,1300H


1075 8A 04 MOV AL,[SI]
1077 E6 E0 OUT 0E0H,AL

1079 46 INC SI
107A 8A 04 MOV AL,[SI]
107C E6 F0 OUT 0F0H,AL

107E 46 INC SI
107F 8A 04 MOV AL,[SI]
1081 E6 E2 OUT 0E2H,AL

1083 46 INC SI
1084 8A 04 MOV AL,[SI]
1086 E6 F2 OUT 0F2H,AL

1088 46 INC SI
1089 8A 04 MOV AL,[SI]

108B E6 E4 OUT 0E4H,AL

108D 46 INC SI
108E 8A 04 MOV AL,[SI]
1090 E6 F4 OUT 0F4H,AL

1092 EB B2 JMP LOOP

1094 code ends


end
RESULT:

Thus the program to display system date is executed and verified.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 205


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 206


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

INPUT:

SET TIME 1200: 05 (LSB OF SECONDS)


1201: 05 (MSB OF SECONDS)

1202: 09 (LSB OF MINUTES)


1203: 05 (MSB OF MINUTES)
1204: 03 (LSB OF HOURS)
1205: 02 (MSB OF HOURS)

SET DATE 1206: 05 (LSB OF DATE)


1207: 02 (MSB OF DATE)
1208: 01 (LSB OF MONTH)
1209: 00 (MSB OF MONTH)
120A: 05(LSB OF YEAR)
120B: 01 (MSB OF YEAR)

OUTPUT:

After execution the time IS 23:59:55 AND DATE IS 25:01:15

After 5 seconds the date will be displayed 26:01:15 IN VBMB-15

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 207


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 208


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

22. DISPLAY RAM SIZE


AIM:

To find display the RAM SIZE of the system.

APPARATUS REQUIRED:

8086 microprocessor kit.

THEORY:

Steps to be followed in program

i) fill the memory with data in RAM


ii) check how much memory correctly filled with data
iii) initialization of lcd
iv) display “RAM SIZE”
v) Read the count value and display the count value as RAM
size.

CPLD ADDRESSES TO BE USED:

LCD DATA/COMMAND :04H

RS :06H

CODE:

0000 code segment


assume cs:code,ds:code
1000 org 1000h
1000 BE 0000 MOV SI,0000h
1003 B9 1000 MOV CX,1000h
1006 B0 11 L1: MOV AL,11h
1008 88 04 MOV [SI],AL
100A 46 INC SI
100B E2 F9 LOOP L1

100D BE 2000 MOV SI,2000h


1010 BA 1FFF MOV DX,1FFFh
1013 B9 7FFF MOV CX,7FFFh
1016 B0 44 L3: MOV AL,44h
1018 88 04 MOV [SI],AL
101A 8A 1C MOV BL,[SI]
101C 46 INC SI
101D 3A C3 CMP AL,BL
101F 75 07 JNZ L2
1021 83 C2 01 ADD DX,01h
1024 E2 F0 LOOP L3
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 209
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

1026 F4 HLT
1027 90 NOP

1028 L2:

1028 E8 10D1 R CALL L10


102B E8 10D8 R CALL L11
102E B0 38 MOV AL,38h
1030 E6 04 OUT 04h,AL

1032 E8 10D1 R CALL L10


1035 E8 10D8 R CALL L11
1038 B0 0E MOV AL,0Eh
103A E6 04 OUT 04h,AL

103C E8 10D1 R CALL L10


103F E8 10D8 R CALL L11
1042 B0 01 MOV AL,01h
1044 E6 04 OUT 04h,AL

1046 E8 10D1 R CALL L10


1049 E8 10D8 R CALL L11
104C B0 06 MOV AL,06h
104E E6 04 OUT 04h,AL

1050 E8 10D1 R CALL L10


1053 E8 10D8 R CALL L11
1056 B0 80 MOV AL,80h
1058 E6 04 OUT 04h,AL

105A E8 10D1 R CALL L10


105D E8 10D8 R CALL L11

1060 B0 0C MOV AL,0Ch


1062 E6 04 OUT 04h,AL

1064 E8 10D1 R CALL L10


1067 B1 0C MOV CL,0ch
1069 BE 10E2 R MOV SI,offset mess

106C E8 10D1 R L4: CALL L10


106F E8 10DD R CALL L12
1072 8A 04 MOV AL,[SI]
1074 E6 04 OUT 04h,AL
1076 FE C9 DEC CL
1078 46 INC SI
1079 8A C1 MOV AL,CL
107B 0C 00 OR AL,00h
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 210
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

107D 75 ED JNZ L4

107F E8 10D1 R CALL L10


1082 E8 10DD R CALL L12
1085 8B C2 MOV AX,DX
1087 BA 0000 MOV DX,0
108A B9 03FF MOV CX,03FFH
108D F7 F1 DIV CX
108F B3 0A MOV BL,0AH
1091 F6 F3 DIV BL
1093 8A D0 MOV DL,AL
1095 8A F4 MOV DH,AH

1097 E8 10D1 R CALL L10


109A E8 10D8 R CALL L11
109D B0 C4 MOV AL,0C4h
109F E6 04 OUT 04h,AL

10A1 E8 10D1 R CALL L10


10A4 E8 10DD R CALL L12
10A7 8A C2 MOV AL,DL
10A9 04 30 ADD AL,30h
10AB E6 04 OUT 04h,AL

10AD E8 10D1 R CALL L10


10B0 E8 10DD R CALL L12
10B3 8A C6 MOV AL,DH
10B5 04 30 ADD AL,30h
10B7 E6 04 OUT 04h,AL

10B9 E8 10D1 R CALL L10


10BC E8 10DD R CALL L12
10BF B0 6B MOV AL,6Bh
10C1 E6 04 OUT 04h,AL

10C3 E8 10D1 R CALL L10


10C6 E8 10DD R CALL L12
10C9 B0 42 MOV AL,42h
10CB E6 04 OUT 04h,AL

10CD E8 10D1 R CALL L10

10D0 F4 HLT

10D1 L10:
10D1 B0 7F MOV AL,7Fh
10D3 2C 01 L8: SUB AL,01h
10D5 75 FC JNZ L8
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 211
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

10D7 C3 RET

10D8 L11:
10D8 B0 00 MOV AL,00h
10DA E6 06 OUT 06h,AL
10DC C3 RET

10DD L12:
10DD B0 01 MOV AL,01h
10DF E6 06 OUT 06h,AL
10E1 C3 RET

10E2 20 52 41 4D 20 53 mess db " RAM SIZE IS"


49 5A 45 20 49 53
10EE code ends
end

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 212


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus the program to display the RAM size is executed and verified.

OUTPUT:

RAM SIZE DISPLAYED IN LCD(16kB)

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 213


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 214


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PC PROGRAMMING WITH ASSEMBLY LANGUAGE USING MASM


Procedure:

1. Open command window (click: start->run->type cmd )

2. Paste the 8086 or MASM software in any drive

3. In that window change the directry [Where the masm software is present]

4. In the command window type the directory name after that change the directory to
8086(masm) after that type edit

5.After changing directory type edit then in that window, write the program

6.After writing a program click: file->save->exit [again we enter the commond


window]

7.Type : masm filename,,; [This will display the error report]

8.Type: link filename,,; [This will create a list file and can be seen inside the
masm(8086)software]

9.Type : debug filename.exe [to create exe file]

10.Type : n filename.bin [to create a bin file]

11.Type : wcs:1000 [writing code segment]

12.Type : g =1000 [to execute a program]

13. Type : u 1000[to see opcode]

14.Type : e 1200 [see output in corresponding address] use space bar to see
next output value

15.Type : q [terminate a line]

16. Down Loading procedure

Note: don’t use these command while down loading

Mov ah, 4ch [These commands are used to see the results system
itself]

Int 21h

( bin file is used to down loading )

 Type: dc then you can get the following window

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 215


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 216


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

17. press f1 key and set the port settings

18.Press esc key to abort

19.Now in micro 86 kit select receiving mode(ie) type si 1000(starting address) then
press enter key. Then the kit is ready to receive data and press any in the host to
start transmission. During transmisson the message display as ,

transmission progress.

Press esc to abort.

Now binary files are downloaded to kit.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 217


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 218


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

23. PROGRAMMING USING ARITHMETIC INSTRUCTIONS OF


8051 MICROCONTROLLER

a) 16 BIT ADDITION

AIM:

To write an ALP to perform 16 bit addition of two numbers using 8051


microcontroller.

APPARATUS REQUIRED:

8051 micro controller, power supply, Keyboard

ALGORITHM:

1. Start
2. Get the Augends.
3. ADD with addend.
4. Get the memory where sum is to be stored.
5. Store the sum in to memory.
6. Stop the program.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 219


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 220


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:
ADDRESS LABEL MNEMONICS

4100 START CLRC


MOV
A,#augend(LSB)
ADDC
A,#addend(LSB)
MOV DPTR,#4500
MOVX @DPTR,A
INC DPTR
MOV A,#
L1 augend(MSB)
ADDC,#
addend(MSB)
MOVX @DPTR,A SJMP L1
SJMP L1

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 221


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 222


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b) 8 BIT SUBTRACTION

AIM:
To write an ALP to perform 8 bit subtraction of two numbers using 8051
microcontroller.
APPARATUS REQUIRED:
8051 micro controller, power supply, Key board
ALGORITHM:
1.Start
2.Clear the sign bit .
3.Get the minuend.
4.Subtract the subtrahend from the minuend.
5.Get the memory where sum is to be stored.
6.Store the sum in to memory.
7.Stop the program.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 223


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 224


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

4100 START CLRC

MOV
A,#minuend

SUB
A,#subtrahend

MOV
L1 DPTR,#4500

MOVX @DPTR,A

SJMP L1 SJMP

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 225


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 226


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

c) 8 BIT MULTIPLICATION

AIM:
To write an ALP to perform 8 bit multiplication of two numbers using 8051
microcontroller.

APPARATUS REQUIRED:
8051 micro controller, power supply, Key board

ALGORITHM:
1. Start
2. Get the multiplicand and multiplier .
3. Perform multiplication.
4. Get the memory where product is to be stored.
5. Store the product in to memory.
7. Stop the program.
PROGRAM:

ADDRESS LABEL MNEMONICS

4100 START MOV A,


#multiplicand
MOV B,#multiplier
MUL AB
MOV DPTR,#4500
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX@DPTR,A
L1
SJMP L1
TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 227


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 228


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

d ) 8 BIT DIVISION

AIM:
To write an ALP to perform 8 bit division of two numbers using 8051
microcontroller.
APPARATUS REQUIRED:
8051 micro controller, power supply, Key board
ALGORITHM:
1.Start
2.get the dividend and divisor .
3.Perform division.
4.Get the memory where result is to be stored.
5.Store the quotient and remainder in to memory.
7.Stop the program.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 229


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 230


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

4100 START MOV A,


#dividend
MOV B, #divisor
DIVAB
MOV
DPTR,#4500
MOVX @DPTR,A
INC DPTR
MOV A,B
L1 MOVX@DPTR,A
SJMP L1 SJMP L1

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

RESULT:

Thus, ALPs are written to perform arithmetic operations 8051 micro controllers.
The outputs are verified and results were carefully noted.

VIVA QUESTIONS

1. Explain the logic behind the programs for arithmetic operations using 8051.
2. What is a Micro controller? What is the difference between microprocessor &
micro controller?
3. List the addressing modes of 8051?
4. List the salient features of 8051 microcontroller?
5. What is the function of program counter in 8051?
6. What are program and data memory?
7. List different special function registers and their functions.
EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 231
THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 232


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

24. PROGRAMMING USING LOGICAL INSTRUCTIONS OF 8051

a) 2’S COMPLEMENT

AIM:
To write an assembly language program to find 2’s complement of a given
number using 8051.
APPARATUS REQUIRED :
8051 micro controller, power supply,Key board
ALGORITHM:
1. Start the program
2. Move the data into the accumulator and compliment.
3. Move the address 4800 into data pointer.
4. Move the value of A into 4800.
5. Increment content of data pointer and accumulator.
6. Move contents of A into address 4801.
7. Stop.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 233


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 234


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

4100 START MOV A,#data

CPL A

MOV
DPTR,#4800

MOVX @DPTR,A

INC A

INC DPTR

MOVX @DPTR,A
L1
SJMP L1

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 235


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 236


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

b)AND/OR/XOR OPERATION OF TWO 8 BIT DATA

AIM:
To write an assembly language program to perform logical AND/OR/XOR of
two 8 bit data using 8051.
APPARATUS REQUIRED:
8051 micro controller, power supply
ALGORITHM:
1. Start the program
2. Move the first data into the accumulator and perform AND/OR/XOR with the
second data.
3. Move the address 4800 into data pointer.
4. Move the value of A into 4800.
7. Stop.
PROGRAM:

ADDRESS LABEL MNEMONICS

4100 START MOV A, #first data

ANL /ORL/XRL A,
#second data

MOV DPTR, #4800

MOVX @DPTR,A
L1
SJMP L1

TABULAR COLUMN

INPUT OUTPUT

ADDRESS DATA

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 237


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 238


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

RESULT:

Thus the assembly language programs using logical instructions of 8051 were
written, executed and the results were verified.

VIVA QUESTIONS

1. Explain the logic behind the programs for logical operations using 8051.
2. Give examples of some logical instructions.
3. List the instructions used to access external RAM.
4. What are the advantages of register indirect addressing mode in 8051?
5. What is meant by bit addressable and byte addressable?
6. What is Program status word (PSW)? Give its format.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 239


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 240


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

CONTENT

BEYOND

SYLLABUS

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 241


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 242


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

25. DC MOTOR CONTROL AND SPEED MEASUREMENT

AIM:

To write a program to control the speed of DC motor and measure the speed
using 8086 microprocessor

APPARATUS REQUIRED:

8086 microprocessor, DC motor interface, Connecting cables

COMPONENT DESCRIPTION

Salient features of DC Motor interface are,

1) 8 Bit DAC to control the speed and direction of DC motor


2) 6V DC motor with slotted disk
3) Optical pickup with wave shaping circuitry for speed sensing
4) Speed measurement through 8253

5) Drivers for driving the DC Motor


6)No external power supply is needed
7) Counter channel 0 is used for measuring the speed of the DC motor by decrement
the counter value using the pulses generated by the opto-coupled DC motor shaft, for
a known time and calibrating the count value to RPM
8) All Address, data and control lines are terminated in a 50 Pin FRC OEN make
male connector to interface with VXT bus.

The DC motor speed controller interface consists of a digital to analog converter


for precise speed control and a 8252 timer/control for speed measurement. The
Speed measurement is based on the principle that the speed of any motor decreases
as the input power to the motor decreases. Hence the input power to the motor is
changed to vary the speed. The motor rotation is first converted to pulses using
optical pick up and these pulses are used to decrement the counter for a known
time. This count value is used to measure the speed.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 243


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

BLOCK DIAGRAM OF DC MOTOR CONTROLLING

PORT ADDRES

PERIPHERAL ADDRESS R/W STATUS

DAC C0 W

TIMER CHANNEL 0 C8 R/W

CHANNEL 1 C4 R/W

CHANNEL 2 CC R/W

TIME& CNTRL REG. CE W

GATE HIGH D0 R/W

GATE LOW D8 R/W

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 244


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ALGORITHM:

1.Start

2.Set the high value for DAC to make active.

3.Make the gate signal low for 8253 to be low and call the delay.

4. Initialize the control word format of 8253 and initialize the count to the counter of
8253.

5.Make the gate signal high and call delay and once again make the gate signal to
low.

6.Store the MSB and LSB of the obtained count to different address.

7.In delay move the high value to register and it is decremented until each one set
the zero flag according to the loop.

8.Stop.

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AL,COUNT

OUT C0,AL

MOV AL,00H

OUT D8,AL

CALL DELAY

MOV AL,3OH

OUT CE,AL

MOV AL,FFH

OUT C8,AL

OUT C8,AL

MOV AL,00H

OUT D0,AL

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 245


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

CALL DELAY

MOV AL,00H

OUT D8,AL

IN AL,C8H

MOV SI,1600H

MOV [SI],AL

MOV AL,00H

INC SI

MOV [SI],AL

END HLT

1400 DELAY MOV CL,04H

LO2 MOV DX,0FFFFH

LOOP DEC DX

JNZ LOOP

DEC CL

JNZ LO2

RET

PROCEDURE:

1. Initialize the DAC and make the gate low.

2. Initialize the control register and make the gate high.

3. Make the data from channel 0 to A and to register R0.

4. Move the higher byte from channel 0 to A and lower byte to memory.

5. Load the delay count; decrement the control until the zero flag in set.

6. Decrement the count if ZF is still equal to zero and go to the specified location.

7. Execute the program, go to location 4300 and 4301.Subtract the data in location
from FFFF and convert it in to decimal, which is the timer output in decimal.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 246


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

8. The speed is calculated using formula,

Speed in RPM= (Timer output in decimalX60)/4x1sec

TABULAR COLUMN:

COUNT TIMER DIFFERENCE SPEED IN RPM


OUTPUT

HEX DEC

RESULT:

Thus, the program for control the DC motor is executed and the speed is measured.

VIVA QUESTIONS

1. Explain the logic behind the program for DC motor speed control.

2. Why do we put a driver between micro controller and dc motor.


3. How can a micro controller be used to control automatically the speed of the
DC motor.
4. How the speed of DC motor is measured from the timer count?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 247


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 248


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

26. STUDY OF 8259 PROGRAMMABLE INTERRUPT


CONTROLLER
AIM:

To initialize and to program an 8259 programmable interrupt controller for


interrupt operations

APPARATUS REQUIRED:

Intel 8086 based MPS 85-2 Trainer Kit,8259 interface board, cable

COMPONENT DESCRIPTION:

A programmable interrupt controller is a microprocessor interface


component. For the 8086 microprocessor, the 8259 interrupt controller is often used.
This interrupt controller accepts service requests from sensors, motors or other types
of electronic devices. It then directs those requests to the interrupt ports of the 8086
processor. In response, the microprocessor will retrieve and execute an Interrupt
Service Routine that it is stored in main memory, the microprocessor stops whatever
its processing and performs a processing routine to address the needs of the device.

The features of 8259 are,

1. It is programmed to work with either 8085 or 8086 processor.

2. It manages 8-interrupts according to the instructions written into its control


registers.

3. In 8086 processor, it supplies the type number of the interrupt and the type
number is
programmable. In 8085 processor, the interrupt vector address is programmable.
The
priorities of the interrupts are programmable.

4. The interrupts can be masked or unmasked individually.

5. The 8259s can be cascaded to accept a maximum of 64 interrupts.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 249


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

BLOCK DIAGRAM:

PIN DIAGRAM

COMMAND WORDS FORMAT

ICW1

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 250


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ICW2

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 251


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

ICW3

MASTER MODE

SLAVE MODE

ICW4

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 252


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

OCW1

OCW2

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 253


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

OCW3

PORT ADDRESS

COMMAND ADDRESS
WORDS

ICW1 C0

ICW2 C2

ICW3 C2

ICW4 C2

OCW1 C2

OCW2 C0

OCW3 C0

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 254


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

CONTROL WORD FORMATION

ICW1

0 0 0 1 0 1 1 1
=17H

ICW2

0 0 0 0 1 0 0 0
=08H

ICW4

0 0 0 0 0 0 0 1
=01H

OCW1

1 1 1 1 1 1 1 0
=FEH

ALGORITHM

Step1. Start
Step 2.move the different control word to their respective control register.
Step 3.Check weather the interrupt is set .if not jump to this same step.

Step 4.check the respective interrupt address jump to any other address
which has some sub program like add, sub etc.
Step 5.Check the result in the address given in the sub program.
Step 6.Stop.

PROCEDURE:

1. To identify the interval between interrupt address (a) cascade mode type of trigger
and vectored address we use the icw1 control word.

2. To identify weather it is specially fully nested mode or not for that ICW2 is used.

3.To identify the interrupt vector address of the 8085 mode we use the ICW4 control
word is used.

4.To identify weather it is mask set or reset we use OCW1.

5.Once the control word is paused it check for the interrupt and output is verified by
getting answer in the respective address.

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 255


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 256


THANTHAI PERIYAR GOVERNMENT INSTITUTE OF TECHNOLOGY, DEPT. OF ECE

PROGRAM:

ADDRESS LABEL MNEMONICS

1000 START MOV AL,17


OUT C0,AL
MOV AL, 08
OUT C2,AL
MOV AL,O1
OUT C2,AL
MOV AL,FE
OUT C2,AL
STI
L1
JMP L1
0020
00 12 00 00
1200 MOV AL,05
ADD AL,06
MOV [1500],AL
HLT

RESULT:

Thus the program for 8259 PIC and development of interrupt service routine is
executed and the output is verified.

VIVA QUESTIONS

1. Explain the logic behind the program for interrupt operations.

2. What are the various interrupts in 8086?


3. What is meant by Maskable interrupts & Non-Maskable interrupts and Give
examples for Maskable & Non-Maskable interrupts?
4. What will happen when the following two interrupt requests occur at the same
time? (i) NMI and INTO (ii) single step mode and INTR
5. What is vectored address?

6. What is the need for interrupt priority?

EC8681 MICROPROCESSORS AND MICROCONTROLLERS LABORATORY Page 257

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy