You are on page 1of 117

T.J.

S ENGINEERING COLLEGE
T.J.S NAGAR, KAVARAIPETTAI-601 206

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

LABORATORY MANUAL

EC6513 MICROPROCESSOR AND MICROCONTROLLER LAB


MANUAL
(R-2013)

YEAR/ SEMESTER

: III / V

DEPARTMENT

: ECE

ACADEMIC YEAR

: 2016-2017 ODD SEMESTERS

BATCH

: 2014-2018

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 2s complement of a number
16. Unpacked BCD to ASCII

ADDITION OF TWO BYTE DATA


AIM:
To write an assembly language program for addition of two
byte data and store the result in memory.
APPARATUS REQUIRED:

1.8086 Trainer kit


2. Power supply
FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA

ADD TWO DATA

STORE RESULT

STOP

Algorithm:

Initialize the pointer to the memory for data and result.


Load data to ax, bx.
Add two data.
Store the result.

Input

:
Input data (2bytes) to be added in

1500
LSB in 1500, MSB in 1501 - 1st data
LSB in 1502, MSB in 1503 - 2nd data

Output

:
Result in 1520
LSB in 1520, MSB in 1521
PROGRAM

Address
1100

Opcode
BE 00 15

1103

Mnemonics
MOV SI, 1500

AD

LODSW

1104

89 C3

MOV BX,

1106

AD

LODSW

1107

01 C3

ADD BX,

AX

AX
1109

BF 20 15

MOV DI, 1520

110C

89 1D

MOV [DI],BX

110E

CC

INT

RESULT:
Thus ALP was written and addition of two byte data was
obtained using 8086 microprocessor kit

SUBTRACTION OF TWO BYTE DATA


AIM:
To write an assembly language program for subtraction of two
byte data and store the result in memory.
APPARATUS REQUIRED:

1.8086 Trainer kit


2. Power supply

FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA

SUBTRACT TWO DATA

STORE RESULT

STOP

Algorithm:

Initialize the pointer to the memory for data and result.


Load data to ax, bx.
Result in 1520 ax, bx.
Subtract two data.
Store the result.
Input

input data (2bytes) to be added in

1500
LSB in 1500, MSB in 1501 - 1 st data
LSB in 1502,
Output

LSB

MSB in 1503 - 2nd data

in 1520, MSB in 1521 result

PROGRAM:
Address
1100
1103

Opcode
BE 00 15

Mnemonics
MOV SI, 1500

AD

LODSW

1104

89 C3

MOV BX,

1106

AD

LODSW

1107

29 C3

SUB BX,

AX

AX
1109

BF 20 15

MOV DI, 1520

110C

89 1D

MOV [DI], BX

110E

CC

INT

RESULT:
Thus ALP was written and subtraction of two byte data was
obtained using 8086 microprocessor kit

MULTIPLICATION OF TWO BYTE DATA


AIM:
To write an assembly language program for multiplication of
two byte data and store the result in memory.
APPARATUS REQUIRED:

1.8086 Trainer kit


2. Power supply

FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA

MULTIPLY TWO DATA

STORE RESULT

STOP

Algorithm:

Initialize the pointer to the memory for data and result.

Load the multiplier in 1500


Load Multiplicand in bx
Multiply two data.
Store the result.
Input

:
Input data (2bytes) in 1500
Load the multiplier in 1500
Load the multiplicand in 1502

Output

PROGRAM
Address
Mnemonics
1200
MOV SI, 1500

Result in 1520

:
Opcode
BE 00 15

1203

AD

LODSW
1204
MOV BX, AX

89 C3

1206

AD

1207

F7 E3

LODSW
MUL BX
1209
MOV DI, 1505

BF 05 15

120C
MOV [DI], AX

89 05

120E

47

INC DI
120F

47

INC DI
1210
MOV [DI], DX
1212

89 15
CC

INT 3

RESULT:
Thus ALP was written and multiplication of two byte data was
performed using 8086 microprocessor kit

DIVISION OF TWO BYTE DATA


AIM:
To write an assembly language program for division of two
byte data and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply

FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA

DIVIDE TWO DATA

STORE RESULT

STOP

Algorithm

Initialize the pointer to the memory for data and result.


Load the dividend in ax
Load the divisor in cx
Divide two data.
Store the result.
Input

:
Dividend in ax
Divisor in cx

Output

:
Result

in 1500

Quotient

in 1500

Remainder
PROGRAM
Address
Mnemonics
1300
0000

in 1503

:
Opcode
BA 00 00

MOV DX,

1303
AX, FFFD

B8 FD FF

MOV

1306
CX, OF

B9 0F 00

MOV

1309
CX

F7 F1

DIV

130B
DI, 1500

BF 00 15

MOV

130E
[DI], AL

88 05

MOV

1310
DI
1311
MOV [DI] ,AH
1313
DI
1314
[DI], DX
1316
3

47

INC

88 25
47

INC

89 15

MOV

CC

RESULT:
Thus ALP was written and division of two byte data was
performed using 8086 microprocessor kit

INT

BLOCK MOVE FROM ONE LOCATION TO ANOTHER

AIM:
To write an assembly language program to move a block from
one location to another location
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
CL=COUNT LOAD DATA
IN AL

LOAD NEXT DATA IN AL

TRANSFER TO DESIRED
LOCATION
CL=CL-1

NO
YES

IF
CL
=
0
STORE RESULT

STOP

Algorithm :
1. Initialize the pointer to the memory Where
data to be transformed
2. Load the al register with the data from
memory.
3. Initialize destination pointer to the memory
Where data to stored.
4. Store data from al register.

Input

Input data from address 1400 which is pointed si,


transferred to the desired location
Number of bytes in cl

Output

:
Output - data in address 1450 is the

moved data.
PROGRAM

Address

Opcode

Mnemonics
1000

B1

08

1002

BE 0014

1005

BF 50 14

1008

AC

MOVE CL, 08
MOV SI, 1400
MOV DI, 1450
LODSB
1009

88 05

100B

47

100C

FE C9

MOV [DI], AL

DEC CL

100E
JNZ 1008

CC

INC DI
75 C8
1010

INT 3

RESULT:
Thus ALP for moving the block from one location to another
location was written and executed using 8086 microprocessor kit

SEARCHING

AIM:
To write an assembly language program for searching a byte
and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
STAR
T

FLOW CHART:

INITIALIZE MEMORY
POINTER
CL=COUNT, DL=SEARCH
BYTE
LOAD DATA IN AL

NO
CL=CL-1

IF
AL=DL
YES
STORE SEARCHED BYTE &
LOCATION

STOP

Algorithm :
1. Initialize the pointer to the memory for
storing data and result.
2. Load dl with search byte
3. Load cl with count
4. Load al with data from memory
5. Compare al with dl if its equal store the result
else decrement counts go to step2
6. Store the result.
Input

Output

PROGRAM

(Search the byte) A in 50 locations from 1200

Store the result byte in 1300

Address

Opcode

Mnemonics

1500

BF 00 13

MOV DI, 1300

1503

BE 00 12

MOV SI, 1200

1506

B1 50

MOV CL, 50

1508

B2 0A

150A

AC

150B

38 C2

150D

74 05

JZ 1514

150F

FE C9

DEC CL

1511

75 F7

JNZ 150A

1513

F4

1514

88 05

1516

4E

1517

89 F3

1519

47

151A

88 1D

151C

47

151D

88 3D

MOV DL, 0A
LODSB
CMP DL, AL

HLT
MOV [DI], AL
DEC SI
MOV BX, SI
INC DI
MOV [DI], BL
INC DI
MOV [DI], BL

151F

CC

INT 3

RESULT:
Thus ALP for searching a byte was written and executed using
8086 microprocessor kit

SUM OF CONSECUTIVE NUMBERS

AIM:
To write an assembly language program for finding the sum of
n consecutive numbers and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:

STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA IN BL=1, AL=0,
CL=COUNT

T(N)=T(N-1)+T(N-2),
BL=BL+1 AL=T(N)
AL=T(N)

NO

IF
CL=0
YES
STORE RESULT
STOP

Algorithm :
1.
2.
3.
4.
5.
6.
7.

Load the value of n


t(n)= t(n-1)+t(n-2)
t(n-1)=t(n-2)+1
n=n-1
if n>0 continue else go to step 2
Initialize the pointer to memory for storing the result
Store the result

Input

:
Load the value of n in cl

Output
PROGRAM

: Result in 2000
:

Address
Mnemonics

Opcode

1300

B1 04

MOV CL, 04

1302

B0 00

MOV AL, 00

1304

B3 01

1306

MOV BL, 01
00 D8

ADD AL, BL

1308

FE C3

INC BL

130A

FE C9

DEC CL

130C

75 F8

130E

BF 00 20

1311
1313

JNZ 1306
MOV DI, 2000

89 05
CC

MOV [DI], AX
INT 3

RESULT:
Thus ALP for sum of n numbers was written and executed
using 8086 microprocessor kit

ASCII TO HEX CODE CONVERSION


AIM:
To write an assembly language program for converting ASCII
to HEX number and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
LOAD al WITH DATA
SUBTRACT WITH 30

IF
AL<=
10

N
O

AL=AL
-7

YES
STOP

Algorithm:
1. Load the data in al register.
2. Subtract 30 with al
3. If data is less than or equal to 16 terminate the program

4. Else subtract 7 from al


5. Result in al register

Input

:
Data input in al register.

Output

:
Data output in al register.

PROGRAM

Address

Opcode

Mnemonics

1100

B0 31

MOV AL, 31

1102

2C 30

SUB AL, 30

1104

3C 10

CMP AL, 10

1106

72 04

JB 110C

1108

74 02

JZ 110C

110A

2C 07

SUB AL, 07

110C

CC

INT 3

RESULT:
Thus ALP for ASCII to HEX code conversion was written and
executed using 8086 microprocessor kit

BCD TO HEXA DECIMAL CONVERSION


AIM:
To write an assembly language program for converting BCD to
HEX number and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
LOAD AL WITH DATA
MASK HIGHER, LOWER
BITS
MOVE HIGHER TO
LOWER BITS
MULTIPLY BY 10 ADD
LOWER BITS TO IT
STOP

Algorithm:
1. Load the data in al register.
2. Separate higher nibble and (in) lower nibble
3. Move the higher nibble (in) to lower nibble position
4. Multiply al by 10
5. Add lower nibble
6. Store the result

Input

:
Data in al

Output:

Result in al

PROGRAM:
Address

Opcode

Mnemonics

1100

B0 10

MOV AL, 10

1102

88 C4

MOV AH, AL

1104

80 E4 0F

AND AH, 0F

1107

88 E3

MOV BL, AH

1109

24 F0

AND AL, F0

110B

B1 04

MOV CL, 04

110D

D2 C8

110F

B7 0A

MOV BH, 0A

1111

F6 E7

MUL BH

1113

00 D8

ADD AL, BL

1115

CC

INT 3

ROR AL, CL

RESULT:
Thus ALP for BCD to HEX code conversion was written and
executed using 8086 microprocessor kit

HEX DECIMAL TO ASCII CODE


