Sie sind auf Seite 1von 63

LABORATORY MANUAL

MICROPROCESSORS &
MICROCONTROLLERS
(III B.Tech., ECE- II Sem.)
(IV B.Tech., EEE- I Sem.)

Department of Electronics & Communication


Engineering

BALAJI INSTITUTE OF ENGINEERING &


SCIENCES
Department of Electronics & Communication Engineering

Laknepally, Narsampet, Warangal

MICROPROCESSOR AND MICROCONTROLLER LAB


LAB MANUAL
CONTENTS
S.No.

Name of the Experiment

1.

Introduction to 8086 Microprocessor

2.

Using 8086 ANSHUMAN Trainer kit

3.

Arithmetic Operation

4.

String Operation

5.

Code Conversion programmes

6.

More programes with 8086 Assembly language

7.

Interfacing 8086 with 8255 PPI

8.

Interfacing to 8051 Microcontroller

9.

Using 8051 Micro Controller trainer kit

10.

Programming with 8051

Department of Electronics & Communication Engineering

S.No.

1.

2.

3.

4.

5.

6.

Name of the Experiment


Introduction to 8086 Microprocessor
Introduction
Pin out diagram of 8086
Architecture of 8086
Addressing modes of 8086
Register set of 8086
Instruction set of 8086
Using 8086 Anshuman Trainer kit
Steps to write and execute ALPs on Assembler
Step to find the opcode of the program
Arithmetic Operation
Addition of two 32-bit numbers
Subtraction of two 32-bit numbers
Multiplication of two 16-bit numbers
Division of two 32-bit numbers
Multiplication of signed numbers
Sting Operation
Comparison of two strings
To find the length of the string
Move string of bytes from one segment to the another segment
Sorting string of n numbers in ascending order
Reversing a given string
Code Conversion programmes
To convert BCD number into Binary number
To convert Binary number to BCD number
To convert Binary number to ASCII number
To ASCII number to binary number
To convert Packed BCD to unpacked BCD number
To convert unpacked BCD number to Packed BCD number
More programes with 8086 Assembly language
Generation of Fibonacci series
Average of n numbers
1s and 2s complement of a given number
Factorial of given numbers
Square root of a given number
Sum of squares of n numbers
Sum of cubes of n numbers

Department of Electronics & Communication Engineering

7.

8.

9.

10.

LCM, GCD, Greatest number, smallest number, Multiplication


table
Interfacing 8086 with 8255 PPI
Generation of Ramp waveform
Generation of Triangular waveform
Generation of Square waveform
Generation of Rectangular waveform
Traffic light controller
Analog to digital conversion
Interfacing to 8051 Microcontroller
Architecture of 8051
Using 8051 Micro Controller trainer kit
Steps to write and execute ALPs on assembler
Steps to find the opcode of the program
Programming with 8051
Addition of Two numbers
Subtraction of two numbers
Multiplication of two numbers
Division of two numbers
Use of SWAP instructions
To find the largest of two numbers
To find the factorial of given number
Increment & decrement the tow numbers until equalize
To find the square of a given number
To find the cube of a given number
To pack two BCD number
To check the nth bit is 1 or 0
Comparison of two numbers

Department of Electronics & Communication Engineering

ARITHMETIC OPERATION

Department of Electronics & Communication Engineering

ARITHMETIC OPERATIONS
Program:1

ADDITION OF TWO 32-BIT DATA

AIM: To add two 32-bit data (Multibyte addition) using 8086 microprocessor.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,[0300]
MOV BX,[0304]
ADD AX,BX
MOV [030A],AX
MOV AX,[0302]
MOV BX,[0306]
ADC AX,BX
MOV [030C],AX
INT A5
RESULT:
Input Data (Before Execution)
0000:0300
0000:0301
0000:0302
0000:0303
0000:0304
0000:0305
0000:0306
0000:0307

78
56
34
12
65
87
21
43

Output Data (After Execution)


0000:030A
DD
0000:030B
DD
0000:030C
55
0000:030D
55

Department of Electronics & Communication Engineering

Program:2

SUBTRACTION OF TWO 32-BIT DATA

AIM: To subtract two 32-bit data (Multibyte subtraction) using 8086 microprocessor.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,[0300]
MOV BX,[0304]
SUB AX,BX
MOV [030A],AX
MOV AX,[0302]
MOV BX,[0306]
SBB AX,BX
MOV [030C],AX
INT A5
RESULT:
Input Data (Before Execution)
0000:0300
0000:0301
0000:0302
0000:0303
0000:0304
0000:0305
0000:0306
0000:0307

