You are on page 1of 54

1.

A) 8-BIT ARITHMETIC OPERATIONS USING 8085


AIM:
To write an assembly language program in 8085 to add, subtract, multiply and divide two 8 bit
numbers.
APPARATUS REQUIRED:
1. 8085 Microprocessor Kit-1
2. Power supply 5V

8-BIT ADDITION
ALGORITHM:
1. Start the program
2. Initialize the carry register asSTART
00H.
3. Move the data1 and data2 to accumulator and B register respectively.
4. Add B register to the content
[C] of accumulator
5. If there is no carry, go to 00H
step 6, else increment C register.
6. Store the content of accumulator to the memory location.
[HL]
7. Move the content of C register to accumulator.
8500H
8. Store the content of accumulator to the next memory location.
[A]
[M]
9. Stop the program.
PROGRAM:
ADDRESS

OPCODE

LABEL
MNEMONICS
[HL][HL]+1
MVI C,00 H

COMMENTS

8100

0E, 00

8102

3E, data1

8104

06,data2

MVI B,data2

Move data2 to B Register

8106

80

ADD B

Add B Reg to accumulator

8107

D2,0B,81

810A

0C

810B

32,00,80

810E
810F

79
32,01,80

CarryMOV
? A,C
[C][C]+1
STA 8001

Move carry to acc


Store the carry

8112

76

HLT
[HL][HL]+1

Stop the program

MVI A,data1
[A][A]+[M]

GO

JNC GO
Is there
a
INR C
carry?
STA 8000

Clear carry register


Move data1 to accumulator

Jump on No carry to address


Increment C Register
Store the result

OUTPUT:
Input

Memory location
Data 1
Data 2
FLOW CHART:

[M]

[A]

Data
04
[HL][HL]+1
02
[M]

[C]

STOP

Output

Memory location
8000
8001

Data
06
00

NO

YES

8-BIT SUBTRACTION

ALGORITHM:
1. Load the subtrahend from memory to A register and move it to B register.
2. Load the minuend to the accumulator.
3. Clear the C register to account for the sign of result.
4. Subtract the contents of B register from the A register.
5. Check for carry. If carry=0 go to 7th step, else go to next step.
6. Increment C register, and find the 2s complement of the content of accumulator.
7. Store the content of accumulator
and C-register
START
8. Stop the program
PROGRAM:

[C] 00H
LABEL
MNEMONICS

ADDRESS

OPCODE

8100

3A, 00, 82

8103

47

8104

3A, 01, 82

8107

0E, 00

8109

90

SUB B

810A

D2, 11, 81

JNC AHEAD
[HL][HL]+1

810D

0C

INR C

810E

2F

810F

C6,01

8111

32, 02, 82

8114

79

8115

32, 03, 82

8118

76

[A]

LDA 8201H
[M] C,00H
MVI

CMA
[A][A]-[M]

Input

Move the subtrahend in B reg


Load the minuend in A reg.
Clear C register.
Get difference on acc.
If CY=0, go to AHEAD
If CY=1, increment C reg
Take 2s complement of the
result

ADI 01H
AHEAD

STA 8202H

Is there
MOV A,C
a STA 8203H
borrow
HLT
?

Store the result in memory


Store the sign bit in memory
Stop the program

Add 01H to [A]


Output
[C][C]+1
Data
Memory location
06
8202
02
8203
[HL][HL]+1

[M]

[A]

[HL][HL]+1

FLOW CHART:

Load the subtrahend

Complement
Borrow
[A]
?

OUTPUT:
Memory location
8200
8201

LDA 8200H
[HL] 8500H
MOV B,A

COMMENTS

[M]

[C]

STOP

Data
04
00

NO

YES

8-BIT MULTIPLICATION

ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.

Start the program


Clear the Accumulator and load multiplicand to B register.
Load the multiplier in C register.
Clear the D register for carry.
Add the content of B to accumulator until the multiplier becomes zero.
Increment the carry register if carry exists.
Store the product and the carry.
Stop the program

PROGRAM:
ADDRESS

OPCODE

8500

3E, 00

8502

LABEL

MNEMONICS

COMMENTS

MVI A,00

Move data to accumulator

06,data1

MVI B,data1

Move multiplicand to B register

8504

0E,data2

MVI C,data2

Move the multiplier to C register

8506

16,00

MVI D,00

Clear D reg for carry

8508

80

ADD B

repetitive addition

8509

D2, 0D, 85

850C

14

850D

0D

850E

LOOP2

JNC LOOP1
INR D

Increment the D register if there is carry

DCR C

Decrement multiplier

C2, 08,85

JNZ LOOP2

Repeat the loop2 till C reg. becomes zero

8511

32,00,80

STA 8000

Store the product

8514

7A

MOV A,D

8515

32,01,80

STA 8001

Store the carry.

8518

76

HLT

Stop the process.

LOOP1

OUTPUT:
Input

Memory location
Data 1
Data 2

FLOWCHART:

Output

Data
03
02

Memory location
8000
8001

Data
06
00

START
[HL]
8500
B M

[HL] [HL]+1

A 00

C 00

[A] [A] +
[M]
NO

YES

Is there
any
carry?

C C+1

B B-1

IS
B=0?

NO
YES

[HL][HL]+1
[M]

[A]

[HL][HL]+1
[M]

[C]

STOP
8-BIT
DIVISION

ALGORITHM:

1. Start the program


2. Load the divisor to accumulator
3. Load the dividend to B-register
4. Compare the B-register value with the accumulator
5. Jump on carry to step - 9
6. Subtract B-register value with accumulator
7. Increment the C-register and Jump to step 4
8. Store the quotient and the remainder.
9. Stop the program
PROGRAM:

START

ADDRESS