AIM:
To write an assembly language program for converting HEX to
ASCII number and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:

STAR
T
LOAD al WITH DATA
YES
If
al<
=9

Al=al+
7

N
O
Al=al+30
+++
STORE RESULT
STOP

Algorithm :
1.
2.
3.
4.
Input

Load al with the data.


If (al<=9) add 30
Else add 7 and 30
Result in al.
:

Data in al.
Output

:
Result in al.

PROGRAM

Address
Mnemonics

Opcode

1100

B0 0A

MOV AL, 0A

1102

3C 09

CMP AL, 09

1104

74 04

JZ 110A

1106

72 02

JB 110A

1108

04 07

ADD AL, 07

110A

04 30

ADD AL, 30

110C

CC

INT 3

RESULT:
Thus ALP for HEX to ASCII code conversion was written and
executed using 8086 microprocessor kit

MATRIX ADDITION
AIM:
To write an assembly language program for matrix addition
and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:

STAR
T
INITIALIZE MEMORY
POINTER FOR 2 MATRIX SI
& DI
LOAD DATA IN CL=COUNT,
AL=DATA

AL=AL+BL INCREMENT
POINTER
STORE RESULT

CL=CL-1
NO
IF
CL=
0

Algorithm:

STOP

1.
2.
3.
4.
5.
Input

YES

Initialize the pointer to memory for data and result.


Load cl with count.
Add two matrices by each element.
Process continues until cl is 0.
Store the result.
:

Data in 2000 consecutive location as rows and columns for first


matrix.

Data in 3000 consecutive location as rows and columns for


second matrix.
Output

:
Data in 3000 with 9 entries.

PROGRAM :
Address

Opcode

Mnemonics

1500

B1 09

MOV CL, 09

1502

BE 00 20

MOV SI, 2000

1505

BF 00 30

MOV DI, 3000

1508

8A 04

MOV AL, [SI]

150A

8A 1D

150C

00 D8

ADD AL, BL

150E

88 05

MOV [DI], AL

1510

47

INC DI

1511

46

INC SI

1512

FE C9

DEC CL

1514

75 F2

JNZ 1508

1516

CC

MOV BL, [DI]

INT 3

RESULT:
Thus ALP for matrix addition was written and executed using
8086 microprocessor kit

SEPARATING ODD AND EVEN


AIM:
To write an assembly language program for separating odd
and even numbers and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA IN AL
ROTATE DATA IN AL
YES
IF
CARR
Y SET

STORE
RESULT
NO

NO
CL=CL1,
CL=0?
YES
STOP

Algorithm:
1. Initialize the pointer to memory for data and result.
2. Load the data in al register from memory.
3. Rotate al register by one bit.
4. If carry flag is set go to step 2.
5. Store the even number as a result.

Input

Data in 2000(mixer of odd and even).

Count: number of bytes in cl


Output

PROGRAM

Even numbers in 3000.

Address

Opcode

Mnemonics

1400

B1 08

MOV CL, 08

1402

BE 00 20

MOV SI, 2000

1405

BF 00 30

MOV DI, 3000

1408

AC

LODSB

1409

D0 C8

140B

72 FB

140D

D0 C0

140F

88 05

MOV [DI], AL

1411

47

INC DI

ROR AL, 1
JB 1408
ROL AL, 1

1412

FE C9

DEC CL

1414

75 F2

JNZ 1408

1416

CC

INT 3

RESULT:
Thus ALP for separating odd and even numbers was written
and executed using 8086 microprocessor kit

FLOATING POINT OPERATIONS


AIM:
To write an assembly language program for Fibonacci series
and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA IN BL=T(N-1),
AL=T(N), CL=COUNT

T(N+1)=T(N-1)+T(N)

CL=CL-1

NO

IF
CL=0
YES
STORE RESULT
STOP

Algorithm:
1.
2.
3.
4.
Input

Initialize the pointer to memory for storing result.


Number of counts in cl register.
T(n+1) =t(n)+t(n-1).
Repeat the above process until count is 0.
Load the number of terms in cl.

Output :
Result in 2000 (clear the memory from 2000 by 00 before
executing the program)

PROGRAM:
Address

Opcode

Mnemonics

1100

B1 10

MOV CL, 10

1102

B0 01

MOV AL, 01

1104

BF 00 20

MOV DI, 2000

1107

B3 00

MOV BL ,00

1109

88 ID

MOV [DI], BL

110B

02 05

ADD AL, [DI]

110D

47

INC DI

110E

47

INC DI

110F

88 05

MOV [DI], AL

1111

4F

DEC DI

1112

FE C9

DEC CL

1114

75 F5

JNZ 110B

1116

CC

INT 3

RESULT:
Thus ALP for Fibonacci series was written and executed using
8086 microprocessor kit

FACTORIAL OF A NUMBER

AIM:
To write an assembly language program for finding the
factorial of a given number and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
INITIALIZE MEMORY
POINTER
LOAD DATA IN BL=1, AL=1,
CL=COUNT

T(N+1)=(N-1)*T(N),
BL=BL+1
CL=CL-1

NO

IF
CL=0
YES
STORE RESULT
STOP

Algorithm

:
1.
2.
3.
4.
5.

Input

Load the counter with value of n.


T(n)=t(n-1)*t( n-2)
Repeat the process until n becomes to store result.
Initialize the pointer to memory to store result.
Store the result
:

Load the value of n in cl.


Output

Result in 2000
PROGRAM

Address

Opcode

Mnemonics

1100

B1 04

MOV CL, 04

1102

B0 01

MOV AL, 01

1104

B3 01

MOV BL, 01

1106

F6 E3

MUL BL

FE C3

INC BL

1108
110A

FE C9

DEC CL

110C

75 F8

JNZ 1106

110E

BF 00 20

MOV DI, 2000

1111

89 05

MOV [DI], AX

1113

CC

INT 3

RESULT:
Thus ALP for factorial of a given number was written and executed
using 8086 microprocessor kit

LARGEST NUMBER IN AN ARRAY


AIM:
To write an assembly language program for finding the largest
number in an array and store the result in memory.

APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:

STAR
T
MOVE START ADDRESS TO MEMORY
POINTER

INITIALIZE COUNTER WITH NUMBER OF


ELEMENTS IN ARRAY
MOVE DATA POINTED BY MEMORY TO
REG1
INCREMENT MEMORY POINTER
DECREMENT COUNTER
C
COMPARE REG1
DATA
WITH DATA
POINTED BY
MEMORY
NO

YES

IS REG1
DATA
GREATER

B
B

A
SWAP DATA
NO
IS
COUNT=0?
YES
STOP

Algorithm:
1.
2.
3.
4.
5.

Take the first number of the array


Compare with the next number
Take the bigger of the two
Decrement the count.
If count is not Zero then continue from step 2

6. Store the result


Input:
Enter the size of array (count) in 9000
Enter the data starting from 9001.
Output:
Result is stored in 9500

PROGRAM:
Address

Opcode

Mnemonics

1000

BE 00 90

MOV SI, 9000

1003

8A 0C

MOV CL, [SI]

1005

46

INC SI

1006

8A 04

MOV AL, [SI]

1008

FE C9

DEC CL

100A

46

INC SI

100B

3A 04

CMP AL, [SI]

100D

73 02

JNB 1011

100F

8A 04

MOV AL, [SI]

1011

FE C9

DEC CL

1013

75 F5

JNZ 100A

1015

BF 00 95

MOV DI, 9500

1018

88 05

MOV [DI], AL

101A

CC

INT 3

RESULT:
Thus ALP for largest number in an array was written and executed
using 8086 microprocessor kit
AVERAGE OF AN ARRAY

AIM:

To write an assembly language program for finding the


average of an array and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:

STAR
T
MOVE START ADDRESS TO MEMORY
POINTER
INITIALIZE REG1 WITH ZERO
INITIALIZE COUNTER WITH NUMBER OF
ELEMENTS IN ARRAY
SAVE COUNT IN REG3

MOVE DATA FROM MEMORY POINTER ADDRESS


TO REG2
ADD REG1 TO REG2 AND STORE REG1
INCREMENT MEMORY POINTER, DECREMENT
COUNTER
IS.
COUNT=0?

NO

YES

DIVIDE REG2/REG3
STOP

ALGORITHM:

1. Add the bytes one by one up to the count (CL).


2. Then divide the total with the count
INPUT:
Size of array (count) in CL=6 (See the program)
Enter the data starting from 9000H

OUTPUT:
Average is stored in AX Register
Quotient in AL and the Reminder in AH
PROGRAM:
Address

Opcode

Mnemonics

1000

BB 00 00

MOV BX, 0000

1003

BE 00 90

MOV SI, 9000

1006

B8 00 00

MOV AX, 0000

1009

B1 06

MOV CL, 06

100B

88 CD

100D

8A 1C

MOV BL, [SI]

100F

00 D8

ADD AL, BL

1011

46

INC SI

1012

FE C9

DEC CL

1014

75 F7

JNZ 100D

1016

F6 F5

DIV CH

1018

CC

INT 3

MOV CH, CL

RESULT:
Thus ALP for average of an array was written and executed using
8086 microprocessor kit

DESCENDING ORDER

AIM:
To write an assembly language program for finding the
descending order of an array and store the result in memory.

APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply
FLOW CHART:
STAR
T
LOAD COUNTER WITH NUMBER OF ELEMENTS IN
ARRAY
MOVE DATA FROM MEMORY POINTER TO REG1
INCREMENT MEMORY POINTER
MOVE SUBSEQUENT DATA TO REG2
NO
IS
YES
REG1<REG
2?
INCREMENT MEMORY POINTER

SWAP REG1, REG2

STORE REG1 DATA TO MEMORY POINTED


ADDRESS
INCREMENT MEMORY POINTER
A

DECREMENT COUNTER

YES

IS
COUNT=0?

NO

STOP

Algorithm:
1. Get the first data and compare with the second data
2. If the two data are in descending order then no swap
3. Else swap the data byte by descending order and then again
compare the other data bytes up to the count
4. Do the above until the array is arranged in descending order

INPUT:
Enter the count in Location 9000
Enter the data location starting from 9001
OUTPUT:
Result in Descending Order in the Location 9001
PROGRAM:
Address
Mnemonics

Opcode

1000

BE 00 90

1003
[SI]

8A 0C

1005

BE 00 90

MOV SI, 9000

1008

8A 14

MOV DL, [SI]

100A

46

INC SI

100B

8A 04

MOV AL, [SI]

100D

FE CA

DEC DL

100F

74 16

JZ 1027

1011

46

INC SI

1012

8A 1C

MOV BL, [SI]

1014

3A C3

CMP AL, BL

1016

72 07

JB 101F

1018

4E

DEC SI

1019

88 04

MOV [ SI],AL

101B

88 D8

MOV AL,BL

101D

EB 03

JMP 1022

101F

4E

DEC SI

1020

88 1C

MOV [SI],BL

1022

46

INC SI

1023

FE CA

DEC DL

1025

75 EA

JNZ 1011

1027

88 04

MOV [SI],AL

1029

FE C9

DEC CL

102B

75 D8

JNZ 1005

MOV SI, 9000