44
44
44
44
11
11
11
11

Output Data (After Execution)


0000:030A
33
0000:030B
33
0000:030C
33
0000:030D
33

Department of Electronics & Communication Engineering

Program:3

MULTIPLICAION OF TWO 16-BIT DATA

AIM: To multiply two 16-bit data (Multibyte multiplication) using 8086 microprocessor.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,[0300]
MOV BX,[0302]
MUL BX
INT A5
RESULT:
Input Data (Before Execution)
0000:0300
0000:0301
0000:0302
0000:0303

44
44
11
11

Output Data (After Execution)


AL
44
AH
44
DL
DH

00
00

Department of Electronics & Communication Engineering

Program:4

DIVISION OF TWO 16-BIT DATA

AIM: To multiply two 16-bit data (Multibyte division) using 8086 microprocessor.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,[0300]
MOV BX,[0302]
DIV BX
INT A5
RESULT:
Input Data (Before Execution)
0000:0300
0000:0301
0000:0302
0000:0303

44
44
22
22

Output Data (After Execution)


AL
22
AH
22
DL
DH

00
00

Department of Electronics & Communication Engineering

Program:5

MULTIPLICAION OF SIGNED NUMBERS

AIM: To multiply two signed numbers (8-bit data) using 8086 microprocessors.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,0200
MOV DS,AX
MOV AL,[1500]
NEG AL
MOV BL,[1501]
MUL BL
MOV [1505],AX
INT A5
RESULT:
Input Data (Before Execution)
2000:1500
2000:1501

10
15

Output Data (After Execution)


2000:1505
2000:1506

B0
13

Department of Electronics & Communication Engineering

STRING OPERATION

Department of Electronics & Communication Engineering

Program:1

COMPARISION OF TWO STRINGS

AIM: To compare two data stings using 8086 microprocessor programming


APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2000
MOV DS,AX
MOV ES,AX
MOV SI,0100
MOV DI,0200
MOV CX,0005
MOV BX,0000
CLD
REP CMPSB
JE Last
MOV BX,FFFF
INT A5
RESULT
Input Data (Before Execution)
DS:SI
2000:0100
2000:0101
2000:0102
2000:0103
2000:0104

01
02
03
04
05

ES:DI
2000:0200
2000:0201
2000:0202
2000:0203
2000:0204

01
02
03
04
05

Output Data (After Execution)


BX FFFF

Department of Electronics & Communication Engineering

Program:2

LENGTH OF A DATA STRING

AIM: To find the length of a given string of data using 8086 microprocessor
programming.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2000
MOV ES,AX
MOV DI,0100
MOV CX,0000
MOV AL,00
CLD
Again

SCASB
JZ

Last

INC CX
JMP
Last

Again

INT A5

RESULT
Input Data (Before Execution)
2000:0100
2000:0101
2000:0102
2000:0103
2000:0104

44
67
49
20
00

Output Data (After Execution)


CX 0004

Department of Electronics & Communication Engineering

Program:3

MOVING A STRING OF DATA

AIM: To move a sting or a block of data from one segment to the other segment using
8086 microprocessor programming.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2100
MOV DS,AX
MOV AX,2200
MOV ES,AX
MOV SI,2000
MOV DI,0000
MOV CX,0005
CLD
REP MOVSB
INT A5
RESULT
Input Data (Before Execution)
2000:2000
2000:2001
2000:2002
2000:2003
2000:2004

23
45
21
78
69

Output Data (After Execution)


2200:0000
2000:0001
2000:0002
2000:0003
2000:0004

23
45
21
78
69

Department of Electronics & Communication Engineering

Program:4
SORTING STRING OF N NUMBERS IN ASCENDING/DESCENDING ORDER
AIM: To write a program to sort a given string of a number in ascending/descending
8086 microprocessor programming.
APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV CX,0005
DEC CX
Again

MOV DX,CX
MOV SI,0200

Up

MOV AL,[SI]
INC SI
MOV BL,[SI]
CMP AL,BL
JLE/JGE

Next

XCHG AL,BL
MOV [SI],BL
DEC SI
MOV [SI],AL
INC SI
Next

DEC DX
JNZ

Up

DEC CX
JNZ

Again