OPCODE

8500

3E,data1

8502

06,data2

8504

0E, 00

8506

B8

8507

DA, 0F, 85

850A

90

850B

0C

850C

C3, 06,85

850F
8512
8513

32,01,80
79
32,00,80

8516

76

LABEL

B 00

[HL]
8500
000
LOOP2
A M

MNEMONICS
MVI A,data1

Move divisor to accumulator

MVI B,data2

Move dividend to B Register

MVI C,00
CMP B
JC LOOP1

[HL] [HL]+1
M A-M

COMMENTS

Clear C register
Compare B reg and accumulator.
Jump on carry to loop1.

SUB B

Repetitive subtraction for division

INR C

Increment C register

JMP LOOP2

LOOP1

STA 8001
MOV A,C
[B] [B] +1
STA 8000
HLT

Jump to loop2
Store the remainder.
Store the quotient.
Stop the process.

IS
A<0?

OUTPUT:

AA+ M
Input

Memory location
Data 1
Data 2

Output

Data
B B-1
04
02
[HL][HL]+1
[M]

[A]

[HL][HL]+1
FLOWCHART:

[M]

[B]

STOP

Memory location
8000
8001

Data
02
00

NO

YES

RESULT:
Thus the assembly language program for 8-bit addition, subtraction, multiplication and division was
executed using an 8085 microprocessor.

1.B)16-BIT ARITHMETIC OPERATIONS USING 8085


16-BIT ADDITION
AIM:

To write an assembly language program in 8085 to add, subtract, multiply and divide two 16-Bit
numbers.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.

Start the program.


Load the first 16 bit data into HL register pair and move it to DE pair.
Load the second 16 bit data in HL register pair.
Clear the accumulator for carry.
Add the content of HL register pair with DE register pair.
Check for carry and if carry exists, store it in carry register.
Store the sum and carry.
Stop the program.

PROGRAM:
ADDRESS
8100
8103
8104

OPCODE
2A, 00, 82
EB
2A, 02, 82

8107

AF

8108

19

8109
810C

D2, 0D, 81
3C

810D

22, 04, 82

8110

32, 06, 82

8113

LABEL

76

MNEMONICS
START
LHLD 8200

XCHG
[L]
LHLD 8202
[8200H]
[H] XRA A
[8201H]
[DE]DAD D
[HL]
JNC RESULT
[L] INR A
[8202H] [H]
RESULT SHLD 8204
[8203H]
STA 8206
[A]00H
HLT

Input

FLOW CHART:

Load first 16-bit data in HL reg pair


Exchange content of DE with HL reg pair
Load second 16-bit data in HL reg pair
Clear the accumulator.
Add the two numbers
If there is no carry store the sum.
Else increment the carry
Store the sum in specified address
Store the carry in specified address
End of program

[HL][HL]+ [DE]

OUTPUT:
Memory location
8200
8201
8202
8203

COMMENTS

Output

Data

Memory location
Is there
8204
a
8205
carry?
8206
Carry?
[A][A]+1

[8204][ L]

[8205] [H]

[8206]

[A]

STOP

Data

NO

YES

16-BIT SUBTRACTION
ALGORITHM:
1. Start the program
2. Load the first 16 bit data in HL register pair and move it to DE reg pair.
3. Load the second 16 bit data in HL register pair.
4. Subtract the lower byte of data first and then higher byte of data.
5. If there is a carry obtain 2S Complement of result.
6. Store the difference and sign bit.

7. Stop the program.


PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

8200

0E, 00

MVI C, 00H

Clear C register

8202

2A, 00, 84

LHLD 8400H

Load the subtrahend in HL reg pair

8205

EB

XCHG

Copy to DE reg pair

8206
8209
820A

2A, 02, 84
7D
93

LHLD 8402
MOV A, L
SUB E

Load the minuend

820B

6F

MOV L, A

Store lower byte result in L register.

820C
820D

7C
9A

MOV A, H
SBB D

Subtract higher order bytes.

820E

67

MOV H, A

Store higher byte result in H register.

820F
8212

D2, 1A, 82
0C

START
JNC
GO
INR C

If CY=0 store the result


Else increments carry register.

8213

7D

8214
8215
8216
8217
8218
8219
821A
821D
821E
8421

2F
6F
7C
2F
67
23
22, 04, 84
79
32, 06, 84
76

L
[L] MOV A,
[8400
H]
[H]
CMA
[8401 H]
MOV L, A
[DE]
MOV A, H
[HL]
CMA
MOV H,A
INX H
[L]
GO
SHLD 8404H
[8402H]
MOV A, C
[H]
STA 8406H
[8403H]
HLT

Subtract lower order bytes

Take 2s complement of result.

Store the result.


.
Store the carry.
End of the program.

OUTPUT:
Input

Memory location
8400
8401
8402
8403
FLOW CHART:

Output

Data

Is thereMemory location
8404
a
8405
borrow
8406
?
borrow
?
[8404][ L]

STOP

Data

[HL][HL]- [DE]

NO
NO
YES

[C][C]+1

[8405] [H]

[8406]

[C]

16-BIT MULTIPLICATION
ALGORITHM:
1. Start the program
2. Load the multiplicand in HL pair register and copy in SP.
3. Load the multiplier in DE reg pair and clear HL and BC reg pair.
4. Add content of SP to HL pair register content.
5. Perform repetitive addition of the multiplicand until the multiplier becomes zero.
6. Store the product.
7. Stop the program.
PROGRAM:
COMMENTS
ADDRESS
OPCODE LABEL
MNEMONICS

8000

2A,50,80

8003

F9

8004

2A,52,80

8007

EB

8008

21,00,00

LXI H, 0000H

800B

01,00,00