MOV CL,

102D

CC

INT 3

RESULT:
Thus ALP for descending order of an array was written and
executed using 8086 microprocessor kit

ASCENDING ORDER
AIM:
To write an assembly language program for finding the
ascending order of an array and store the result in memory.
APPARATUS REQUIRED:
1.8086 Trainer kit
2. Power supply

FLOW CHART:

STAR
T
LOAD COUNTER WITH NUMBER OF ELEMENTS IN
ARRAY

MOVE DATA FROM MEMORY POINTER TO REG1


INCREMENT MEMORY POINTER
MOVE SUBSEQUENT DATA TO REG2
NO

SWAP REG1, REG2

IS
YES
REG1>REG
2?
INCREMENT MEMORY POINTER
STORE REG1 DATA TO MEMORY POINTED
ADDRESS
INCREMENT MEMORY POINTER
A
A

DECREMENT COUNTER

YES

IS
COUNT=0?

NO

STOP

Algorithm:
1. Get the first data and compare with the second data.
2. If the two data are in Ascending order then no swap
3. Else swap the data byte by Ascending order and then again
compare the other data bytes up to the count
4. Do the above until the array is arranged in Ascending order
INPUT:

Enter the count in Location 9000


Enter the data location starting from 9001
OUTPUT:
Result in Ascending Order in the Location 9001
PROGRAM:
Address
Mnemonics

Opcode

1100

BE 00 90

1103
[SI]

8A 0C

1105

BE 00 90

MOV SI, 9000

1108

8A 14

MOV DL, [SI]

110A

46

INC SI

110B

8A 04

MOV AL, [SI]

110D

FE CA

DEC DL

110F

74 16

JZ 1127

1111

46

INC SI

1112

8A 1C

MOV BL, [SI]

1114

38 D8

CMP AL, BL

1116

72 07

JNB 111F

1118

4E

DEC SI

1119

88 04

MOV [ SI],AL

111B

88 D8

MOV AL,BL

111D

EB 03

JMP 1122

111F

4E

DEC SI

1120

88 1C

MOV [SI],BL

1122

46

INC SI

1123

FE CA

DEC DL

1125

75 EA

JNZ 1111

1127

88 04

MOV [SI],AL

1129

FE C9

DEC CL

112B

75 D8

JNZ 1105

112D

CC

INT 3

MOV SI, 9000


MOV CL,

RESULT:
Thus ALP for ascending order of an array was written and executed
using 8086 microprocessor kit

STRING MANIPULATION
MOVE STRING BYTE AND MOVE STRING WORD
AIM:
To write a program to move the string byte and word.
ALGORITHM:
a. Initialize the data segment .(DS)
b. Initialize the extra data segment .(ES)
c. Initialize the start of string in the DS. (SI)
d. Initialize the start of string in the ES. (DI)
e. Move the length of the string(FF) in CX register.
f. Move the byte from DS TO ES, till CX=0.
START

Initialize DS,ES,SI,DI

CX=length of string,
DF=0.

Move a byte from source string (DS)


to destination string (ES)

Decrement CX

NO
Check for
ZF=1

STOP

MOVE STRING BYTE


ADDRESS
PROGRAM

COMMENTS

1100

MOV CL, 05

Initialize count value

1102

MOV SI,1200

Initialize starting address

1105

MOV DI, 1400

Initialize destination address

1108

CLD

Clear direction flag

1109

REP MOVSB

110B

INT 3

Copy the contents of source into


destination until count reaches zero
Stop

MOVE STRING WORD


ADDRESS

PROGRAM

COMMENTS

1100

MOV CL, 03

Initialize count value

1102

MOV SI,1400

Initialize starting address

1105

MOV DI

Initialize destination address

1108

CLD

Clear direction flag

1109

REP MOVSB

110A

INT 3

Copy the contents of source into


destination until count reaches zero
Stop

INPUT:
OUTPUT:

RESULT:
Thus a string of a particular length is moved from source segment to destination segment

STRING COMPARE
AIM:
To obtain the program for string compare operation using 8086.
PROGRAME
ADDRESS

PROGRAM

COMMENTS

1100

MOV CX, 0004

Initialize count value

1103

MOV DI, 1200

Initialize destination address

1106

MOV SI, 1150

Initialize starting address

1109

REP CMPSB

Compare

110B

JNZ 112

110D

MOV B,1111

1110

JMP 1115

1112

MOV BX100

1115

INT 3

Stop

INPUT

OUTPUT

RESULT:
Thus a given 16-bit number was compared and executed using 8086 trainer kit.

PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE


AIM:
To write an Assembly Language Program (ALP) for performing the Arithmetic
operation of two byte numbers

APPARATUS REQUIRED:
SL.N
O
1.
2.

ITEM
Microprocessor kit
Power Supply

SPECIFICATION
8086 kit
+5 V dc

PROGRAM:
;PASSWORD IS MASM1234
DATA SEGMENT
PASSWORD DB 'MASM1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $'
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,00
UP1:
MOV AH,08H
INT 21H
CMP AL,0DH
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H
INT 21H
INC SI
JMP UP1
DOWN:

QUANTITY
1
1

MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
;Today.asm Display month/day/year.
; Feb 1st, 2012
;CIS 206 Ken Howard
.MODEL small
.STACK 100h
.DATA
mess1 DB 10, 13, 'Today is $' ; 10=LF, 13=CR
.CODE
Today PROC
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET mess1 ; Move string to DX
MOV AH, 09h
; 09h call to display string (DX > AH > DOS)
INT 21H
; Send to DOS
; CX year, DH month, DL day
MOV AH, 2AH
; Get the date (appendix D)
INT 21H
; Send to DOS
PUSH CX
; Move year to the stack
MOV CX, 0
; Clear CX
MOV CL, DL
PUSH CX
; Move day to stack
MOV CL, DH
; Move month > CL
PUSH CX
; Move month to stack
MOV DH, 0
; Clear DH
; ************************** DISPLAY MONTH ************************

; Set up for division


; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0
; Clear DX
POP AX
; Remove month from stack into AX
MOV CX, 0
; Initialize the counter
MOV BX, 10
; Set up the divisor
dividem:
DIV BX
; Divide (will be word sized)
PUSH DX
; Save remainder to stack
ADD CX, 1
; Add one to counter
MOV DX, 0
; Clear the remainder
CMP AX, 0
; Compare quotient to zero
JNE dividem
; If quoient is not zero, go to "dividem:"
divdispm:
POP DX
; Remove top of stack into DX
ADD DL, 30h
; ADD 30h (2) to DL
MOV AH, 02h
; 02h to display AH (DL)
INT 21H
; Send to DOS
LOOP divdispm
; If more to do, divdispm again
; LOOP subtracts 1 from CX. If non-zero, loop.
MOV DL, '/'
; Character to display goes in DL
MOV AH, 02h
; 02h to display AH (DL)
INT 21H
; Send to DOS
; ************************** DISPLAY DAY ************************
; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0
; Clear DX
POP AX
; Remove day from stack into AX
MOV CX, 0
; Initialize the counter
MOV BX, 10
; Set up the divisor
divided:
DIV BX
; Divide (will be word sized)
PUSH DX
; Save remainder to stack
ADD CX, 1
; Add one to counter
MOV DX, 0
; Clear the remainder
CMP AX, 0
; Compare quotient to zero
JNE divided
; If quoient is not zero, go to "divided:"
divdispd:
POP DX
; Remove top of stack ADD
DL, 30h
; ADD 30h (2) to DL
MOV AH, 02h
; 02h to display AH (DL)
INT 21H
; Send to DOS
LOOP divdispd
; If more to do, divdispd again
; LOOP subtracts 1 from CX. If non-zero, loop.

MOV DL, '/'


; Character to display goes in DL
MOV AH, 02h
; 02h to display AH (DL)
INT 21H
; Send to DOS
; ************************** DISPLAY YEAR ************************
; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0
; Clear DX
POP AX
; Remove month from stack into AX
MOV CX, 0
; Initialize the counter
MOV BX, 10
; Set up the divisor
dividey:
DIV BX
; Divide (will be word sized)
PUSH DX
; Save remainder to stack
ADD CX, 1
; Add one to counter
MOV DX, 0
; Clear the remainder
CMP AX, 0
; Compare quotient to zero
JNE dividey
; If quoient is not zero, go to "dividey:"
divdispy:
POP DX
; Remove top of stack into DX
ADD DL, 30h
; ADD 30h (2) to DL
MOV AH, 02h
; 02h to display AH (DL)
INT 21H
; Send to DOS
LOOP divdispy
; If more to do, divdisp again
; LOOP subtracts 1 from CX. If non-zero, loop.
MOV al, 0
; Use 0 as return code
MOV AH, 4ch
; Send return code to AH
INT 21H
; Send return code to DOS to exit.
Today ENDP
; End procedure
END Today
; End code. Start using "Today" procedure.
MVI A, 80H: Initialize 8255, port A and port B
OUT 83H (CR): in output mode
START: MVI A, 09H
OUT 80H (PA): Send data on PA to glow R1 and R2
MVI A, 24H
OUT 81H (PB): Send data on PB to glow G3 and G4
MVI C, 28H: Load multiplier count (40) for delay
CALL DELAY: Call delay subroutine
MVI A, 12H
OUT (81H) PA: Send data on Port A to glow Y1 and Y2
OUT (81H) PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10) for delay
CALL: DELAY: Call delay subroutine
MVI A, 24H
OUT (80H) PA: Send data on port A to glow G1 and G2
MVI A, 09H
OUT (81H) PB: Send data on port B to glow R3 and R4
MVI C, 28H: Load multiplier count (40) for delay

CALL DELAY: Call delay subroutine


MVI A, 12H
OUT PA: Send data on port A to glow Y1 and Y2
OUT PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10) for delay
CALL DELAY: Call delay subroutine
JMP START Delay
Subroutine:
DELAY: LXI D, Count: Load count to give 0.5 sec delay
BACK: DCX D: Decrement counter
MOV A, D
ORA E: Check whether count is 0
JNZ BACK: If not zero, repeat
DCR C: Check if multiplier zero, otherwise repeat
JNZ DELAY
RET: Return to main program
Ram size:
ORG 0000H
CLR PSW3
CLR PSW4
CPL A
ADD A, #01H
MOV A,R3
AGAIN: SJMP AGAIN

RESULT:
Thus the output for the Password checking, Print RAM size and system date was
executed successfully

COUNTERS AND TIME DELAY


AIM:
To write an assembly language program in 8086 to Counters and Time Delay
APPARATUS REQUIRED:
SL.NO
ITEM
1.
Microprocessor kit
2.
Power Supply
3.
Stepper Motor Interface board
4.
Stepper Motor

SPECIFICATION
8086
+5 V, dc,+12 V dc
-

PROGRAM:
.MODEL SMALL
.DATA
MSGIN DB 'Enter delay duration (0-50): $'
MSG1 DB 'This is Microprocessor!$'
DELAYTIME DW 0000H
.CODE
MOV DX,@DATA
MOV DS,DX
LEA DX,MSGIN
MOV AH,09H
INT 21H
IN1:
MOV AH,01H
INT 21H
CMP AL,0DH ;
JE NXT
SUB AL,30H
MOV DL,AL
MOV AX,BX
MOV CL,0AH
MUL CL
MOV BX,AX
AND DX,00FFH
ADD BX,DX
MOV DELAYTIME,BX
LOOP IN1