INT A5

Department of Electronics & Communication Engineering

RESULT
Input Data (Before Execution)
0000:0200
0000:0201
0000:0202
0000:0203
0000:0204

38
47
02
11
29

Output Data (After Execution)


Ascending order
0000:0200
02
0000:0201
11
0000:0202
29
0000:0203
38
0000:0204
47

Descending order
47
38
29
11
02

Department of Electronics & Communication Engineering

Program:5

REVERSE OF A STRING

AIM: To write a program to reverse of a string 8086 microprocessor programming.


APPARATUS:
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2000
MOV DS,AX
MOV CX,0005
MOV SI,0200
MOV DI,0209
Next

MOV AL,[SI]
XCHG AL,[DI]
MOV [SI],AL
INC SI
DEC DI
JNZ

Next

INT A5
RESULT
Input Data (Before Execution)
2000:0200
2000:0201
2000:0202
2000:0203
2000:0204
2000:0205
2000:0206
2000:0207
2000:0208
2000:0209

00
01
02
03
04
05
06
07
08
09

Output Data (After Execution)


2000:0200
2000:0201
2000:0202
2000:0203
2000:0204
2000:0205
2000:0206
2000:0207
2000:0208
2000:0209

09
08
07
06
05
04
03
02
01
00

Department of Electronics & Communication Engineering

CODE CONVERSION PROGRAMMES

Department of Electronics & Communication Engineering

Program: 1

BCD TO BINARY NUMBER CONVERSION

AIM: To covert the given two digit BCD data into 8-bit binary or two digit hexadecimal
number by using 8086 microprocessor programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2000
MOV DS,AX
XOR AX,AX
MOV SI,1000
MOV AL,[SI]
MOV DL,AL
AND AL,F0
MOV CL,04
ROR AL,CL
MOV BL,0A
MUL BL
AND DL,0F
ADD AL,DL
MOV [SI],AL
INT A5
RESULT
Input Data
2000:1000

72

Output Data
2000:1000

48

Department of Electronics & Communication Engineering

Program:2

BINARY TO BCD CONVERSION

AIM: To covert given 8-bit binary or two digit hexadecimal number data into BCD
number by using 8086 microprocessor programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2000
MOV DS,AX
XOR AX,AX
MOV AL,[1000]
MOV BL,64
DIV BL
MOV [1001],AL
MOV AL,AH
MOV AH,00
MOV BL,0A
DIV BL
MOV CL,04
SHL AL,CL
ADD AL,AH
MOV [1002],AL
INT A5
RESULT
Input Data
2000:1000

FF

Output Data
2000:1001

02

2000:1002

55

Department of Electronics & Communication Engineering

Program:3

BINARY TO ASCII NUMBER CONVERSION

AIM: To covert the given binary number to ASCII number by using 8086 microprocessor
programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AL,[0100]
MOV BL,30
CMP AL,09
JL

Down

ADD BL,07
Down

ADD BL,AL
INT A5

RESULT
Input Data
0000:0100

05

Output Data
0000:0001

35

Department of Electronics & Communication Engineering

Program:4

ASCII TO BINARY NUMBER CONVERSION

AIM: To covert the given ASCII number to binary number by using 8086 microprocessor
programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,1200
MOV DS,AX
MOV AL,[1000]
SUB AL,30
CMP AL,0A
JB

Down

SUB AL,07
Down

MOV [1001],AL
INT A5

RESULT
Input Data
1200:1000

37

Output Data
1200:1001

07

Department of Electronics & Communication Engineering

Program:5

PACKED TO UNPACKED BCD CONVERSION

AIM: To unpack an 8-bit BCD data at a given memory locaion using 8086
microprocessor programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AL,[0300]
MOV BL,AL
AND BL,0F
AND AL,F0
MOV CL,04
ROR AL,CL
MOV [0301],AL
MOV [0302],BL
INT A5
RESULT
Input Data
0000:0300

23

Output Data
0000:0301

02

0000:0302

03

Department of Electronics & Communication Engineering

Program:6

UNPACKED TO PACKED BCD CONVERSION

AIM: To pack an two unpacked BCD data at a given memory location using 8086
microprocessor programming.
APPARATUS:
1. 8080 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV SI,0300
MOV DI,0301
MOV AL,[SI]
MOV BL,[DI]
AND AL,0F
AND BL,0F
MOV CL,04
ROR AL,CL
OR AL,BL
MOV [0302],AL
INT A5
RESULT
Input Data
0000:0300