LXI B, 0000H

800E

39

800F

LHLD 8050H
SPHL
LHLD 8052
XCHG

LOOP

D2,13,80

DAD SP
JNC NEXT

8012

03

8013

1B

8014

7B

MOV A,E

8015

B2

ORA D

8016

NEXT

SHLD 8054

801C

79

MOV A, C

32,56,80

STA 8056

78

MOV A, B

32,57,80

STA 8057

76

If there is no carry, go to the


instruction labeled NEXT
Decrement DE reg. pair.

22,54,80

8024

Add SP with HL pair.

DCR D

8019

8021

Clear HL & DE reg. pairs.

Increment BC reg. pair

JNZ LOOP

8020

Load the second No. in HL reg. pair


& Exchange with DE reg. pair.

INX B

C2,0E,80

801D

Load the first No. in stack pointer


through HL reg. pair

HLT

Move the content of reg. E to Acc


OR Acc. with D reg.
If there is no zero, go to instruction
labeled LOOP
Store the content of HL pair in
memory locations 8054 & 8055.
Move the content of reg. C to Acc.
Store the content of Acc. in memory
location 8056.
Move the content of reg. B to Acc.
Store the content of Acc. in memory
location 8057.
Stop program execution

OUTPUT:
Input

Memory location
8050
8051
8052
8053

Output

Data

Memory location
8054
8055
8056
8057

Data

FLOWCHART :

START

L
[8050]
H

[8051]

SP HL

[8052]

[8053]

DE
HL
HL0000
BC0000
HLHL+SP

NO

YES

Is Carry
flag set?

[8054]
L
[8055]
H
[8056]
C

BCBC+1

DEDE+1
NO

[8057]
B
STOP

YES
Is Zero

flag set?

16-BIT DIVISION
ALGORITHM:
1. Start the program
2. Load the dividend in HL pair register.
3. Load the divisor in accumulator and move to C register.
4. Subtract the content of the divisor from the dividend until the carry flag is set.
5. Increment the quotient during every time of subtraction.
6. Store the quotient and the remainder.
7. Stop the program.
PROGRAM:
ADDRESS
8100
8103
8106
8107
810A
810B
810C

OPCODE
2A,00, 42
3A,02,42
4F
11,00,00
7D
91
6F

LABEL

810D

D2,11,81

JNC LOOP2

8110
8111
8112
8113

25
13
7C
FE,00

DCR H
INX D
MOV A,H
CPI 00H

8115

C2,0A,81

JNZ LOOP1

8118
8119

7D
B9

MOV A,L
CMP C

811A

D2,0A,81

JNC LOOP1

811D
8120
8121
8124

22,02,83
EB
22,00,83
76

SHLD 8302H
XCHG
SHLD 8300H
HLT

LOOP1

LOOP2

MNEMONICS
LHLD 8200H
LDA 8202H
MOV C,A
LXI D,0000H
MOV A,L
SUB C
MOV L,A

COMMENTS
Load the dividend in HL reg pair
Load the divisor in C register
Clear DE reg pair
Move the content of Acc to L.
Subtract reg. C from that of Acc.
Move the content of Acc to L.
If there is no carry, go to the location
labeled LOOP 2.
Decrement H reg. pair.
Increment the quotient
Move the content of reg. H Acc.
If there is no zero, go to instruction
labeled LOOP1
Move the content of Acc to L.
Compare C & A
If there is no carry, go to the location
labeled LOOP 1.
Store the remainder
Exchange
Store the quotient
Stop the program execution.

OUTPUT:
Input

Memory location
8200
8201
8202
8203

Output

Data

Memory location
8300
8301
8302
8303

Data

FLOWCHART:

START
L
[8200]
H [8201]
HL
DE
L

[8202]

H [8203]

BC 0000H
A
A
E

L; AABCBC- 1

LA

HLHL+DE

AH;
AA- HBorrow;

L[8300]
H[8301]

HA
BCBC+ 1

AC
NO

HA

Is
Carry
flag
set ?

[8302] A
AB

YES

[8303] A

A
STOP

RESULT:
Thus the assembly language program for 16-bit addition, subtraction, multiplication and division was
executed using an 8085 microprocessor.

3.A)ASCENDING ORDER

AIM:
To sort the given number in the ascending order using 8085 microprocessor.
ALGORITHM:
1.
Get the numbers to be sorted from the memory locations.
2.
Compare the first two numbers and if the first number is larger than second then I interchange the
number.
3.
If the first number is smaller, go to step 4
4.
Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:
ADDRESS

OPCODE

8000

06,04

8002

21,00,81

8005

0E,04

8007

7E

8008

LABEL

MNEMONICS

COMMENTS

MVI B,04

Initialize B reg with number of comparisons (n-1)

LXI H,8100

Initialize HL reg. to 8100H

MVI C,04

Initialize C reg with no. of comparisons (n-1)

MOV A,M

Transfer first data to acc.

23

INX H

Increment HL reg. to point next memory location

8009

BE

CMP M

Compare M & A

800A

DA,12,80

JC LOOP1

If A is less than M then go to loop1

800D

56

MOV D,M

Transfer data from M to D reg

800E

77

MOV M,A

Transfer data from acc to M

800F

2B

DCX H

Decrement HL pair

8010

72

MOV M,D

Transfer data from D to M

8011

23

INX H

Increment HL pair

8012

0D

DCR C

Decrement C reg

8013

C2,07,80

JNZ LOOP2

If C is not zero go to loop2

8016

05

DCR B

Decrement B reg

8017

C2,02,80

JNZ LOOP3

If B is not Zero go to loop3

801A

76

HLT

Stop the program

LOOP 3
LOOP2

LOOP1

OUTPUT:
INPUT
MEMORY LOCATION