QUANTITY
1
1
1
1

NXT:
MOV CX,DELAYTIME
MOV DL,10
MOV AH,02H
INT 21H
LEA SI,MSG1
LP: PUSH DX
MOV DL,[SI]
CMP DL,'$'
JE NXT2
MOV AH,02H
INT 21H
ADD SI,1
POP DX
MOV DI,DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2: MOV AH,4CH
INT 21H
END
RESULT:
Thus the output for the Counters and Time Delay was executed successfully

1250

16-BIT ADDITION
OBJECTIVE:
To perform 16-bit addition of two 16-bit data using immediate
addressing and store the result in memory.
APPARATUSREQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:
STAR
T
(A)=MSB OF I OPERAND

ADD(A) WITH MSB OF II


OPERAND
STORE MSB OF RESULT IN
MEMORY
(A)=LSB OF II OPERAND

ADD(A) WITH LSB OF II


OPERAND
STORE LSB OF RESULT IN
MEMORY
STO
P

PROCEDURE:
1.
2.
3.
4.

ENTER THE OPCODES FROM 8200 IN THE TRAINER


EXECUTE THE PROGRAM
CHECK FOR THE RESULT AT 8250 AND 8251
CHANGE DATA AND SEE IF THE RESULT AT 8250 CHANGES
ACCORDINGLY
PROGRAM:
MEMORY ADDRESS

OBJECT CODES

MNEMONICS

8200

C3

CLR C

8201

74

MOV A,#DATAL1

1251

8202

34

8203

24

8204

78

8205

90

8206

82

8207

50

8208

F0

MOVX @DPTR,A

8209

A3

INC DPTR

820A

74

MOV A,#DATAM1

820B

12

820C

34

820D

56

820E

F0

820F

80

8210

FE

ADD A,#DATAL2

MOV DPTR,#8250

ADDC A,#DATAM2

MOVX @DPTR,A

HERE: SJMP HERE

INPUT:
OUTPUT:
RESULT: Thus the ALP for addition of 16-bit numbers was executed
in 8051 trainer kit

8-BIT SUBTRACTION:
OBJECTIVE:

1252

To perform SUBTRACTION of two 8-bit data using immediate


addressing and store the result in memory.
APPARATUSREQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:
STAR
T
CLEAR CARRY FLAG

GET I OPERAND IN A

SUBTRACT II OPERAND FROM


A
STORE RESULT IN MEMORY

STO
P

PROCEDURE:
1.
2.
3.
4.

ENTER THE OPCODES FROM 8200 IN THE TRAINER


EXECUTE THE PROGRAM
CHECK FOR THE RESULT AT 8250
CHANGE DATA AND SEE IF THE RESULT AT 8250 CHANGES
ACCORDINGLY

PROGRAM:
MEMORY ADDRESS

OBJECT CODES

MNEMONICS

8200

C3

CLR C
1253

8201

74

MOV A,#DATA1

8202

20

8203

94

8204

10

8205

90

8206

82

8207

50

8208

F0

MOVX @DPTR,A

8209

80

HERE: SJMP HERE

820A

FE

SUBB A,#DATA2

MOV DPTR,#8250

INPUT:

OUTPUT:

RESULT:
Thus the ALP for subtraction of 8-bit numbers was executed in
8051 trainer kit

8-BIT MULTIPLICATION:
OBJECTIVE:
TO OBTAIN THE PRODUCT OF TWO 8-BIT DATA USING IMMEDIATE
ADDRESSING AND STORE THE RESULT IN MEMORY.

1254

APPARATUSREQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:
STAR
T
GET MULTIPLIER IN A

GET MULTIPLICAND IN B

MULTIPLY A WITH B

STORE RESULT IN MEMORY

STO
P

PROCEDURE:
1.
2.
3.
4.

ENTER THE OPCODES FROM 8200 IN THE TRAINER


EXECUTE THE PROGRAM
CHECK FOR THE RESULT AT 8250
CHANGE DATA AND SEE IF THE RESULT AT 8250 CHANGES
ACCORDINGLY

PROGRAM:
MEMORY ADDRESS

OBJECT CODES

MNEMONICS

8200

74

MOV A,#DATA1

8201

0A

8202

75

8203

F0

8204

88

MOV B,#DATA2

1255

8205

A4

MUL AB

8206

90

MOV DPTR,#8250

8207

82

8208

50

8209

F0

MOVX @DPTR,A

820A

A3

INC DPTR

820B

E5

MOV A,B

820C

F0

820D

F0

MOVX @DPTR,A

820E

80

HERE: SJMP HERE

820F

FE

INPUT:
OUTPUT:

RESULT:
Thus the ALP for 8-bit multiplication was executed in 8051
trainer kit

8-BIT DIVISION:
OBJECTIVE:
To DIVIDE AN 8-BIT NUMBER BY ANOTHER 8-BIT NUMBER AND STORE
THE QUOTIENT AND REMAINDER IN MEMORY.

APPARATUSREQUIRED:

8051 Trainer kit

Power supply

1256

FLOW CHART:
STAR
T
GET DIVIDEND IN A

GET DIVISOR IN B

DIVIDE A BY B

STORE LSB & MSB OF


RESULT IN MEMORY

STO
P

PROCEDURE:
1.
2.
3.
4.

ENTER THE OPCODES FROM 8200 IN THE TRAINER


EXECUTE THE PROGRAM
CHECK FOR THE RESULT AT 8250 AND 8251
CHANGE DATA AND SEE IF THE RESULT AT 8250 CHANGES
ACCORDINGLY
PROGRAM:
MEMORY ADDRESS

OBJECT CODES

MNEMONICS

8200

74

MOV A,#DATA1

8201

65

8202

75

8203

F0

8204

08

8205

84

DIV AB

8206

90

MOV DPTR,#8250

8207

82

8208

50

8209

F0

MOVX @DPTR,A

820A

A3

INC DPTR

MOV B,#DATA2

1257

820B

E5

MOV A,B

820C

F0

820D

F0

MOVX @DPTR,A

820E

80

HERE: SJMP HERE

820F

FE

INPUT:
OUTPUT:

RESULT:
Thus the ALP for 8-bit division was executed in 8051 trainer
kit

SUM OF ELEMENTS IN AN ARRAY


OBJECTIVE:
B
To add the numbers of an 8-bit array, the array length being the
STAR
first element in the array and store the result in memory.
T
INCREMENT MSB OF RESULT
APPARATUSREQUIRED:
COUNT IN R0 & POINTER IN
A
DPTR
8051 Trainer kit
GET I ELEMENT IN A &
INCREMENT POINTER
Power
supply
CLEAR
B
CLEAR CARRY FLAG

DECREMENT R0

FLOW CHART:
ADD(A) WITH NEXT
ELEMENT
YES
CARRY
=0
NO
A

R0=0?
B

NO

YES
1258
STORE LSB &MSB IN
MEMORY
STO

PROCEDURE:
1. Enter the above opcodes and data from 8200 and 8250
respectively.
2. Executive the program
3. Check for result at 8300 and 8301.
4. Change data at 8250 and check for results

PROGRAM:
MEMORY
ADDRESS

OBJECT
CODES

MNEMONICS

8200

90

MOV DPTR,#8250

8201

82

8202

50

8203

E0

MOVX A,@DPTR

8204

F8

MOV R0,A

8205

75

MOV B,#0

8206

F0

8207

00

8208

A9

MOV R1,B

1259

8209

F0

820A

C3

ADD: CLR C

820B

A3

INC DPTR

820C

E0

MOVX A,@DPTR

820D

25

ADD A,B

820E

F0

820F

F5

8210

F0

8211

50

8212

01

8213

09

INC R1

8214

D8

NC:DJNZ R0,ADD

8215

F4

8216

90

8217

83

8218

00

8219

E9

MOV A,R1

821A

F0

MOVX @DPTR,A

821B

A3

INC DPTR

821C

E5

MOV A,B

821D

F0

821E

F0

MOVX @DPTR,A

821F

80

HLT:

8220

FE

MOV B,A

JNC NC

MOV DPTR,#8300

SJMP HLT

INPUT:
OUTPUT:

RESULT:
Thus the ALP for sum of elements in an array was executed in
8051 trainer kit

1260

ASCII TO DECIMAL CONVERSION


OBJECTIVE:
To convert the ASCII number in the accumulator to its
equivalent decimal number.
APPARATUSREQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:

STAR
T
GET DATA IN
A
(A)=(A)-30H

YES

RESULT= FFH

IS
(A)>
9?

NO

RESULT=
(A)
)

STOP

1261

PROCEDURE:
1.
2.
3.
4.

Enter the opcodes from the specified address.


Enter the data
Execute the program and check the results.
Change data and see if exact results are stored

PROGRAM :
MEMORY
ADDRESS

OBJECT
CODES

MNEMONICS

8200

90

MOV
DPTR,#8250

8201

82

8202

50

8203

74

8204

40

8205

C3

CLR C

8206

94

SUBB A,#3

8207

30

8208

C3

8209

94

820A

0A

820B

40

820C

04

MOV A,#DATA

CLR C
SUBB A,#0A

JC

STR

1262

820D

74

820E

FF

820F

80

8210

02

8211

24

MOV A,#0FF

SJMP L1

STR: ADD A,#0A

INPUT:
OUTPUT:
RESULT:
Thus the ALP for ASCII to decimal conversion was executed in
8051 trainer kit

HEXA TO DECIMAL CONVERSION


OBJECTIVE:
To obtain the decimal equivalent of an 8-bit hex number
stored in memory.
STAR
TT
APPARATUSREQUIRED:

GET HEX
8051 Trainer
kit DATA IN A

Power supply
LOAD B WITH 100D
FLOW CHART:
DIVIDE A BY B

STORE (A) i.e NO. OF


100S
LOAD B WITH 10D

DIVIDE A BY 10D

STORE (A) AS NO.OF


TENS
STORE (B) AS NO.OF
UNITS
STO

1263

PROCEDURE:
1.
2.
3.
4.

Enter the opcodes from the specified address.


Enter the data
Execute the program and check the results.
Change data and see if exact results are stored.

PROGRAM :
MEMORY
ADDRESS

OBJECT
CODES

MNEMONICS

8200

90

MOV DPTR,
#8250

8201

82

8202

50

8203

E0

MOVX
A,@DPTR

8204

75

MOV B,#64

8205

F0

8206

64

8207

84

DIV

8208

90

MOV DPTR,
#8251

8209

82

820A

51

820B

F0

AB

MOVX
@DPTR,A
1264

820C

E5

MOV A,B

820D

F0

820E

75

820F

F0

8210

0A

8211

84

DIV AB

8212

A3

INC DPTR

8213

F0

MOVX
@DPTR,A

8214

A3

INC DPTR

8215

E5

MOV A,B

8216

F0

8217

F0

8218

80

MOVX
@DPTR,A