05

0000:0301

08

Output Data
0000:0302

58

Department of Electronics & Communication Engineering

MORE PROGRAMES WITH 8086 ASSEMBLY LANGUAGE

Department of Electronics & Communication Engineering

Program:1

GENERATION OF FIBONACCI SERIES

AIM: To generate Fibonacci series upto a given number by using 8086 assembly
language program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV SI,0300
MOV BL,00
MOV DL,00
MOV AL,01
Up

INC SI
MOV [SI],AL
MOV DL,BL
MOV BL,AL
ADD AL,DL
DEC CL
JNZ

Up

INT A5
RESULT
Input Data
0000:0300

05

Output Data
0000:0301
0000:0302
0000:0303
0000:0304
0000:0305

01
01
02
03
05

Department of Electronics & Communication Engineering

Program:3

1S COMPLIMENT OF A NUMBER

AIM: To find the ones compliment of a given 16-bit data using 8086 assembly language
program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2222
NOT AX
INT A5
RESULT
Input Data
AX

2222

Output Data
DX

DDDD

Department of Electronics & Communication Engineering

Program:4

2S COMPLIMENT OF A NUMBER

AIM: To find the twos compliment of a given 16-bit data using 8086 assembly language
program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2222
NEG AX
INT A5
RESULT
Input Data
AX

2222

Output Data
AX

DDDE

Department of Electronics & Communication Engineering

Program:5

FACTORIAL OF A NUMBER

AIM: To find the factorial of a given 8-bit number by using 8086 assembly language
program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AX,2200
MOV DS,AX
MOV SI,1000
MOV CX,0004
MOV AX,0001
Again

MUL CX
LOOP

Again

MOV [SI],AX
INT A5
RESULT
Input Data
CX

0004

Output Data
2200:1000

18H

Department of Electronics & Communication Engineering

Program:6

SQUARE ROOT OF A NUMBER

AIM: To find the square root of an 8-bit binary data into BCD number by using 8086
assembly language program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV BH,00
MOV BL,[0300]
Up

MOV AL,CL
CMP CL,BL
JG

Down

MUL CL
CMP AX,BX
JZ

Last

INC CL
JMP

Up

Down

MOV CL,00

Last

INT A5

RESULT
Input Data
0000:0300

19

Output Data
CX

0005

Department of Electronics & Communication Engineering

Program:7

SUM OF SQUARES OF N NUMBER

AIM: To find the sum of squares of data string by using 8086 assembly language
program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV SI,[0300]
MOV CL,[SI]
MOV DI,0220
MOV BX,0000
MOV AH,00
Up

INC SI
MOV AL,[SI]
MUL AL
ADD [DI],AX
DEC CL
JNZ

Up

INT A5
RESULT
Input Data
0000:0300
0000:0301
0000:0302
0000:0303
0000:0304
0000:0305

05
01
02
03
04
05

Output Data
BX

0037

Department of Electronics & Communication Engineering

Program:8

SUM OF CUBES OF N NUMBERS

AIM: To find the um of cubes of an array of size 10 by using 8086 assembly language
program.
APPARATUS
1. 8086 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV SI,0200
MOV DI,0220
MO CL,0A
MOV AX,0000
MOV [DI],AX
MOV AL,[SI]
MOV BL,AL
MUL AL
MUL BL
ADD [DI],AX
Up

INC SI
DEC CL
JNZ

Up

INT A5
RESULT
Input Data
0000:0200
0000:0201
0000:0202
0000:0203
0000:0204
0000:0205
0000:0206
0000:0207
0000:0208
0000:0209

Output Data
01
02
03
04
05
06
07
08
09
0A

0220
0221

D1
0b

Department of Electronics & Communication Engineering

Program:

MULTIPLICATION TABLE

AIM: To write an ALP for multiplication table upto10 of a given no. sorted at memory
location 0300 and result from 0301.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV SI,0300
MOV AL,[SI]
MOV CL,0A
MOV AL,01
MOV DL,AL
Up

INC SI
MUL BL
MOV [SI],AL
IN BL
MOV AL,DL
DEC CL
JNZ

Up

INT A5
RESULT:
Input Data
0000:0300

04

Output Data
0000:0301
0000:0302

04
08

Department of Electronics & Communication Engineering

Program:

LCM OF TWO 8 BIT NUMBER