OUTPUT
DATA

MEMORY LOCATION

8100

8100

8101

8101

8102

8102

8103

8103

8104

8104

FLOWCHART:

DATA

START

[B] 04H
[HL]
[8100H]
[C] 04H
[A] [HL]
[HL [HL] + 1
YES
IS [A] <
[HL]?
NO
[D] [HL]

[HL] [A]

[HL] [HL] - 1

YES

[HL] [D]
[HL] [HL] + 1
[C] [C] NO
01 H

A
B

NO

YES
A

IS
[C]=0?

NO

[C] =
YES
0?
[B] [B]-1

IS
[B]=0?
[B] =
0?
STOP

RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending order.

3.B) DESCENDING ORDER


AIM:
To sort the given number in the descending order using 8085 microprocessor.
ALGORITHM:
1.
Get the numbers to be sorted from the memory locations.
2.
Compare the first two numbers and if the first number is smaller than second then I
interchange the number.
3.
If the first number is larger, go to step 4
4.
Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS
START

8000

06,04

8002

21,00,81

8005

0E,04

8007

7E

8008

COMMENTS

MVI B,04

Initialize B reg with number of comparisons (n-1)

LXI H,8100

Initialize HL reg. to 8100H

MVI C,04

Initialize C reg with no. of comparisons (n-1)

MOV
A,M
[HL]

Transfer first data to acc.

23

[8100H]
INX
H

Increment HL reg. to point next memory location

8009

BE

CMP M

Compare M & A

800A

D2,12,80

JNC LOOP1

If A is greater than M then go to loop1

800D

56

MOV
[A] D,M
[HL]

Transfer data from M to D reg

800E

77

MOV M,A

Transfer data from acc to M

800F

2B

[HL
[HL]
DCX
H +1

8010

72

MOV M,D

Transfer data from D to M

8011

23

INX H

Increment HL pair

8012

0D

8013

C2,07,80

JNZ LOOP2

If C is not zero go to loop2

8016

05

DCR B

Decrement B reg

8017

C2,02,80

JNZ LOOP3

If B is not Zero go to loop3

801A

76

HLT

Stop the program

LOOP 3
LOOP2

[B] 04H

[C] 04H

LOOP1

IS [A] <
DCR
C
[HL]?

[D] [HL]

Decrement HL pair

Decrement C reg

[HL] [A]

OUTPUT:
INPUT
MEMORY LOCATION
8100
8101
8102
8103
8104
FLOWCHART:

[HL] [HL] - 1

DATA
[HL] [D]
[HL] [HL] + 1

[C] [C] 01 H

OUTPUT
MEMORY LOCATION
8100
8101
8102
8103
8104

DATA

NO

YES

IS
[C]=0?

[C] =
0?
[B] [B]-1

IS
[B]=0?
[B] =
0?
STOP

NO

YES

YES

RESULT:
Thus the descending order program is executed and thus the numbers are arranged in descending
order.

3.B) LARGEST ELEMENT IN AN ARRAY


AIM:
To find the largest element in an array.

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

OPCODE LABEL

MNEMONICS

COMMENTS

8001

21,00,81

LXI H,8100

Initialize HL reg. to 8100H

8004

06,04

MVI B,04

Initialize B reg with no. of comparisons(n-1)

8006

7E

MOV A,M

Transfer first data to acc.

8007

23

INX H

Increment HL reg. to point next memory location

8008

BE

CMP M

Compare M & A

8009

D2,0D,80

JNC LOOP

If A is greater than M then go to loop

800C

7E

MOV A,M

Transfer data from M to A reg

800D

05

DCR B

Decrement B reg

800E

C2,07,08

JNZ LOOP1

If B is not Zero go to loop1

8011

32,05,81

STA 8105

Store the result in a memory location.

8014

76

HLT

Stop the program

LOOP1

LOOP

OUTPUT:
INPUT
MEMORY LOCATION
8100
8101
8102
8103
8104

FLOW CHART:

OUTPUT
DATA

MEMORY LOCATION
8105

DATA

START