8219

FE

HLT:
HLT

MOV B,#0A

SJMP

INPUT:
OUTPUT:
RESULT:
Thus the ALP for HEX to decimal conversion was executed in
8051 trainer kit

1265

DECIMAL TO HEX CONVERSION


OBJECTIVE:
To convert BCD digits in memory to the equivalent hex
number.
APPARATUS REQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:

STAR
TT
GET MSD OF DATA IN A
MULTIPLY A WITH 0A
ADD IT WITH LSD OF
DATA
STORE HEX DATA IN
MEMORY
STO
P
PROCEDURE:
1266

1.
2.
3.
4.
5.

Key in the opcodes from 8200.


Enter the BCD data at 8250 and 8251.
Execute the program.
Check for result at 8252.
Change data and verify for proper results.

PROGRAM:
MEMORY
ADDRESS

OBJECT
CODES

MNEMONICS

8200

90

MOV
DPTR,#8250

8201

82

8202

50

8203

E0

MOVX A,
@DPTR

8204

75

MOV B, #0A

8205

F0

8206

0A

8207

A4

MUL

8208

F5

MOV B,A

8209

F0

820A

A3

INC

820B

E0

MOVX A,
@DPTR

820C

25

ADD

A,B

820D

F0

820E

A3

INC

DPTR

820F

F0

MOVX

AB

DPTR

1267

@DPTR,A
8210

80

8211

FE

HLT:
HLT

SJMP

INPUT:
OUTPUT:
RESULT:
Thus the ALP for decimal to HEX conversion was executed in
8051 trainer kit

LARGEST ELEMENT IN AN ARRAY


OBJECTIVE:
To find the biggest number in an array of 8-bit unsigned numbers of
predetermined length.
APPARATUS REQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:
STAR
T
INITIALIZE COUNTER &
POINTER

LOAD INTERNAL MEMORY LOCATION 40H


WITH 0

INCREMENT POINTER &


DECREMENT COUNTER

GET CURRENT ELEMENT OF


ARRAY IN A
YES
IS
(40H)=
(A)?

2
1

STORE (40H) IN MEMORY

NO
NO
IS
(40H)<
(A)?

STO
P

YES

MOVE (A) INTO 40H


LOCATION
1

NO

IS
COUNT=
YES
0?

1268

PROCEDURE:
1.
2.
3.
4.

Enter the opcodes starting from 8200.


Key in the data at 8250.
Execute the program and verify for result at 825A.
Change the array length and data and repeat.

PROGRAM :
MEMORY
ADDRESS

OBJECT
CODES

MNEMONICS

8200

90

MOV DPTR,
#8250

8201

82

8202

50

8203

75

8204

40

8205

00

8206

7D

8207

0A

8208

E0

LOOP2: MOVX
A,@DPTR

8209

B5

CJNE
A,4OH,LOOP1

820A

40

820B

08

820C

A3

LOOP3:
DPTR

820D

DD

DJNZ
R5,LOOP2

820E

F9

820F

E5

8210

40

8211

F0

MOV 40H, #00

MOV

MOV

R5,#0AH

INC

A,40H

MOVX
1269

@DPTR,A
8212

80

8213

FE

8214

40

HLT:
HLT

LOOP1:

SJMP

JC

LOOP3
815

F6

8216

F5

8217

40

8218

80

8219

F2

MOV

40H,A

SJMP

LOOP3

INPUT:
OUTPUT:

RESULT:
Thus the ALP for largest element in an array was executed in
8051 trainer kit

1270

ASCENDING ORDER OF AN ARRAY


OBJECTIVE:
To arrange an array of 8-bit unsigned numbers of know length
in ascending order.
APPARATUS REQUIRED:

8051 Trainer kit

Power supply

FLOW CHART:
STAR
T

(R3) &
(R4)=COUNT-1

INCREMENT POINTER &


DECREMENT R3
NO

(DPTR)=POINTER

IS
R3=0
YES
?

2
(R5)

(DPL), (R6) (DPH)


(DPL)

GET I ELEMENT IN
B
GET NEXT ELEMENT
IN A
YES
1

IS
(A)>(
B)?

(R5) , (DPH)(R6)

INCREMENT POINTER &


DECREMENT R4
NO
2

NO

EXCHANGE (A) ,
AND(B)
1

IS
R4=0
?
YES
STO
P

PROCEDURE :
1. Key in the opcodes from 8200.
2. Enter data at 8250.
1271

3. Execute the program and check for results from 8250.

PROGRAM:
MEMORY
ADDRESS

OBJECT
CODE

8200

7B

8201

04

8202

7C

8203

04

8204

90

8205

82

8206

50

8207

AD

MNEMONICS
MOV

MOV

R3, #4

R4, #4

MOV
#8250

DPTR,

REPT1:

MOV

R5,DPL
8208

82

8209

AE

820A

83

820B

E0

MOVX

820C

F5

MOV

820D

F0

820E

A3

MOV

R6 ,DPH

REPT:

A,@DPTR
B,A

INC

DPTR
820F

E0

MOVX
A,@DPTR

8210

F8

MOV

8211

C3

CLR

8212

95

SUBB

R0,A
C
A,B
1272

8213

F0

8214

50

8215

13

8216

C0

JNZ

EXCH:
PUSH

CHKNXT

DPL

8217

82

8218

C0

8219

83

821A

8D

821B

82

821C

8E

821D

83

821E

E8

MOV

821F

F0

MOVX
@DPTR,A

8220

D0

POP

8221

83

8222

D0

8223

82

8224

E5

8225

F0

8226

F0

MOVX
@DPTR,A

8227

88

MOV

8228

F0

8229

DB

PUSH

MOV

DPH

DPL,R5

MOV

DPH,R6

A,R0

DPH

POP
DPL

MOV

A,B

B,R0

CHKNXT:DJNZ
R3, REPT

822A

E3

822B

1C

DEC
R4

822C

EC

MOV

822D

FB

MOV

822E

OC

INC

A,R4
R3,A
R4
1273

822F

8D

8230

82

8231

8E

8232

83

8233

A3

INC
DPTR

8234

DC

DJNZ
R4,REPT1

8235

D1

8236

80

8237

MOV
R5

DPL,

MOV
DPH,R6

HLT:
SJMP

HLT

FE

INPUT:

OUTPUT:

RESULT:
Thus the ALP for ascending order of an array was executed in
8051 trainer kit

1274

ADC PROGRAM

OBJECTIVE:

To write an assembly language program for ADC Program


APPARATUS REQUIRED:

8086 Trainer kit

Power supply

8086 ADC PROGRAM:

ADDRESS

LABEL

OPCODE

MNEMONICS

1000

BA 26 FF

MOV DX,FF26H

1003

B0 90

MOV AL,90H

1005

EE

OUT DX,AL

1006

BA 24 FF

MOV DX,FF24H

1009

B0 FF

MOV AL,FFH

100B

EE

OUT DX,AL

100C

B0 00

MOV AL,00H

100E

EE

OUT DX,AL

100F

B0 FF

MOV AL,FFH

1011

EE

OUT DX,AL

1012

E8 EB 00

CALL 1100H

1015

BA 20 FF

MOV DX,FF20H

1018

EC

IN AL,DX

1019

CC

INT 3

COMMENTS

OUT IT IN CONTROL REG


CWR FOR PORT A AS I/P
PORT B AND PORT C AS O/P
PORT C IS ENABLED FOR WR
START OF CONVERSION

DELAY ROUTINE
PORTA AS I/P

READ THE ADC VALUE


BREAK POINT

1275

DELAY SUBROUTINE:
ADDRESS

LABEL

OPCODE

MNEMONICS

B9 FF FF

MOV CX,FFFFH

90

NOP

1104

90

NOP

1105

49

DEC CX

1106

75 FB

JNE 1103H(L1)

1108

C3

RET

1100
1103

L1

COMMENTS

DELAY COUNT

RETURN TO MAIN PROGRAM

NOTE:

INPUT:

The input (analog volts) for the adc is given by varying the pot

(0
OUTPUT:

to 5v).
The digital count o/p for the given input volts is stored and
shown in accumulator
;port A receives digital o/p from adc
;port B for r/w
;port A receives digital o/p from adc
;port c for r/w

; Note RESULT STORED IN ACCUMULATOR

1276

WORKING PROCEDURE FOR ADC :

Connect the 26-pin connector from the kit to the adc cord.
Connect the card from keyboard into the socket provided in the kit.
Switch on the power supply.
Assemble your program.
Vary the pot in the adc chord.
Execute it and view the output count in the accumulator, which will be
displayed in the LCD display.
Every time you vary the pot, execute the program and measure the
count value in the accumulator.
Repeat the above step for different inputs in the pot.
After enough of readings have been taken reduce the pot to its minimum
value.
Switch off the power supply and remove all the connections.

1277

8086 DAC PROGRAM:


BASIC SIMPLE PROGRAM
ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENTS

1000

BA 26 FF

MOV DX,FF26H

CWR FOR ALL PORT O/P

1003

B0 80

MOV AL,80H

OUT IT IN CONTROL REG

1005

EE

OUT DX,AL

1006

BA 22 FF

MOV DX,FF22H

1009

B0 FF

MOV AL,80H

100B

EE

OUT DX,AL

100C

CC

INT 3

OUT PORT B
GIVEN I/P DATA

BREAK POINT

SQUARE WAVE GENERATION:

1278

User can change the delay period in order to get the desired frequency of the
wave form. User can view the output at DAC O/P, which is from 2nd pin of dac
(0800), through the CRO.
ADDRESS

OPCODE

MNEMONICS

2000

BA 26 FF

MOV DX,FF26H

CWR FOR ALL PORT O/P

2003

B0 80

MOV AL,80H

OUT IT IN CONTROL REG

2005

EE

OUT DX,AL

2006

BA 22 FF

MOV DX,FF22H

B0 FF

MOV AL,FFH

200B

EE

OUT DX,AL

200C

E8 F1 00

CALL 2100H

CALL DELAY

200F

B0 00

MOV AL,00H

GIVEN I/P DATA LOW

2011

EE

OUT DX,AL

2012

E8 EB 00

CALL 2100H

CALL DELAY

2015

EB F2

JMP 2009H

JUMP TO L1

2009

LABEL

L1

COMMENTS

OUT PORT B
GIVEN I/P DATA HIGH

DELAY SUBROUTINE:
ADDRESS

LABEL

OPCODE

MNEMONICS

B9 FF 07

MOV CX,07FFH

90

NOP

2104

90

NOP

2105

49

DEC CX

2106

75 FB

JNE 2103H(L1)

2108

C3

RET

2100
2103

L1

COMMENTS

DELAY COUNT

RETURN TO MAIN PROGRAM

1279

STAIR CASE WAVE FORM GENERATION


User can change the delay period in order to get the desired frequency of the
wave form. User can view the output at the yellow colour wire which is from
2nd pin of dac (0800) through the CRO.
ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENTS

3000

BA 26 FF

MOV DX,FF26H

CWR FOR ALL PORT O/P

3003

B0 80

MOV AL,80H

OUT IT IN CONTROL REG

3005

EE