AIM: To write an ALP for LCM of two 8-bit numbers.


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AL,[0300]
MOV BL,[0301]
CMP AL,BL
JAE

Up

XCHG AL,BL
Up

MOV CL,01
MOV DL,AL

Next

MUL CL
MOV [0302],AL
DIV BL
CMP AH,00
JE

Last

MOV AL,CL
INC CL
JMP
Last

Next

INT A5

RESULT:
Input Data
0000:0300
0000:0301
Output Data
0000:0302

04
05
014(H)

Department of Electronics & Communication Engineering

Program:

GCD OF TWO 8-BIT NUMBERS

AIM: To write an ALP to find GCD of two 8-bit numbers.


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV AL,[0300]
MOV BL,[0301]
CMP AL,BL
JAE

UP

XCHG AL,BL
DIV BL
MOV AL,BL
MOV BL,AH
MOV AH,00
CMP BL,00
JE

Next

Up

JMP

Next

INT A5

RESULT:
Input Data
0000:0300
0000:0301

78H
4EH

Output Data
AX

06

Department of Electronics & Communication Engineering

INTERFACING 8086 WITH 8255 PPI

Department of Electronics & Communication Engineering

Program:1

RAMP WAVE GENERATION

AIM: To generate a ramp wave form by interfacing 8255 PPI with 8086 microprocessor.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat

MOV AL,00
MOV DX,8801

Next

OUT DX,AL
INC AL
CMP AL,FF
JB

Next

JMP

Repeat

INT A5
RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address

PORT A

8801

PORT B

8803

PORT C

8805

CWR

8807

Port A is connected to CRO to verify the program output.


Output: Ramp waveform is generated on CRO and the wave form is plotted on graph.
Peak to peak Voltage :
Time period

Department of Electronics & Communication Engineering

Program:2

TRIANGULAR WAVE GENERATION

AIM: To generate a triangular wave form by interfacing 8255 PPI with 8086
microprocessor.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat

MOV AL,00
MOV DX,8801

Next

OUT DX,AL
INC AL
CMP AL,FF
JB

Again

Next

OUT DX,AL
DEC AL
CMP AL,00
JA
JMP
INT A5

Again
Repeat

RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address

PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Triangular waveform is generated on CRO and the wave form is plotted on
graph.
Peak to peak Voltage :
Time period
:
Department of Electronics & Communication Engineering

Program:3

SQUARE WAVE GENERATION

AIM: To generate a square wave form by interfacing 8255 PPI with 8086
microprocessor.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat

MOV AL,FF
MOV DX,8801
OUT DX,AL
CALL

Delay

MOV AL,00
OUT DX,AL
CALL

Delay

JMP

Repeat

DELAY PROGRAM
MOV CX,6D
Back

NOP
NOP
LOOP

Back

RET

Department of Electronics & Communication Engineering

RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address

PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Square waveform is generated on CRO and the wave form is plotted on graph.
Peak to peak Voltage :
Time period

ON period

OFF period

Department of Electronics & Communication Engineering

Program:4

RECTANGULAR WAVE GENERATION

AIM: To generate a rectangular wave form by interfacing 8255 PPI with 8086
microprocessor.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat

MOV AL,FF
MOV DX,8801
OUT DX,AL
CALL

Delay1

MOV AL,00
OUT DX,AL
CALL

Delay2

JMP

Repeat

DELAY PROGRAM
Delay1

MOV CX,6D

Back1

NOP
NOP
LOOP

Back1

RET

Department of Electronics & Communication Engineering

RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address

PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Recatangular waveform is generated on CRO and the wave form is plotted on
graph.
Peak to peak Voltage :
Time period

ON period

OFF period

Department of Electronics & Communication Engineering

PROGRAM:5

TRAFFIC LIGHT CONTROLLER

AIM: To simulate a traffic light control signals by interfacing a traffic light controller kit
with 8086 microprocessor through 8255 PPI.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:

First

MOV AL,80
MOV DX,8806
OUT DX,AL
MOV AL,80
MOV DX,8000
OUT DX,AL
MOV AL,00
MOV DX,8802
OUT DX,AL
MOV AL,61
MOV DX,8004
OUT DX,AL
CALL
Delay2
MOV AL,00
MOV DX,8000
OUT DX,AL
MOV AL,40
MOV DX,8002
OUT DX,AL
CALL
Delay1
MOV AL,40
MOV DX,8000
OUT DX,AL
MOV AL,00
MOV DX,8002
OUT DX,AL
MOV AL,A1
MOV DX,8004
OUT DX,AL
CALL
Delay2
MOV AL,00
MOV DX,8000