[HL]
[8100H]
[B] 04H
[A] [HL]
[HL [HL] + 1
NO
IS [A] <
[HL]?

YES

[A] [HL]
[B] [B]-1

NO
IS [B]
= 0?
YES
YES
[8105] [A]
STOP

RESULT:
Thus the largest number in the given array is found out.

SMALLEST ELEMENT IN AN ARRAY


AIM:
To find the smallest element in an array.
ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.

2.
3.
4.
5.
6.
7.

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

PROGRAM:
ADDRESS

OPCODE LABEL

MNEMONICS

COMMENTS

8001

21,00,81

LXI H,8100

Initialize HL reg. to 8100H

8004

06,04

MVI B,04

Initialize B reg with no. of comparisons(n-1)

8006

7E

START
MOV
A,M

Transfer first data to acc.

8007

23

INX H

Increment HL reg. to point next memory location

8008

BE

[HL]
CMP
M

Compare M & A

8009

DA,0D,80

JC LOOP

If A is lesser than M then go to loop

800C

7E

MOV
[B] A,M
04H

Transfer data from M to A reg

800D

05

DCR B

Decrement B reg

800E

C2,07,08

[A]LOOP1
[HL]
JNZ

If B is not Zero go to loop1

8011

32,05,81

STA 8105

Store the result in a memory location.

8014

76

LOOP1

[8100H]

LOOP

[HL [HL] + 1

HLT

Stop the program

OUTPUT:
INPUT
MEMORY LOCATION

IS [A] <
[HL]?

DATA

8100
8101
8102

FLOW CHART:

MEMORY LOCATION
8105

[A] [HL]

8103
8104

OUTPUT

[B] [B]-1

IS [B]
= 0?

[8105] [A]

STOP

DATA

YES

NO
NO

NO

YES

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

7.PROGRAMMABLE COMMUNICATION INTERFACE WITH 8085


AIM:
To interface 8251 with 8085 to transmit & receive data using interface card.
APPARATUS REQUIRED:

S.NO

APPARATUS

SPECIFICATION

QUANTITY

Microprocessor

8085 system

Power supply

+5V

Interface board

VBMB-004

Bus

VXT

CIRCUIT DIAGRAM

MODE WORD FORMAT:


D7

D6

D5

BAUD RATE FACTOR:


D0

D1

SYNCMODE.

ASYNC * 1

ASYNC * 16

ASYNC * 64

CHARACTER LENGTH:
D2

D3

5BITS

6BITS

D4

D3

D2

D1

D0

7BITS

8BITS

PARITY CONTROL:
D4

D5

NO PARITY

ODD PARITY

EVEN PARITY

FRAMING CONTROL:
D6

D7

NOT VALID

1 STOP BIT

1 STOP BIT

2 STOP BIT

COMMAND WORD FORMAT:

EH

IR

RTS

ER

EH->Enable hunt mode

1-enable

IR->Internal reset

1-Reset

SBRK

RXE

DTR

RTS->Request to send

1-enable RTS.

ER->Error reset

1-Reset error flag.

SBRK->Send break character

1-Force txd low & 0-Normal operation.

RE->Receive enables

1-Enable. & 0-Disable.

DTR->Data transmit ready

1-Enable

TXEN->Transmit enable

1-Enable

TXEN

STATUS WORD FORMAT:


DST

SYNDET

FE

DSR ->It indicates that DSR is Zero.

OE

PE

TXEN
RDY

RXRDY

TXRRDY

FE

->Framing Error sets when a valid stop bit is not detected and reset by ER Command.

OE -> Overrun error reads the character before it is available. It is reset by ER bit in Command word.
PE -> Parity error, 1-Enable parity error reset by ER bit of command word.
RS 232 C
PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

8100

3E , 36

MVI A , 36

8102

D3 , CE

OUT 0CEH

8104

3E ,0A

MVI A,0A

8106

D3 , C8

OUT 0C8H

8108

3E ,00

MVI A,00

810A

D3 ,C8

OUT 0C8H

810C

3E ,4E

MVI A,4E

810E

D3 ,C2

OUT 0C2H

8110

3E ,37

MVI A, 37H

8112

D3,C2

OUT 0C2H

8114

3E ,41

MVI A, 41H

8116

D3 ,C0

OUT 0C0H

8118

CF

8200

DB, C0

8202

32 ,50 , 82

8205

CF

COMMENTS
Mode set for 8253

Mode for 8251


command instruction
Send the data

RST 1
IN 0C0H
STA 8250H
RST 1

Receive the data


Store the data

RESULT:
Thus the 8251 is interfaced with 8085 and 8086 and the data was transmitted & received using
interface card.

TIMER AND KEYBOARD/DISPLAY INTERFACE USING 8085


TIMER INTERFACE
AIM:
To generate a square waveform using timer interface 8253.

PIN CONFIGURATION OF 8253:

CONTROL FORMAT:
SC1

SC0

SCO

SC1

RL1

RL0

M2

M1

M0

RL1

RL2

=Counter 0

=Counter latch

=Counter 1

=LSB

=Counter 2

=MSB

=X

=LSB/MSB

M2

M1

M0

MODE

Interrupt on Terminal Count

Programmable One shot

Rate Generator

Square wave generator

BCD

BCD:
0=Binary count (16 bit)
1=BCD (11 decoder)
To generate a square wave the control word is formed for a counter 0, using LSB/MSB, Mode3 and
a binary count. The Control word is now 36 H.
0

Count value = Required Period / Period


PROGRAM FOR 8085
ADDRESS

OPCODE

LABLE

MNEMONICS

COMMENTS

8100

3E, 36

START

MVI A,36H

8102

D3, CE

OUT CEH

8104

3E, 0A

MVI A,0AH

8106

D3, C8

OUT C8H

8108

3E, 00

MVI A,00H

810A

D3, C8

OUT C8H

810C

76

HLT

Initialize timer in channel 0 and


in mode3
Move LSB to counter
Move MSB to counter
Stop the program

RESULT:
Thus using the timer interface 8253 square waveform is generated.

KEYBOARD AND DISPLAY INTERFACE - 8279


AIM:
To interface a keyboard and a display with 8085 microprocessor and write assembly language
program for displaying a character and reading the scan code of a key.

DISPLAYING A CHARACTER:
ADDRESS

OPCODE

LABLE

8100

3E, 00

8102

MNEMONICS

COMMENTS

MVI, 00H

Keyboard/display mode setup


word

D3 ,C2

OUT C2H

Out to the control word register

8104

3E,CC,00

MVI A, CCH

Clear display control word

8106

D3 , C2

OUT C2H

Out to the control word register

8108

3E ,90

MVI A, 90H

Control word to select the row


address of the display RAM and
auto increment.

810A

D3 , C2

OUT C2H

Out to the control word register

810C

3E , 88

MVI A, 88

Display A

810E

D3, C0

OUT C0

8110

3E , FF

MVI A, FF

8112

D3, C0

OUT C0

8114

D3 , C0

OUT C0

8116

D3 , C0

OUT C0

8118

D3 , C0

OUT C0

811A

D3 , C0

OUT C0

811C

76

HLT

Blank the rest of the display

End of the program

TO READ A KEY AND STORE THE KEYCODE IN MEMORY LOCATION


ADDRESS

OPCODE

8100

DB, C2

8102

LABLE
LOOP

MNEMONICS

COMMENTS

IN C2H

Read the FIFO status word

E6, 07

ANI 07H

Check for a key press

8104

CA,00,81

JZ LOOP

Close not met

8107

3E, 40

MVI A, 40H

Command

word for reading

RAM
8109

D3 , C2

OUT C2H

Out put to the command word


register

810B

DB, C0

IN C0H

Read the FIFO data from the


register with address C0

810D

32, 00, 42

STA 8200H

Store the value in a memory

8110

76

HLT

End of the program

RESULT:
Thus a keyboard and a display are interfaced with 8085 microprocessor and the assembly
language program for displaying a character and reading the scan code of a key is written.

ARITHMETIC OPERATIONS USING 8051


Ex.No: 9
,

AIM:

Date:

To perform 16-bit addition, 8-bit subtraction, 8-bit multiplication and division using 8051 micro
controller.

16 BIT ADDITION:
ALGORITHM:
1.Get the LSB of the first operand and add with the LSB of the second operand.
2.Store the LSB of the result.
3.Get the MSB of the first operand and add with the MSB of the second operand.
4.Store the result.
5.Stop the program.
PROGRAM:
ADDRESS

OPCODE

LABLE

9100

C3

CLR C

Clear the carry flag

9101

74,32

MOV A,#DATA L1

Move LSB1 to A

9103

24,CD

ADD A,#DATA L2

Add LSB2 with A

9105

90,91,50

MOV DPTR,#4150

Initialize data pointer

9108

F0

MOVX @DPTR, A

Accumulator content is
immediately moved to DPTR

9109

A3

INC DPTR

Increment DPTR

910A

74,54

MOV A,#DATA M1

Move MSB1 to A

910C

34,AB

ADDC A,# DATA M2

Add MSB2 to A with carry

910E

F0

MOVX @DPTR, A

Accumulator content is
immediately moved to DPTR

910F

80

9110

FE

here

MNEMONICS

COMMENTS

SJMP here
Stop the program

8 BIT SUBTRACTION
PROGRAM:
ADDRESS

OPCODE

9100

C3

LABLE

MNEMONICS
CLR C

COMMENTS
Clear the carry flag

9101

74,C2

MOV A,#DATA1

Move data1 to A

9103

94,02

SUBB A,#DATA2

Data2 is subtracted
accumulator

9105

90,45,00

MOV DPTR,#9500

Initialize DPTR

9108

F0

MOVX @DPTR,A

Move accumulator content to


DPTR

9109

80

910A

FE

here

from

SJMP here
Stop

8 BIT MULTIPLICATION
PROGRAM:
ADDRESS

OPCODE

LABLE

9100

74,FF

MOV A,#DATA1

Move data1 to A register

9102

75,F0,FF

MOV B, #DATA2

Move data2 to B register

9105

A4

MUL A,B

Multiply A and B register

9106

90,95,00

MOV DPTR,
#9500

Initialize the DPTR

9109

F0

MOVX @DPTR,A

Move LSB in A to DPTR

910A

A3

INC DPTR

Increment DPTR

910B

E5,F0

MOV A,B

Move the content of B to A

910D

F0

MOVX @DPTR,A

Move A to DPTR

910E

80

910F

FE

Here

MNEMONICS

COMMENTS

SJMP here
Stop the program

8BIT DIVISION
PROGRAM:
ADDRESS

HEXCODE

LABEL

MNEMONICS

COMMENT

9100

74,65

MOV A,#DATA1

Move data1 to register A

9102

75,F0,08

MOV B,#DATA2

Move data2 to B by B register

9105

84

DIV A,B

Divide A by B

9106

90,95,00

MOV DPTR,#9500

Move 9500toDPTR

9109

F0

MOV @DPTR,A

Move content A to DPTR

910A

A3

INC DPTR

Increment DPTR

910B

E5,F0

MOV A,B

Move the content of B to A

910D

F0

MOVX @DPTR,A

Move content in A to DPTR

910E

80

SJMP here

Stop the program

910F

FE

here

RESULT:
Thus 16 bit addition, 8 bit subtraction ,8 bit multiplication and division were executed using 8051
microcontroller.

EX.NO: 10
DATE :

TRANSMISSION AND RECEPTION OF A


CHARACTER USING 8085 & 8253

AIM:
To write a program for the transmission and reception of a character between 8085 and 8253/8251.

APPARATUS REQUIRED:

1. 8085 Microprocessor Kit


2. 8253/8251 Interface Kit
3. Power supply 5V
4. Keyboard

ALGORITHM:
1. Type the transmission program and execute the program
2. Type the reception of a character and execute
3. To check the reception of a character.

PROGRAM:
FOR TRANSMITTING A CHARACTER:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9000

3E,36

MVI A,36H

Move immediate data to Acc

9002

D3,CE

OUT OCEH

Out data to control register

9004

3E,0A

MVI A,0AH

Move immediate data to Acc

9006

D3,C8

OUT OC8H

Out data to control register

9008

3E,00

MVI A,00H

Clear A register

900A

D3,C8

OUT OC8H

Out data to control register

ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

900C

3E,4E

MVI A,4EH

Move immediate data to Acc

900E

D3,C2

OUT OC2H

Out data to control register

9010

3E,37

MVI A,37H

Move immediate data to Acc

9012

D3,C2

OUT OC2H

Out data to control register

9014

3E,50

MVI A,50H

Move immediate data to Acc

9016

D3,C0

OUT OC0H

Out data to control register

9018

CF

RST

Reset

FOR RECEIVING A CHARACTER:


ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9100

DB,C0

IN 0C0H

Move input data to control reg

9102

32,50,41

STA 9150H

Store the result in Accumulator

9105

CF

RST

Reset

RESULT:
Thus the transmission and reception of a character between 8085 and 8253/8251 was executed and
verified successfully.

EX.NO: 11

KEYBOARD AND DISPLAY INTERFACE WITH 8051

DATE :

AIM:
To perform interfacing of keyboard and seven segment display with 8051.

APPARATUS REQUIRED:
1. 8081 Microprocessor Kit

2. 8279 Interface board


3. Power supply 5V
4. Keyboard

ALGORITHM:
1. Assemble the program
2. Execute it and press any key in keyboard and then view the result in the accumulator
3. Before pressing any key in keyboard execute the program once.

KEYBOARD PROGRAM:
ADDRESS

OPCODE

LABEL

9000

90,60,61

MOV DPTR,#6061

Control & status register

9003

74,12

MOV A,#12H

Control word

9005

F0

MOVX @DPTR,A

Out to 8279

9006

74,3E

MOV A,#3EH

For freq division

9008

F0

MOVX @DPTR,A

Out to 8279

9009

74,A0

MOV A,#A0H

Display/write inhibit

900B

F0

MOVX @DPTR,A

Out to 8279

900C

90,60,61

900F

E0

LOOP1

MNEMONICS

COMMENTS

MOV DPTR,#6061
MOVX A,@DPTR

Read the status 8279

ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9010

54,07

ANL A,#07H

9012

60,F8

JZ 900C (LOOP1)

If zero loop back

9014

90,60,60

MOV DPTR,#6060

Read key code data

9017

E0

MOVX A,@DPTR

9018

54,3F

ANL A,#3FH

Suppress unwant bits

901A

12,00,BB

LCALL 00 BBH

Break Point

DISPLAY PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9200

79,60

MOV R1,#60H

7 Segment code for 2

9202

90,60,61

MOV DPTR,#6061H

Control & status register

9205

74,12

MOV A,#12H

Control word

9207

F0

MOVX @DPTR,A

Out to 8279

9208

74,3E

MOV A,#3EH

For freq division

920A

F0

MOVX @DPTR,A

Out to 8279

920B

74,A0

MOV A,#A0H

Display/write inhibit

920D

F0

MOVX @DPTR,A

Out to 8279

920E

78,08

MOV R0,#08H

8 Digit count

9210

74,00

MOV A,#00H

9212

90,60,60

MOV DPTR,#6060H

9215

F0

9216

D8,FD

DJNZ R0,9215H(L1)

Clear all digit

9218

E9

MOV A,R1

7 Segment code to be
displayed

9219

F0

MOVX @DPTR,A

Out to 8279

LOOP1

LOOP2

Data register address

MOVX @DPTR,A

ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

921A

80,FD

SJMP 9219H(L2)

921C

12,00,BB

LCALL 00 BBH

Break Point

OUTPUT:
7 SEGMENT CODES FOR 0 TO F:

FC

60

BA

F2

66

D6

DE

70

FE

76

7E

CE

9C

EA

9E

1E

7 SEGMENT CODE FORMAT:


Character

Hex code

FC

60

a
f

b
g

.h

RESULT:
Thus the interfacing of keyboard and seven segment display with 8051 were executed and verified
successfully.

EX.NO: 12

ANALOG TO DIGITAL CONVERSION

DATE :

AIM:
To write an assembly language program to perform analog to digital conversion using 8051.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. ADC Interface Kit
3. Power supply 5V
4. Keyboard
PROCEDURE:
1. Assemble the program
2. Vary the pot in the adc chord
3. Execute it and view the output count in the accumulator, which will be displayed in the LCD
display

4. Every time you vary the pot, execute the program and measure the count value in the
accumulator.
5. Repeat the above step for different inputs in the pot
6. After enough of readings have been taken reduce the pot to its minimum value
7. Switch off the power supply and remove all the connections.

ADC PROGRAM:
ADDRESS

OPCODE

LABEL

9000

90,60,03

MOV DPTR,#6003H

Out it in Control register

9003

74,90

MOV A,#90H

CWR for port A as I/P port


and port C as O/P

9005

F0

MOVX @DPTR,A

9006

90,60,02

MOV DPTR,#6002H

Port c is enabled for WR

9009

74,FF

MOV A,#FFH

Start of conversion

900B

F0

MOVX @DPTR,A

900C

90,60,02

MOV DPTR,#6002H

900F

74,00

9011

F0

MOVX @DPTR,A

9012

90,60,02

MOV DPTR,#6002H

9015

74,FF

MOV A,#FFH

9017

F0

MOVX @DPTR,A

9018

12,90,22

LCALL 9022H

Delay routine

901B

90,60,00

MOV DPTR,#6000H

Port A as I/P

901E

E0

MOV A, @DPTR

Read the ADC value

901F

12,00,BB

LCALL 00 BBH

Break Point

LOOP1

MNEMONICS

COMMENTS

MOV A,#00H

DELAY SUBROUTINE:
ADDRESS

OPCODE

9022

79,FF

9024

00

9025

LABEL

MNEMONICS

COMMENTS

MOV A,#FFH

Delay Count

NOP

No Operation

00

NOP

No Operation

9026

00

NOP

No Operation

9027

00

NOP

No Operation

9028

00

NOP

No Operation

9029

00

NOP

No Operation

902A

00

NOP

No Operation

902B

D9,F7

DJNZ 9024(LOOP1)

902D

22

RET

LOOP1

Return To Main Program

OUTPUT:

S.NO
1
2
3
4
5
6

ANALOG INPUT

DIGITAL OUTPUT

RESULT:
Thus the analog to digital conversion using 8051 was executed and verified successfully.

EX.NO: 13

DIGITAL TO ANALOG CONVERSION

DATE :

AIM:
To write an assembly language program to perform digital to analog conversion using 8051.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. DAC Interface Kit
3. Power supply 5V
4. Keyboard
PROCEDURE:
1.
2.
3.
4.
5.

Assemble the program


Give the digital data in the software program itself.
Execute it and view the output through the multi-meter at the connector in the dac cord
For different values of the digital data you will get different values in the multi-meter
Switch off the power supply and remove all the connections

DAC PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9000

74,80

MOV A,#80H

CWR for all Port O/P

9002

90,60,03

MOV DPTR,#6003H

Out it in Control Register

9005

F0

MOVX @DPTR,A

9006

74,80

MOV A,#80H

Given I/P data

9008

90,60,01

MOV DPTR,#6001H

Out Port B

900B

F0

MOVX @DPTR,A

ADDRESS

OPCODE

900C

12,00,BB

LABEL

MNEMONICS

COMMENTS

LCALL 00BBH

Break point

OUTPUT:

S.NO

DIGITAL INPUT

ANALOG OUTPUT

1
2
3
4
5

RESULT:
Thus the digital to analog conversion using 8051 was executed and verified successfully.

DC MOTOR INTERFACING WITH 8051


EX.NO: 14
DATE :

AIM:
To perform stepper motor control using 8051 microcontroller.

APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. DC motor interfacing board
3. Power supply 5V
4. Keyboard
PROCEDURE:
1.
2.
3.
4.
5.

Assemble the program


Give the digital data in the software program itself.
Execute it and view the output through control by dc motor
For different values of the digital data you will get different speed in the motor
Switch off the power supply and remove all the connections

DC MOTOR PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9000

74,80

MOV A,#80H

CWR for all Port O/P

9002

90,60,03

MOV DPTR,#6003H

Out it in Control Register

9005

F0

MOVX @DPTR,A

9006

74,80

MOV A,#80H

Given I/P data

9008

90,60,01

MOV DPTR,#6001H

Out Port B

900B

F0

MOVX @DPTR,A

900C

12,00,BB

LCALL 00BBH

Break point

RESULT:
Thus the DC motor was interfaced successfully with 8051 and verified.

EX.NO: 15

STEPPER MOTOR INTERFACING WITH 8051

DATE :

AIM:
To perform stepper motor control using 8051 microcontroller.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit-1
2. Power supply 5V
3. Keyboard-1
4. Serial interface cable
5. Stepper motor
6. Stepper motor interfacing board
ALGORITHM:
1.
2.
3.
4.
5.

Store the switching sequence values at memory location


Initialize the counter for number of values
Get the value and give it to rotate the motor
Provide sometime delay using delay routine
Check whether all the sequence are given / not repeat step 3 and 4.

PROGRAM:
CLOCK WISE DIRECTION:

ADDRESS

OPCODE

LABEL

9000

90,60,03

MOV DPTR,#6003

9003

74,80

MOV A,#80H

9005

F0

MOVX @DPTR,A

9006

90,60,00

MOV DPTR,#6000

9009

74,05

900B

F0

MOVX @DPTR,A

900C

12,90,24

LCALL 9024(DELAY)

Call Delay

900F

74,07

MOVX A,@ #07H

Second step sequence

9011

F0

MOVX @DPTR,A

9012

12,90,24

LCALL 9024(DELAY)

Delay

9015

74,06

MOV A,#06H

Third step sequence

9017

F0

MOVX @DPTR,A

9018

12,90,24

LCALL 9024(DELAY)

Delay

901B

74,04

MOV A,#04H

Fourth sequence

901D

F0

MOVX @DPTR,A

901E

12,90,24

LCALL 9024(DELAY)

Delay

9021

02,90,09

LJMP 9009(LOOP1)

Repeat

LOOP1

MNEMONICS

MOV A,#05H

COMMENTS

Control port
All bits outputs
First step sequence

ANTI CLOCK WISE DIRECTION:


ADDRESS

OPCODE

9000

90,60,03

LABEL

MNEMONICS

MOV DPTR,#6003

COMMENTS

Control port

ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

9003

74,80

MOV A,#80H

9005

F0

MOVX @DPTR,A

9006

90,60,00

MOV DPTR,#6000

9009

74,04

900B

F0

MOVX @DPTR,A

900C

12,90,24

LCALL 9024(DELAY)

Call Delay

900F

74,06

MOVX A,@ #06H

Second step sequence

9011

F0

MOVX @DPTR,A

9012

12,90,24

LCALL 9024(DELAY)

Delay

9015

74,07

MOV A,#07H

Third step sequence

9017

F0

MOVX @DPTR,A

9018

12,90,24

LCALL 9024(DELAY)

Delay

901B

74,05

MOV A,#05H

Fourth sequence

901D

F0

MOVX @DPTR,A

901E

12,90,24

LCALL 9024(DELAY)

Delay

9021

02,90,09

LJMP 9009(LOOP1)

Repeat

LOOP2

MOV A,#04H

All bits outputs


First step sequence

DELAY SUBROUTINE:
ADDRESS

OPCODE

LABEL

MNEMONICS

9024

79,0A

MOV R1,#0AH

9026

74,40

LOOP3

MOV A,#40H

9028

00

LOOP4

NOP

9029

00

NOP

902A

00

NOP

902B

00

NOP

902C

14

DEC A

COMMENTS

Changing the speed of


rotation

ADDRESS

OPCODE

LABEL

MNEMONICS

902D

70,F9

JNZ 9028(LOOP4)

902F

D9,F5

DJNZ R1,9026(LOOP3)

9031

22

RET

COMMENTS

RESULT:
Thus the stepper motor was interfaced successfully with 8051 and the full step rotation for both
clockwise and anti-clockwise was verified.

You might also like