OUT DX,AL

3006

BA 22 FF

MOV DX,FF22H

MOVE C.WORD TO CNTRL REG


OUT PORT B

3009

L1

B0 00

MOV AL,00H

300B

L2

EE

OUT DX,AL

OUT PORT B

300C

E8 F1 00

CALL 3100H

CALL DELAY

300F

04 10

ADD AL,10H

STEP VALUE 10H RISING STEP

3011

75 F8

JNE 300BH(L2)

3013

B0 FF

MOV AL,FFH

EE

OUT DX,AL

OUT PORT B

3016

E8 E7 00

CALL 3100H

CALL DELAY

3019

2C 10

SUB AL,10H

STEP VALUE 10H FALING STEP

301B

73 F8

JNB 3015H(L3)

301D

EB EA

JMP 3009H(L1)

3015

L3

INITIAL LOW VALUE DATA

GIVEN I/P DATA HIGH

JUMP TO L1

DELAY SUBROUTINE:
ADDRESS

LABEL

OPCODE

MNEMONICS

B9 FF 00

MOV CX,00FFH

90

NOP

3104

90

NOP

3105

49

DEC CX

3106

75 FB

JNE 3103H

3100
3103

L1

COMMENTS

DELAY COUNT

1280

3108

C3

RET

RETURN TO MAIN PROGRAM

WORKING PROCEDURE FOR DAC:


Connect the 26-pin connector from the chord to kit.
Switch on the power supply.
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 card.
For different values of the digital data you will get different values in the
multi-meter.
Switch off the power supply and remove the connectors.

8086 STEPPER MOTOR PROGRAM


MAIN:
CLOCK WISE DIRECTION:

ADDRESS

LABE
L

OPCODE

MNEMONICS

1000

BA 26 FF

MOV DX,FF26

1003

B0 80

MOV AL,80

1005

EE

OUT DX,AL

BA 20 FF

MOV DX,FF20

1009

B0 05

MOV AL,05

1st sequence data

100B

EE

OUT DX,AL

Out it in port A

100C

E8 F1 00

CALL 1100

Call delay subroutine

100F

B0 07

MOV AL,07

2nd sequence data

1006

LOOP
1

COMMENTS
load the DX with the
add cntr.reg
Control word for
enabling the ports
Move the control
word cntr.reg
Move the address of
port A to DX

1281

1011

EE

OUT DX,AL

Out it in port A

1012

E8 EB 00

CALL 1100

Call delay subroutine

1015

B0 06

MOV AL,06

3rd sequence data

1017

EE

OUT DX,AL

Out It In Port

1018

E8 E5 00

CALL 1100

Call delay subroutine

101B

B0 04

MOV AL,04

4th sequence data

101D

EE

OUT DX,AL

Out it in port A

101E

E8 EB 00

CALL 1100

Call delay subroutine

1021

EB E3

JMP 1006(LOOP1)

Jump to start

ANTI CLOCK WISE DIRECTION:

ADDRESS

LABE
L

OPCODE

MNEMONICS

2000

BA 26 FF

MOV DX,FF26

2003

B0 80

MOV AL,80

2005

EE

OUT DX,AL

BA 20 FF

MOV DX,FF20

2009

B0 04

MOV AL,04

1st sequence data

200B

EE

OUT DX,AL

Out it in port A

200C

E8 F1 F0

CALL 1100

Call delay subroutine

200F

B0 06

MOV AL,06

2nd sequence data

2011

EE

OUT DX,AL

Out it in port A

2012

E8 EB F0

CALL 1100

Call delay subroutine

2006

LOOP
2

COMMENTS
load the DX with the
add cntr.reg
Control word for
enabling the ports
Move the control
word cntr.reg
Move the address of
port A to DX

1282

2015

B0 07

MOV AL,07

3rd sequence data

2017

EE

OUT DX,AL

Out It In Port

2018

E8 E5 F0

CALL 1100

Call delay subroutine

201B

B0 05

MOV AL,05

4th sequence data

201D

EE

OUT DX,AL

Out it in port A

201E

E8 EB F0

CALL 1100

Call delay subroutine

2021

EB E3

JMP 2006(LOOP2)

Jump to start

DELAY SUBROUTINE:

ADDRESS

LABE
L

OPCODE

MNEMONICS

BB 1000

MOV BX,0010

B0 FF

MOV AL,FF

90

NOP

1106

90

NOP

1107

90

NOP

1100
1103
1105

LOOP
3
LOOP
4

COMMENTS
Changing speed of
rotation

1283

1108

90

NOP

1109

FE C8

DEC AL

110B

75 F8

JNE 1105(LOOP4)

110D

4B

DEC BX

110E

75 F3

JNE 1103(LOOP3)

C3

RET

ADDRESS

1110

LABEL

OPCODE

MNEMONICS

Return to main
MOV AL,80H program

1000

B0 80

1002

BA 26 FF

MOV DX,FF26

1005

EE

OUT DX,AL

Working procedure for stepper motor: Connect the 5V &12V power supply to the Stepper Interface card.
Connect the 26-pin
ADDRESS

LABEL

OPCODE

MNEMONICS

1000

B0 80

MOV AL,80H

1002

BA 26 FF

MOV DX,FF26

1005

EE

OUT DX,AL

FRC from the kit to


the card.
Switch on the
power supply.
Assemble the

program and execute it.


The stepper motor will start rotating either in clockwise or anti-clockwise
direction based on the order of the coil excitation.
Switch off the power supply and remove all the connections.

TRAFFIC LIGHT PROGRAM IN 8086:


FOR STARTING VEHICLES IN N-S DIRECTION(STRAIGHT) AND
PEDESTRAIN STOPPING:
1284

ADDRESS

LABEL

OPCODE

CONT

B0 0F

MOV AL,0FH

1008

BA 22 FF

MOV DX,FF22

100B

EE

OUT DX,AL

100C

B0 4D

MOV AL,4D

100E

BA 20 FF

MOV DX,FF20

1011

EE

OUT DX,AL

1012

E8 75 00

CALL DELAY

1015

E8 65 00

CALL AMBER

1006

MNEMONICS

INUE

ADDRESS

LABEL

OPCODE

MNEMONICS

1018

B0 8B

MOV AL,8BH

101A

BA 20 FF

MOV DX,FF20

101D

EE

OUT DX,AL

101E

E8 69 00

CALL DELAY

1021

E8 59 00

CALL AMBER

1285

1039
ADDRESS

LABEL

E8 41 00
OPCODE

CALL
AMBER
MNEMONICS

1024

B0 49

MOV AL,49H

1026

BA 20 FF

MOV DX,FF20

1029

EE

OUT DX,AL

102A

B0 01

MOV AL,01H

102C

BA 24 FF

MOV DX,FF24

102F

EE

OUT DX,AL

1030

E8 57 00

CALL DELAY

1033

B0 00

MOV AL,00H

1035

BA 24 FF

MOV DX,FF24

1038

EE

OUT DX,AL

1286

STOPPING RIGHT TURN IN N-S SIDES AND STARTING RIGHT


TURN IN E-W SIDES:

ADDRESS

LABEL

OPCODE

MNEMONICS

103C

B0 89

MOV AL,89H

103E

BA 20 FF

MOV DX,FF20

1041

EE

OUT DX,AL

1042

B0 02

MOV AL,02H

1044

BA 24 FF

MOV DX,FF24

1047

EE

OUT DX,AL

1048

E8 3F 00

CALL DELAY

104B

B0 00

MOV AL,00H

104D

BA 24 FF

MOV DX,FF24

1050

EE

OUT DX,AL

1051

B0 30

CALL DELAY

1053

BA 20 FF

MOV AL,30H

1056

EE

OUT DX,AL

1057

B9 04 00

MOV CX,0004H

105A

E8 34 00

CALLDELAYSUB

1287

FOR STARTING PEDESTRAIN:

ADDRESS

LABEL

OPCODE

MNEMONICS

105D

B0 C0

MOV AL,C0H

105F

BA 20 FF

MOV DX,FF20

1062

EE

OUT DX,AL

1063

B0 F0

MOV AL,0F0H

1065

BA 22 FF

MOV DX,FF22

1068

EE

OUT DX,AL

1069

B9 10 00

MOV AL,10H

106C

E8 22 00

CALL DELAYSUB

106F

B0 30

MOV AL,30

1071

BA 20 FF

MOV DX,FF20

1074

EE

OUT DX,AL

1075

B9 08 00

MOV DX,0008H

1078

E8 16 00

CALL DELAYSUB

107B

EB 89

JMP CONTINUE

1288

AMBER:

ADDRESS

LABEL

OPCODE

MNEMONICS

107D

AMBER

B0 39

MOV AL,39H

107F

BA 20 FF

MOV DX,FF20

1082

EE

OUT DX,AL

1083

B9 08 00

MOV CX,8H

1086

E8 08 00

CALL DELAYSUB

1089

C3

RET

DELAY:
ADDRESS

LABEL

OPCODE

MNEMONICS

108A

DELAY

B9 40 00

MOV CX,40H

108D

E8 01 00

CALL DELAYSUB

1090

C3

RET

1289

ADDRESS

LABEL

OPCODE

MNEMONICS

1091

DELAYS

BB 10 00

MOV CX,00FF

UB,BAC
K2
1094

BACK1

B8 FF 00

MOV AX,00FF

1097

BACK

90

NOP

1098

48

DEC AX

1099

75 FC

JNZ BACK

109B

4B

DEC BX

109C

89 D8

MOV AX,CX

109E

75 F4

JNZ BACK1

10A0

09 C8

OR AX,CX

74 00

JZ OUT

49

DCR CX

10A5

75 EA

JNZ BACK2

10A7

C3

RET

10A2
10A4

OUT

DELAY

SUBROUTINE:

1290

Working procedure for Traffic light interface:

Connect the 5V supply to the trainer kit


Connect the 26-pin FRC from the kit.
Switch on the power supply.
Assemble the program.
Execute it and output display by led.
Switch off the power supply and remove the connectors.

8086 PRINTER PROGRAM


INPUT:
* The String of Data Which Has To Be Printed
* Is To Be Entered In the Memory From
1291

* 2000h with Cr (0dh) As the End of String


* Example: 2000 - 41 42 43 .0d

LOOP1:
ADDRESS

OPCODE

MNEMONICS

COMMENTS

1000

BE 00

MOV

START ADDR

20

SI,2000H

OF MESSAGE
STRING

1003

B8 00

MOV

INITIALISE

00

AX,0000H

THE DS TO
0000H

1006

8E D8

MOV DS, AX

1008

BA 26

MOV DX,

FF

FF26H

B0 82

MOV AL, 82H

100B

CONTROL REG
ADDR
INITI 8255
WITH PORT A
& PORT C

100D

EE

OUT DX, AL

AS OUTPUT
AND PORT B
AS INPUT

100E
1011

BA 24

MOV DX,

FF

FF24H

B0 07

MOV AL, 07H

PORT C ADDR
FOR MAKING
STROBE,
AUTOFEED
AND INT HIGH

1013

EE

OUT DX, AL

TO PORT C

1014

E8 0A

CALL PRINT