Department of Electronics & Communication Engineering

OUT DX,AL
MOV AL,01
MOV DX,8002
OUT DX,AL
CALL
Delay1
MOV AL,02
MOV DX,8000
OUT DX,AL
MOV AL,00
MOV DX,8002
OUT DX,AL
MOV AL,C1
MOV DX,8004
OUT DX,AL
CALL
Delay2
MOV AL,00
MOV DX,8000
OUT DX,AL
MOV DX,8002
OUT DX,AL
CALL
Delay1
MOV AL,01
MOV DX,8000
OUT DX,AL
MOV AL,00
MOV DX,8002
OUT DX,AL
MOV AL,E0
MOV DX,8004
OUT DX,AL
CALL
Delay2
MOV AL,00
MOV DX,8000
OUT DX,AL
MOV AL,20
MOV DX,8002
OUT DX,AL
CALL
Delay1
JMP
First
DELAY PROGRAMS
Delay1
MOV CX,FFFF
JNT AA
RET

Department of Electronics & Communication Engineering

DELAY2 PROGRAM
CALL
CALL
RET

Delay1
Delay1

RESULT:
8255 PPI is interfaced with 8086 in mode 0 with port A, B, and C as output ports.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Output: Traffic light signals are generated on the traffic light controller kit. The delays
between each signal change are verified.

Department of Electronics & Communication Engineering

Program:6

ANALOG TO DIGITAL CONVERSION

AIM: To interface analog to digital converter with 8086 microprocessor through 8255
and display the digital equivalent of the analog input voltage.
APPARATUS:
1.
2.
3.
4.
5.

8086 Trainer kit


Key board
SMPS
CRO
Interfacing cable with probe

PROGRAM CODE:
MOV DX,8807
MOV AL,81
OUT DX,AL
MOV DX,8803
MOV AL,00
OUT DX,AL
MOV DX,8807
MOV AL,09
OUT DX,AL
MOV AL,08
OUT DX,AL
MOV AL,83
OUT DX,AL
INT AC
Repeat
MOV DX,8807
MOV AL,0D
OUT DX,AL
MOV AL,0C
OUT DX,AL
MOV DX,8805
UP
IN AL,DX
AND AL,02
JNZ
Up
Again
IN AL,DX
AND AL,02
JZ
Again
MOV AL,0B
MOV DX,8807
OUT DX,AL
MOV DX,8803
IN AL,DX
MOV CL,AL
MOV DX,8807

Department of Electronics & Communication Engineering

MOV AL,0A
OUT DX,AL
INT AB
MOV AL,02
MOV DX,CX
NOP
MOV DH,00
INT AE
MOV AH,0B
INT A1
AND AL,FF
JZ
Repeat
INT A3
RESULT: 8255 PPI is interfaced with 8086 in mode 0 with port A, B, and C as output
ports.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Output:

Department of Electronics & Communication Engineering

Program:7

STEPPER MOTOR

AIM: Write a program to rotate stepper motor in clock wise direction.


APPARATUS:
1.
2.
3.
4.

8086 Trainer kit


Key board
SMPS
Stepper motor interfacing kit

PROGRAM CODE:.
MOV DX,8006
MOV AL,80
OUT DX,AL
MOV CL,01
MOV DX,8000
MOV AL,88
OUT DX,AL
CALL

Delay

ROR AL,CL
JMP

Up

INT A5
DELAY PROGRAM
Delay

MOV CX,FFFF
INT AA
RET

Department of Electronics & Communication Engineering

PROGRAMMING WITH 8051

Department of Electronics & Communication Engineering

Department of Electronics & Communication Engineering

Program:1

ADDITION OF TWO NUMBERS

AIM: To add tow numbers by using 8051 microcontroller


APPARATUS:
5. 8051 Trainer kit
6. Key board
7. SMPS
PROGRAM CODE;
MOV A,#24
MOV F0,#42
ADD A,F0
RET
RESULT
Input Data
A
B
Output Data
A

24
42
66

Department of Electronics & Communication Engineering

Program:2

SUBTRACTION OF TWO NUMBERS