PRINT ONE

00

CHARACTER
1292

1017

8A 04

MOV AL,[SI]

GET THE
CHAR TO AL

1019

3C 0D

CMP AL,0DH

CHECK FOR
CR

101B

75 01

JNZ LOOP2

IF TRUE
TERMINATE
THE
PROGRAM

101D

CC

INT 3

LOOP2:
101E

46

INC SI

ELSE GET THE NEXT


CHAR

101F

EB

JMP

F3

LOOP1

BA

MOV

22

DX,0FF22H

CONTINUE PRINT

PRINT:
1021

PORT B ADDR

FF

LOOP3:
1024

EC

IN AL,DX

GET THE PRINTER


STATUS

1025

24

AND AL,

CHECK THE PB2


1293

1027

02

02H

75

JNZ LOOP3

BIT(BUSY)STATUS
IF BUSY THEN WAIT

FB
1029
102B

8A

MOV AL,

04

[SI]

BA

MOV

20

DX,0FF20H

ELSE GET THE CHAR


FROM MEMORY
PORT A ADDR

FF
102E

EE

OUT DX,AL

OUT THE CHAR TO PORT


A

102F

B0

MOV AL,04

04
1031

TO MAKE THE STROBE


SIGNAL TO LOW

BA

MOV

24

DX,0FF24H

PORT C ADDR

FF
1034

EE

OUT DX,AL

1035

90

NOP

1036

90

NOP

1037

B0

MOV AL,05

05

OUT TO PORT C

MAKE STROBE BACK TO


HIGH

1039

EE

OUT DX,AL

103A

C3

RET

OUT TO PORT C
RETURN

Working procedure for Printer Interface:


1294

Connect the 26 pin FRC from the kit to the Printer Interface card
Switch on the power supply.
Assemble the program.
Execute it and character will be printed.
Switch off the power supply and remove all the connections.

DIGITAL CLOCK PROGRAM IN 8086:


MAIN PROGRAM:
ADDRE

LAB

OPCO

MNEMONIC

SS

EL

DE

BA 26

MOV

FF

DX,FF26

1003

B4 00

MOV AH,00

1005

B0 80

MOV AL,80

1007

EE

OUT DX,AL

B5 00

MOV CH,00

B1 00

MOV CL,00

BA 22

MOV

FF

DX,FF22

100F

88 C8

MOV AL,CL

1011

EE

OUT DX,AL

1012

BA 20

MOV

FF

DX,FF20

1015

88 E8

MOV AL,CH

1017

EE

OUT DX,AL

1018

E8 E5

CALL

0F

2000(SECON

1000

1008

L1

100A
100C

L2

DS)
101B

FE C1

INC CL
1295

101D

88 C8

MOV AL,CL

101F

E8

CALL

DE 01

1200(CON IN
MIN)

1022

3C 60

CMP AL,60

1024

73 02

JNB
1028(L3)

1026

EB E4

JMP
100C(L2)

1028

L3

FE C5

INC CH

102A

B1 00

MOV CL,00

102C

88 E8

MOV AL,CH

102E

E8 DF

CALL

01

1210(CON IN
HRS)

1031

3C 24

CMP AL,24

1033

73 D3

JNB
1008(L1)

1035

ADDRESS

LABE

EB

JMP

D5

100C(L2)

OPCODE

MNEMONICS
1296

L
2000
2002

B2 00

MOV DL,00

LOOP

E8 FB

CALL 1100

F0

2005

FE C2

INC DL

2007

88 D0

MOV AL,DL

2009

3C 60

CMP AL,60

200B

73 02

JNB
200F(LOOP2)

200D

EB F3

JMP
2002(LOOP
1)

200F

LOOP

C3

RET

PROGRAM IN SECONDS:
DECIMAL CONVERTER PROGRAM IN MINUTES:
ADDRESS

LABE

OPCODE

MNEMONICS

1200

2C 01

SUB AL,01

1202

04 01

ADD AL,01

1204

27

DAA

1205

88 C1

MOV CL,AL

1207

C3

RET

1297

DECIMAL CONVERTER PROGRAM IN HOURS:

ADDRE

LABE

OPCOD

MNEMONI

SS

CS

1210

2C 01

SUB AL,01

1212

04 01

ADD AL,01

1214

27

DAA

1215

88 C5

MOV CH,AL

1217

C3

RET

DELAY PROGRAM:

ADDRESS LABEL
1100

OPCODE

MNEMONICS

BB

MOV

FF

BX,01FF

01
1103

LOO

B0

P3

DF

LOO

90

NOP

1106

90

NOP

1107

90

NOP

1105

MOV AL,DF

P4

1298

1108

90

NOP

1109

FE

DEC AL

C8
110B

75

JNE

F8

1105(LOOP
4)

110D

4B

DEC BX

110E

75

JNE

F3

1103(LOOP
3)

1110

C3

RET

1299

8251 PROGRAM IN 8086[BOARD]


TRANSMIT

12100

8251 PROGRAM IN 8086[BOARD]RECEIVE

ADDRES
S

OPCODE

MNEMONICS

COMMENTS

ADDRES
1031
2000S
1032
2003
1000
1034
2035
2006
1003
1035

EE OPCODE
90
B8 78 00
B0 40
E8 1C 00
B8 78 00
EE
BA
12 FF(62
8A C3
11 00
FF) 0B
E8

2038
1038
2008
1006
203A
103A
200B
1009
203B
200D
100A
103B
203C
200E
100D
103C
203D
2011
100E
103D
203F
2013
1010
103F
2040
2016
1012
1040
2043
2017
1015
1041
2045
2019
1016
1042
201B
1017
2046
1043
201D
1019
2047
1044
2020
101B
2048
1047
2021
101E
204A
1048
2022
101F
204B
1049
2024
1021
204C
104A
2026
1024
204D
104C
2029
1025
204E
104D
202A
1027
204F
202C
1028
2052
202F
1029
2053
2030
102A
2054
2032
102D
2055
2033
102F
2057

00 00
B0
4E
E8 03
E8 01 00
EE
EB F9
CC
EE
CC
BA 12 FF(62 FF)
90
EE
E8 3D 00
EC
90
B0
8A 40
D8
24 02
B0
27
EE
BA 12 FF(62 FF)
74
EE FB
E8
EC 0B 00
BA
90 10 FF(60 FF)
B0
4E
24 01
EC
90
EE
74 FB
C3
8A C3
8B
90 C8
53
BA 10 FF(60 FF)
B0
90 37
BB
FF 04
EE
BA
FF 06(50FF)
B0 27
90
C3
EE
90
8B C8
8A
90
4B C1
B0 37
BA
00 FF(50 FF)
90 FB
75
BA06 FF(50 FF)
EE
C3
5B
EE
8A
53 C5
C3
8A C1
EE
BB FF 04
BA 00 FF(50 FF)
90
EE
90
8A C5
BA
4B 12FF(62 FF)
EE
B0
00
75 FB
90
EE
5B

MNEMONICS
COMMENTS
OUT DX,AL
NOP
MOV AX,0078H
BAUD COUNT
AL,40H
RESET WORD
CALL 2022
AX CONTAIN TIMER COUNT
MOV DX,AL
AX,0078H BAUD COUNT
OUT
MOV
DX,FF12
FF12
STATUS REGISTER
MOV AL,BL
BL CONTAIN
THE BYTE TO BE
1017
INITIALIZE THE TIMER
CALL 1043
TX
AND USART
MOV
AL,00
DUMMY
WORD
MOV
AL,4E
00MODE
11 10TO
CALL 200E
TX01
ONE
BYTE
PC
CALL 100A
RX ONE BYTE
OUT
DX,AL
OUT
DX,AL
ONE STOPBIT,NO
JMP
2006
INT 3
PARITY,8BITS CHAR
OUT
INTDX,AL
3
MOV DX,FF12
FF12 STATUS REGISTER
NOP
OUT
DX,AL
CALL 204E
IN AL,DX
NOP
MOV
RESET
WORD
MOVAL,40
BL,AL
SAVE THE
BYTE
AND AL,02
MOV
AL,27
ENABLE TX
OUT
DX,AL
MOV
DX,FF12
STATUS REG
JE
100D
OUT
DX,AL
CALL
204E
IN AL,DX
GET THE STATUS BYTE
MOV
NOP DX,FF10
MOV
0100
1110
ANDAL,4E
AL,01
CHECK
THE READY BIT
IN
AL,DX
NOP
OUT
DX,AL
ONE STOP BIT, NO PARITY,
JE 2016
8BITS CHAR
RET
MOV AL,BL
RESTORE THE BYTE TO AL
MOV CX,AX
SAVE THE COUNT IN CX
NOP
PUSH
BX
MOV DX,FF10
MODE REG
AL,37
COUNTER 0 IS SELECTED
NOP
MOV BX,04FFH
OUT DX,AL
TX THE BYTE
MOV
DX,06FF
06FF CONTROL
REG
MOV
AL,27
ENABLE
TX
NOP
RET
OUT
DX,AL
OUT
DX,AL
NOP
MOV CX,AX
SAVE THE COUNT IN CX
MOV
AL,CL
COUNT LSB
NOP
DEC BX
MOV AL,37
COUNTER-0 IS SELECTED
MOV1047
DX,FF00
FF00 COUNTER 0 REG
NOP
JNE
MOV DX,FF06
FF06 CONTROL REG
OUT BX
DX,AL
RET
POP
OUT DX,AL
MOV
AL,CH
COUNT MSB
PUSH
RETBX
MOV AL,CL
COUNT LSB
OUT
DX,AL
MOV
BX,04FF
MOV DX,FF00
COUNTER-0 REG
NOP
NOP
OUT DX,AL
NOP
NOP
MOV AL,CH
COUNT MSB
MOV
FF12 STATUS REGISTER
DEC
BX DX,FF12
OUT DX,AL
A1,00
DUMMY MODE WORD
JNEMOV
2052
12101
NOP
OUT
DX,AL
POP BX

1030
2058

EE
C3

OUT DX,AL
RET

Working procedure for 8251 Interface:


Switch off the power supply and remove
Connect the 5V supply to the trainer kit
Connect the 50-pin FRC from the kit.
Switch on the power supply.
Assemble the program.
Execute it and output Tx & Rx data for pc.
the connectors.

INTERFACING HEX KEYBOARD WITH 8086 KIT:


This program is used to interface an external hex keypad with MP-86L kit.
Input clock to 8279 is 3MHZ. The program waits for a key to be entered from

12102

the keypad and the row and column matrix of the depressed key is stored in
Acc register.

16 Keys are arranged in 4 X 4 matrix. Their scan codes are as follows


21H

22H

23H

24H

19H

1AH

1BH

1CH

11H

12H

13H

14H

09H

0AH

0BH

OCH

I/O PORT ADDRESSES FOR 8279 :

FF50H

Data Register

FF52H

Status Register

OUTPUT:

scan code of the depressed key is at Acc

8086 KEYBOARD PROGRAM:


ADDRESS

LABEL

OPCODE

MNEMONICS

1000

B0 12

MOV AL,12H

1002

BA 52 FF

MOV DX,FF52H

1005

EE