AIM: To subtraction two numbers by using 8051 microcontroller


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE;
MOV A,#44
MOV F0,#37
CLR C
SUB A,F0
RET
RESULT
Input Data
A
B
Output Data
A

44
37
0D

Department of Electronics & Communication Engineering

Program:3

MULTIPLICATION OF TWO NUMBERS

AIM: To multiply the given two numbers by using 8051 microcontroller


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE;
MOV A,#22
MOV F0,#11
MUL AB
RET
RESULT
Input Data
A
B
Output Data
A
B

22
11
42
02

Department of Electronics & Communication Engineering

Program:4

DIVISION OF TWO NUMBERS

AIM: To multiply the given numbers by using 8051 microcontroller


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE;
MOV A,#22
MOV F0,#11
DIV A
RET
RESULT
Input Data
A
B
Output Data
A
B

22
11
02
00

Department of Electronics & Communication Engineering

Program:5

USE OF SWAP INSTRUCTION

AIM: To show the use of SWAP instruction of 8051 microcontroller


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE;
MOV A,#50
SWAP A
MOV R0,A
RET
RESULT
Input Data
A
Output Data
A

50

05

Department of Electronics & Communication Engineering

Program:6

LARGEST OF TWO NUMBERS

AIM: To find the largest of two numbers using 8051 microcontroller.


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV R0,#05
MOV R1,#08
MOV A,R0
CLR C
SUBB A,R1
JNC

Down

MOV A,R1
RET
Down

MOV A,R0
RET

RESULT:
Input Data
R0
R1

05
08

Output Data
A

08

Department of Electronics & Communication Engineering

Program:7

FACTORIAL OF A NUMBERS

AIM: To find the factorial of a given numbers using 8051 microcontroller.


APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV A,#05
MOV R1,#04
MOV F0,R1
MUL AB
DJNZ R1,FB
RET
RESULT:
Input Data
A
R1

05
04

Output Data
A

78

Department of Electronics & Communication Engineering

Program:8

EQUALIZING THE GIVEN NUMBERS

AIM: To increment and decrement the given two numbers until they are equal using
8051 microcontroller programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV R2,#04
MOV R5,#08
INC R2
Up

MOV A,R2
DEC R5
CJNE A,05

Up

RET
RESULT:
Input Data
A
R1

05
04

Output Data
A

78

Department of Electronics & Communication Engineering

Program:9

SQUARE OF A NUMBERS

AIM: To find the square of a given number using subroutine using 8051 microcontroller
programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV R0,#02
MOV R1,#03
MOV A,R0
LCALL

Routine

RET
SUBROUTINE:
Routine

MOV A,R1
MOV F0,R1
MUL AB
RET

RESULT:
Input Data
R1

03

Output Data
A

09

Department of Electronics & Communication Engineering

Program:10 CUBE OF A NUMBERS


AIM: To find the cube of a given number using 8051 microcontroller programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV R1,#04
MOV A,R1
MOV F0,R1
MUL AB
MOV F0,R1
MUL AB
RET
RESULT:
Input Data
R1

04

Output Data
A

40

Department of Electronics & Communication Engineering

Program:11 UNPACKED TO PACKED BCD CONVERSION


AIM: To pack the given two BCD numbers using 8051 microcontroller programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV A,#04
MOV F0,#05
SWAP A
ADD A,F0
RET
RESULT:
Input Data
A
B

04
05

Output Data
A

45

Department of Electronics & Communication Engineering

Program:12

CHECKING AN NTH BIT

AIM: To check whether n-th bit of given data is 1 or 0 using 8051 microcontroller
programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV A,#10
AND A,#08
JNZ

Down

MOV A,#55
RET
Down

MOV A,#FF
RET

RESULT:
Input Data
A

10

Output Data
A

FF

Department of Electronics & Communication Engineering

Program:13

COMPARE TWO NUMBERS

AIM: To compare two numbers and store 00 in A if data1=data2, FF in A if data1>data2


and 55 in A if data1<data2 using 8051 microcontroller programming.
APPARATUS:
1. 8051 Trainer kit
2. Key board
3. SMPS
PROGRAM CODE:
MOV A,#09
CJNE A,#08

Down

MOV A,#00
RET
Down

JC

Last

MOV A,#FF
RET
Last

MOV A,#55
RET

RESULT:
Input Data
A
09
Data2 in prog. 08
Output Data
A

FF

Department of Electronics & Communication Engineering

Das könnte Ihnen auch gefallen