OUT DX,AL

1006

B0 3E

MOV AL,3EH

1008

EE

OUT DX,AL

1009

B0 A0

MOV AL,A0H

100B

EE

OUT DX,AL

EC

IN AL,DX

24 01

AND AL,01H

100C
100D

L1

COMMENTS
CONTROL WORD

CONTROL & STATUS REG


OUT TO 8279
FOR FREQ DIVISION
OUT TO 8279

DISPLAY/WRITE INHIBIT
OUT TO 8279
READ STATUS OF 8279
FIFO EMPTY?
12103

IF YES LOOP BACK

100F

74 FB

JE 100CH(L1)

1011

BA 50 FF

MOV DX,FF50H

1014

EC

IN AL,DX

1015

24 3F

AND AL,3FH

1017

CC

INT 3

CHARACTER IS AVAILABLE
READ CODE FROM DATA PORT
SUPRESS UNWANTED BITS

BREAK POINT

INTERFACING 7 SEGMENT DISPLAY WITH 8086 KIT

This program is will display the character for the given 7 segment code on all the digits of
the display.
INPUT:

Enter the seven segment code at 2000h.


for example - 2000: BA ( seven segment code for 2)

I/O PORT ADDRESSES FOR 8279 :


FF52H

Data Register

FF50H

Status Register

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:


Char

Hex code

FC

60

b
g

c
12104

.h

8086 DISPLAY PROGRAM:


ADDRESS

LABEL

OPCODE

MNEMONICS

COMMENTS

1050

B0 12

MOV AL,12H

CONTROL WORD

1052

BA 52 FF

MOV DX,FF52H

1055

EE

OUT DX,AL

1056

B0 3E

MOV AL,3EH

1058

EE

OUT DX,AL

1059

B0 A0

MOV AL,A0H

105B

EE

OUT DX,AL

105C

B4 08

MOV AH,08H

CONTROL & STATUS REG


OUT TO 8279
FOR FREQ DIVISION
OUT TO 8279

DISPLAY/WRITE INHIBIT
OUT TO 8279
COUNT OF 8 FOR CLEARING
DIS.

105E

BA 50 FF

MOV DX,FF50H

1061

B0 00

MOV AL,00H

EE

OUT DX,AL

1064

FE CC

DEC AH

1066

75 FB

JNE 1063H(L1)

BA 52 FF

MOV DX,FF52H

EC

IN AL,DX

24 01

AND AL,01H

106E

74 FC

JE 106CH(L3)

1070

BA 50 FF

MOV DX,FF50H

DATA REGISTER ADDRESS

1073

BB 00 20

MOV BX,2000H

DATA I/P ADDRESS

1076

8A 07

MOV AL,[BX]

1078

EE

OUT DX,AL

1079

EB ED

JMP 1068H(L2)

1063

1068

L1

L2

106B
106C

L3

DATA REGISTER ADDRESS


DATA =0
OUT TO 8279
DECREMENT LOOP COUNT
WAIT TILL ZERO
STATUS REGISTER ADDRESS
READ STATUS OF 8279
FIFO EMPTY?
IF YES LOOP BACK

READ THE INPUT CODE

TO 8279 DATA REGISTER


JMP L2

12105

Working procedure for 8279 interface:

Connect the 50-pin FRC from the kit.


Switch on the power supply.
Assemble the program.
Execute it and press any key in keypad and then view the result in the
accumulator.
Before pressing any key in keypad execute the program once.
Switch off the power supply and remove the connectors.
.

8251 PROGRAM IN 8086[BOARD]

RECEIVE

12106

ADDRES
S

OPCODE

MNEMONICS

COMMENTS

1000

B8 78 00

MOV AX,0078H

BAUD COUNT

1003

E8 11 00

CALL 1017

INITIALIZE THE TIMER


AND USART

1006

E8 01 00

CALL 100A

RX ONE BYTE

1009
1031
100A
1032
100D
1034
100E
1035
1010
1038
1012
103A
1015

CC
EE
BA 12 FF(62 FF)
B0 40
EC
EE
24 02
E8 0B 00
74 FB
B0 4E
BA 10 FF(60 FF)
EE
EC

INT 3
OUT DX,AL
MOV DX,FF12
AL,40H
IN AL,DX
OUT DX,AL
AND AL,02
CALL 1043
JE 100D
MOV AL,4E
MOV DX,FF10
OUT DX,AL
IN AL,DX

1016
103B

C3
90

RET
NOP

1017
103C

8B C8
90

MOV CX,AX
NOP

SAVE THE COUNT IN CX

1019
103D

37
B0 27

AL,37
MOV AL,27

COUNTER
0 IS SELECTED
ENABLE TX

101B
103F

BA FF 06(50FF)
EE

MOV DX,AL
DX,06FF
OUT

06FF CONTROL REG

101E
1040

EE
90

OUT DX,AL
NOP

101F
1041

8A C1
90

MOV AL,CL
NOP

COUNT LSB

1021
1042

BA 00 FF(50 FF)
C3

MOV DX,FF00
RET

FF00 COUNTER 0 REG

1024
1043

EE
53

OUT DX,AL
PUSH
BX

1025
1044

8A
BB C5
FF 04

MOV AL,CH
BX,04FFH

1027
1047

EE
90

OUT DX,AL
NOP

1028
1048

90

NOP

1029
1049

90
4B

NOP BX
DEC

102A
104A

BA FB
12FF(62 FF)
75

MOV1047
DX,FF12
JNE

FF12 STATUS REGISTER

102D
104C

B0 00
5B

MOVBX
A1,00
POP

DUMMY MODE WORD

102F
104D

EE
C3

OUT DX,AL
RET

1030

EE

OUT DX,AL

FF12 STATUS REGISTER


RESET WORD

01 00 11 10
ONE STOPBIT,NO
PARITY,8BITS CHAR

COUNT MSB

12107

Working procedure for 8251 Interface:

Connect the 5V supply to the trainer kit


Connect the 50-pin FRC from the kit.
Switch on the power supply.
Assemble the program.
Execute it and output Tx & Rx data for pc.
Switch off the power supply and remove the connectors.

LOGICAL AND BIT MANIPULATION


AIM:
To write an ALP to perform logical and bit manipulation operations using 8051
microcontroller.
APPARATUS REQUIRED:
8051 microcontroller kit
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.

Initialize content of accumulator as FFH


Set carry flag (cy = 1).
AND bit 7 of accumulator with cy and store PSW format.
OR bit 6 of PSW and store the PSW format.
Set bit 5 of SCON.
Clear bit 1 of SCON.
Move SCON.1 to carry register.
12108

8. Stop the execution of program.


FLOWCHART:
START

Set CY flag, AND CY with MSB of


Store the PSW format, OR CY with bit 2 IE reg
Clear bit 6 of PSW, Store PSW
Set bit 5 of SCON , clear bit 1 and store
SCON
Move bit 1 of SCON to CY and store PSW
STOP

12109

PROGRAM TABLE FOR AND OPERATION


ADDRESS

OPCODE

MNEMONICS

8200

78

MOV R0, #DATA1

8201

02

8202

74

8203

02

8204

58

ANL A, R0

8205

90

MOV DATA R, #8250

8206

82

8207

50

8208

F0

MOVX @ DPTR, A

8209
820A

80
FE

SJMP HERE

INPUT

OUTPUT

MOV A, #DATA2

PROGRAM TABLE FOR OR OPERATION


ADDRESS

OPCODE

MNEMONICS

8200

78

MOV R0, #DATA1

8201

02

8202

74

8203

02

8204

58

ORL A, R0

8205

90

MOV DATA R, #8250

8206

82

8207

50

8208

F0

MOVX @ DPTR, A

8209
820A

80
FE

SJMP HERE

MOV A, #DATA2

INPUT

OUTPUT

RESULT:
Thus the logical operation was executed in 8051 trainer kit.

Square and Cube program, Find 2s complement of a number


AIM
To convert square and cube program, find 2s complement of a
number
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
PROGRAM: 2s COMPLEMENT

ADDRESS
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209

OPCODE
74
45
F4
01
90
90
00
F0
80
FE

MENEMONICS
MOV A, #45
CPLA
MOV DPTR, #9000
MOV @ DPTR, A
SJMP HERE

INPUT
OUTPUT

PROGRAM: SQUARE THE NUMBER

ADDRESS
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209

OPCODE
90
90
00
E0
F5
F0
A4
A3
F0
E5

MENEMONICS
MOV DPTR, #9000
MOV A, @ DPTR
MOV B, A
MUL AB
INC DPTR
MOV X @ DPTR, A
MOV AB

F0
A3
F0
80
FF

INC DPTR
MOV X @ DPTR, A
SJMP HERE

INPUT

OUTPUT
Cube program
org 0000h; sets the program counter to 0000h
mov a,#n;assign value 'n' in decimal to A which is converted to it's
equivalent hexadecimal value
mov b,#n;assign value 'n' in decimal to B which is converted to it's
equivalent hexadecimal value
mov r0,#n;assign value 'n' in decimal to R0 which is converted to it's
equivalent hexadecimal value
mul ab; multiplying 'A' with 'B'
mov 40h,a; lower byte is stored in address 40h
mov 41h,b; higher byte is stored in address 41h
mov r1,a; move value of 'A' to R1
mov a,b; move value of 'B' to 'A'
mov b,r0; move value of R0 to b
mul ab; multiply 'A' and 'B'
mov b,a; lower byte obtained is moved from 'A' to 'B'
mov r2,b; move value of 'B' to R2
mov a,r1; move value of R1 to 'A'
mov b,r0; move value of R0 to 'B'
mul ab; multiplying 'A' and 'B'

mov 50h,a; Lower byte obtained is stored in address 50h


mov r3,b; higher byte obtained is stored in R3
mov a,r2; move value from R2 to 'A'
add a,r3; add value of 'A' with R3 and store the value in 'A'
mov b,a; move value from 'A' to 'B'
mov 51h,b; store value obtained in address 51h
end
SQUARE PGM USING 8051
ORG 00h
02
LJMP MAIN
03 DELAY:
04 ;MOV R0,#2
05 MOV TMOD, #01H
06 MOV TH0, #HIGH (-50000)
07 MOV TL0, #LOW (-50000)
08 SETB TR0
09 JNB TF0,
10 CLR TF0
12 ;DJNZ R0,DELAY
13 RET
14 MAIN:
15 MOV DPTR,#300H
16 MOV A,#0FFH
17 MOV P1,A
18 BACK:
19 LCALL DELAY
20 MOV A,P1
21 MOVC A,@A+DPTR
22 ;MOV P2,#00H
23 ;LCALL DELAY
24 MOV P2,A
25 SJMP BACK
26 ORG 300H
27 XSQR_TABLE:
28 DB 0,1,4,9,16,25,36,49,64,81
29 END
RESULT:
Thus the Square and Cube program, Find 2s complement of a number is done in
8051 microcontroller

Unpacked BCD to ASCII

AIM:
To convert BCD number into ASCII by using 8051 micro controller
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply

FLOWCHART:

116

RESULT:
The given number is converted into ASCII using 8051 microcontroller kit.

117

You might also like