You are on page 1of 71

EX NO: 1

PROGRAMS FOR ARITHMETIC OPERATIONS

EX NO: 1.1

8-BIT ADDITION

DATE:

Addition of Two Bytes of Data

AIM:
To write an assembly language program to perform the 8-bit addition using 8086
instruction.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Initialize the pointer to the memory for data and result.


Load the data into AX, BX.
Add the two data of AX and BX registers.
Store the result into Memory from AX registers.

Input

Input datas (2 byte) are loaded into Memory address 1500.


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

Output

Result stored in Memory address 1520.


LSB in 1520, MSB in 1521.

Flowchart

Program

ADDRESS OPCODE

MNEMONICS
MOV

COMMENTS

1100

BE 00 15

SI, 1500

1103

AD

1104

89 C3

1106

AD

1107

01 C3

ADD

BX, AX

Add BX and AX registers

1109

BF 20 15

MOV

DI, 1520

Load 1520 address location into DI

110C

89 1D

MOV

[DI], BX

Store BX value into memory

110E

74

LODSW
MOV

Move 1500 into SI pointer


Load the first data into AX

BX, AX

LODSW

Move AX value into BX


Load the second data into AX

HLT

HALT

INPUT:
ADDRESS

DATA

ADDRESS

DATA

OUTPUT:

EX NO: 1

PROGRAMS FOR ARITHMETIC OPERATIONS

EX NO: 1.2

8-BIT SUBTRACTION

DATE:

AIM:
To write an assembly language program to perform the 8-bit subtraction using 8086
instruction.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Initialize the pointer to the memory for data and result.


Load the two datas into AX, BX.
Subtraction of these two bytes of data.
Store the result into Memory address 1520.

Input

Input datas (2 byte) are loaded into Memory address 1500.


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

Output

Result stored in Memory address 1520.


LSB in 1520, MSB in 1521.

Flow Chart

Program
ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

BE 00 15

MOV SI,1500

Load 1500 into SI

1103

AD

LODSW

Load the first data

1104

89 C3

MOV BX, AX

Move AX value into BX

1106

AD

LODSW

Load the second data

1107

01 C3

SUB BX, AX

subtract AX from BX

1109

BF 20 15

MOV DI, 1520

Load 1520 address into DI

110C

89 1D

MOV [DI],BX

Load BX value into DI

110E

CC

INT 3

Break point
5

INPUT:
ADDRESS

DATA

ADDRESS

DATA

OUTPUT:

PROGRAMS FOR ARITHMETIC OPERATIONS


8-BIT MULTIPLICATION

EX.NO:1.3
DATE:

AIM:
To write an assembly language program to perform the 8-bit multiplication using 8086
instruction.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Initialize the pointer to the memory for data and result.


Load the multiplier value into AX register.
Load multiplicand value in BX register.
Multiply of these two datas.
Store the result into Memory address 1520.

Input

Input datas (2 byte) are loaded into Memory address 1500.


Load the multiplier value in 1500.
Load the multiplicand value in 1502.

Output

Result stored in Memory address 1520.

Multiplication Of Two Byte Data

Flow Chart

Program

ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

BE 00 15

MOV SI,1500

Load 1500 into SI

1103

AD

LODSW

Load the multiplicand value

1104

89 C3

MOV BX, AX

Load AX value into BX

1106

AD

LODSW

Load the multiplier value

1107

F7 E3

MUL BX

Multiply two data

1109

BF 0 5 15

MOV DI, 1520

Load 1520 address into DI

110C

89 05

MOV [DI], AX

Store AX value into DI

110E

47

INC DI

Increment the DI

110F

47

INC DI

Increment the DI

1110

89 15

MOV [DI], BX

Store BX value into DI

1112

CC

INT 3

Break point

INPUT:
ADDRESS

DATA

ADDRESS

DATA

OUTPUT:

EX.NO:1.4

PROGRAMS FOR ARITHMETIC OPERATIONS


8-BIT DIVISION

DATE:

AIM:
To write an assembly language program to perform the 8-bit division using 8086
instruction.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Initialize the pointer to the memory for result.


Load the dividend value into AX register.
Load the divisor value into BX register.
Divide these two datas.
Store the result into Memory address 1520.

Input

Dividend value loaded into AX register.


Divisor value loaded into BX register.

Output

Result stored into 1520 address.


Quotient stored into 1522 address.
Remainder stored into 1523 address.

10

Division (2 Byte/ 1 Byte)

Flow Chart

11

Program

ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

BA 00 00 MOV DX, 0000

Clear DX registers

1103

B8 FD FF MOV AX, FFFD

Load the dividend in AX

1106

B9 0F 00 MOV BX, 0F

Load the divisor value in BX

1109
110B

F7 F1

DIV BX

Divide the two datas

BF 00 15 MOV DI, 1520

110E

88 05

1110

47

1111

88 25

1113

47

1114

89 15

1116

CC

Load 1520 address into DI

MOV [DI], AL

Load AL value into DI

INC DI

Increment DI

MOV [DI], AH

Load AH value into DI

INC DI

Increment DI

MOV [DI], DX

Load DX value into DI

INT3

Break point

INPUT:
ADDRESS

DATA

ADDRESS

DATA

OUTPUT:

12

EX NO: 2
EX NO: 2.1
DATE:

Programs For String Manipulation Operations


BLOCK MOVE FROM ONE LOCATION TO ANOTHER

AIM:
To write an assembly language program to perform the string manipulation operation by
moving data one location to other location.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

13

Algorithm

Initialize the pointer to the memory where data to be transformed.


Load the AL register with the data from memory.
Initialize destination pointer to the memory where data to stored.
Store data from AL register.

Input

Input data from address 1500 which is pointed SI, transferred to the desired
Location.
Number of byte in CL.

Output

Output data in address 1550 is the moved data.

Program
ADDRESS OPCODE MNEMONICS
1100
1102

B1 08
BE 00 14

MOV CL, 05

COMMENTS
Load 08 value into CL

MOV SI, 1200

Load 1200 into SI

1105

BF 50 14

MOV DI, 1300

Load 1300 into DI

1108

LOOP1:

MOV AX,[SI]

Load the data in AL Register

1109

88 05

INC SI

110B

47

MOV [DI],AX

110C

FE C9

INC DI

110E

75 F8

DEC CX

1110

CC

JNZ LOOP1

1113

MOV AH,4CH

1114

INT 21H

Increment the pointer

Decrement the pointer

Loop continues until the counter is zero

Break point
14

TABULATION:

INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

15

DATA

EX NO: 3

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 3.1

SEARCH AND FIND OPERATION

DATE:
AIM:
To write an assembly language program to perform the search operation and to find the
biggest number in an given array using 8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Searching a Byte

Flow Chart

16

Algorithm

Initialize the pointer to the memory for storing data and result.
Load DL with search byte.
Load CL with count.
Load AL with data from memory. Compare AL with DL if its equal store the
result else decrement counts go to step2.
Store the result.

Input

(Search the byte) A in 5 locations from 1500.


Output

Store the result byte in 1500.


Program
ADDRESS OPCODE MNEMONICS
1100

MOV CX,0005H

1103

MOV SI,1400H

1106
1108
110A

MOV AL,[SI]
INC SI
DEC CX

110B

LOOP1: CMP AL,[SI]

110D

JNC LOOP2

110F

MOV AL,[SI]

1111
1113

COMMENTS

LOOP2: INC SI
DEC CX

1114

JNZ LOOP1

1116

MOV SI,1500H

1117

MOV [SI],AL

1119

MOV AH,4CH

111A

INT 21H
17

TABULATION:

INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

18

DATA

EX NO: 3

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 3.2

REPLACE OPERATION

DATE:
AIM:
To write an assembly language program for replacing a data with given data for specified
location using 8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

ADDRESS OPCODE MNEMONICS


1100

MOV CX,0005H

1103

MOV AX,77H

1106
1108
110A

MOV SI,1200H
MOV [SI],AX
INC SI

LOOP:

110B

DEC CX

110D

JNZ LOOP

110F

MOV AH,4CH

1111

INT 21H

COMMENTS

TABULATION:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

19

DATA

EX NO: 3

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 3.3

COPY OPERATION

DATE:
AIM:
To write an assembly language program for copying the data at one location to another
using 8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

PROGRAM:
ADDRESS OPCODE MNEMONICS
1100

COMMENTS

MOV CX,0005H
MOV SI,1400H
LOOP:

MOV DI,1500H
MOV AX,[SI]
MOV [DI],AX
ADD SI,0002H
ADD DI,0002H
DEC CX
JNZ LOOP
MOV AH,4CH
INT 21H

TABULATION:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

20

DATA

EX NO: 3

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 3.4

SORTING OF AN ARRAY-DESCENDING ORDER

DATE:

Descending Order
AIM:
To write an assembly language program for arranging the datas in descending order using
8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Get the first data and compare with the second data.
If the two data are in descending order then no swap.
Else swap the data byte by descending order and then again compare the other
data bytes up to the count.
Do the above the array is a ranged in descending order.
Finally the array is arranged in ascending order.

Input

Enter the count in location 9000.


Enter the data location starting from 9001.

Output

Result in descending order in the location 9001.

21

Flow chart

22

Program
ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

BE 00 90

MOV SI, 9001

Load 9000 into SI

1103

8A 0C

MOV CL, [SI]

Load SI value into CL

1105

BE 00 90

MOV SI, 9000

get the count

1108

8A 14

MOV DL, [SI]

Load SI count value into DL

110A

46

INC SI

Increment the pointer

110B

8A 04

MOV AL, [SI]

first data in AL

110D

FE CA

DEC DL

Decrement DL

110F

74 16

JZ 1127

If count is zero then jump into 1127

1111

46

INC SI

Increment SI

1112

8A 1C

MOV BL, [SI]

Load SI count value into BL

1114

3A C3

CMP AL, BL

if al > bl go to (jump1)

1116

72 07

JB 111F

1118

4E

DEC SI

Decrement SI

1119

88 04

MOV [SI],AL

Load ACC value in SI

111B

88 D8

MOV AL, BL

Store the greatest data

111D

EB 03

JMP 1122

Jump into 1122

111F

4E

DEC SI

Decrement SI

1120

88 1C

MOV [SI], BL

Store the smallest data in memory

1122

46

INC SI

Increment SI

1123

FE CA

DEC DL

Decrement DL

1125

75 EA

JNZ 1111

If count is not zero then jump into 1111

1127

88 04

MOV [SI], AL

Load AL value into SI

1129

FE C9

DEC CL

Decrement CL

112B

75 D8

JNZ 1105

If count is not zero then jump into 1105

112D

CC

INT3

Break point

TABULATION:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

23

DATA

EX NO: 3

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 3.5

SORTING OF AN ARRAY-ASCENDING ORDER

DATE:

Ascending Order
AIM:
To write an assembly language program for arranging the datas in Ascending order using
8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Algorithm

Get the first data and compare with the second data.
If the two data are in ascending order then no swap.
Else swap the data byte by ascending order and then again compare the other data
bytes up to the count.
Do the above the array is arranged in ascending order.
Finally 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.


24

Flow chart

25

Program
ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

BE 00 90

MOV SI, 9000

Load 9000 into SI

1103

8A 0C

MOV CL, [SI]

Load SI value into CL

1105

BE 00 90

MOV SI, 9000

Get second data

1108

8A 14

MOV DL, [SI]

Load SI second data into DL

110A

46

INC SI

Increment SI

110B

8A 04

MOV AL, [SI]

Load SI value into AL

110D

FE CA

DEC DL

Decrement DL

110F

74 16

JZ 1127

If count is zero then go to 1127

1111

46

INC SI

Increment SI

1112

8A 1C

MOV BL, [SI]

Load SI value into BL

1114

38 D8

CMP AL, BL

if AL > BL go to (jump1)

1116

72 07

JNB 111F

1118

4E

DEC SI

Decrement SI

1119

88 04

MOV [SI],AL

Load AL value into SI

111B

88 D8

MOV AL, BL

Load BL value into AL

111D

EB 03

JMP 1122

111F

4E

DEC SI

Decrement SI

1120

88 1C

MOV [SI], BL

Load BL value into SI

1122

46

INC SI

Increment SI

1123

FE CA

DEC DL

Decrement DL

1125

75 EA

JNZ 1111

If count is not zero then go to 1111

1127

88 04

MOV [SI], AL

Load AL value into SI

1129

FE C9

DEC CL

Decrement CL

112B

75 D8

JNZ 1105

If count is not zero then go to 1105

INT3

Breakpoint

112D
CC
TABULATION:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

26

DATA

EX NO: 4

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 4.1

GRAY CODE CONVERSION(LOOK UP TABLE)

DATE:
AIM:
To write an assembly language program for converting the gray code from Binary using
8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

Algorithm
Load the memory with truth table of gray codes.
Initialize the pointer to the memory for data and result.
Load AL with the data from memory.
Convert gray code for that data.
27

Store the result into Memory.


Input

Data in 1500.

Output

Result in 1501.

Lookup Table

Start from 1600.

The look up table is provided by hex or of two bits in a byte the value ranges from 00 to
0f. 1600 - 00 01 03 02 06 07 05 04 0c 0d 0f 0e 0a 0b 09 08.

Program
ADDRESS OPCODE
BB 00 12
1100

MNEMONICS
MOV BX, 1600

COMMENTS
Load 1200 into BX

1103

BE 50 11

MOV SI, 1500

Load 1500 into SI

1106

AC

LODSB

Load the accumulator with the data

1107

D7

XLAT

Check gray code for that data

1108

BF 51 11

MOV DI, 1501

Load 1501 address into DI

110B

88 05

MOV [DI], AL

Store the gray code of the given data

110D

CC

INT3

Break point

28

EX NO: 4

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 4.2

ASCII TO HEX CODE CONVERSION

DATE:
AIM:
To write an assembly language program for converting the ascii code into Hex Code using
8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

29

Algorithm

Load the input data in AL register.


Subtract 30 from AL register value.
If data is less than or equal to 16 terminate the program.
Else subtract 7 from AL register value.
Result stored in AL register.

Input

Data input in AL register.


Output

Data output in AL register.


Program
ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

B0 31

MOV AL,31

Get data 31 into AL

1102

2C 30

SUB AL,30

Subtract 30 with the AL

1104

3C 10

CMP AL,10

1106

72 04

JB 110C

If data is less than or equal to 16 go to 110C


If 1st operand is below the 2nd operand then
short jump into 110C

1108

74 02

JZ 110C

If count zero then jump into to 110C

110A

2C 07

SUB AL,07

Else subtract 7 from AL register value

110C

CC

INT 3

Break point

30

EX NO: 4

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 4.3

BCD TO HEXA DECIMAL CODE CONVERSION

DATE:
AIM:
To write an assembly language program for converting the BCD code into Hex Code using
8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

31

Algorithm

Load the data in AL register.


Separate higher nibbles and (in) lower nibbles.
Move the higher nibbles (in) to lower nibbles position.
Multiply AL by 10.
Add lower nibbles.
Store the result into Memory.

Input

Data in AL register.

Output

Result in AL register.
Program
ADDRESS OPCODE

MNEMONICS

COMMENTS

1100

B0 10

MOV AL,10

Load register AL with the data 10

1102

88 C4

MOV AH,AL

Load AL value into AH

1104

80 E4 OF

AND AH,0F

Mask higher bits

1107

88 E3

MOV BL,AH

Load AH value into BL

1109

24 F0

AND AL,F0

Mask lower bits

110B

B1 O4

MOV CL,04

Load 04 value into CL

110D

D2 C8

ROR AL,CL

Rotate the data from last 4bits to first 4 bits

110F

B7 0A

MOV BH,0A

Load 10 value into BH

1111

F6 E7

MUL BH

Multiply by 10

1113

00 D8

ADD AL,BL

Add lower nibble to the multiplied data

1115

CC

INT3

Break point

32

EX NO: 4

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 4.4

HEXA DECIMAL TO ASCII CODE CONVERSION

DATE:

AIM:
To write an assembly language program for converting the Hex code into ASCII Code
using 8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

33

Algorithm

Load AL with the input data.


Check If (AL<=9) then add 30 with AL register.
Else add 7 with AL register.
Result stored into AL register.

Input

Data in AL register.

Output

Result in AL register.

Program

ADDRESS OPCODE MNEMONICS

COMMENTS

1100

B0 0A

MOV AL,0A

Load register AL with the data 10

1102

3C 09

CMP AL,09

If data less than 9 add 30 to the data

1104

74 04

JZ 110A

1106

72 02

JB 110A

If count is zero then go to 110A


If 1 operand is below than 2nd operand then
short jump into 110A

1108

04 07

ADD AL,07

Else Add AL with 07

110A

04 30

ADD AL,30

add 30 with AL

110C

CC

INT3

Break point

st

34

EX NO: 4

PROGRAMS FOR STRING MANIPULATION OPERATIONS

EX NO: 4.5

MATRIX ADDITION

DATE:

AIM:
To write an assembly language program for adding 2x2 Matrix without carary using 8086.
APPARATUS REQUIRED:
*8086 Microprocessor trainer kit
*Power supply

Flow Chart

35

Algorithm

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 into Memory.

Input

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

COMMENTS

1100

B1 09

MOV CL, 09

Initialize 09 into CL register

1102

BE 00 20

MOV SI, 2000

Load 2000 into SI for 1st matrix

1105

BF 00 30

MOV DI, 3000

Load 3000 into DI for 2nd matrix

1108
110A
110C

8A 04
8A 1D
00 D8

MOV AL, [SI]


MOV BL, [DI]
ADD AL, BL

Load AL with data of first matrix


Load BL with data of second matrix
Add two data of AL and BL

110E

88 05

MOV [DI], AL

Store AL with data into DI

1110

47

INC DI

Increment DI

1111
1112

46
FE C9

INC SI
DEC CL

1114

75 F2

JNZ 1108

Increment SI
Decrement CL
Loop continues until all elements of
Matrix to added

1116

CC

INT3

Break point
36

EX.NO: 5
DATE:

INTERFACING ANALOG TO DIGITAL CONVERTER WITH 8086


MICROPROCESSOR

AIM:
To write as assembly language program to convert an analog signal into a digital
signal using an ADC interfacing.
APPARATUS REGUIRED:
Microprocessor kit 8086 kit.
Power supply - +5v DC.
ADC interface board.
PROBLEM STATEMENT:
The program is executed for various values of analog voltage which are set
with the help of a potentiometer. The LED directly is verified with the digital value that
is shorted in a memory location.
ALGORITHM:

Select the control and catch the address.


Send the start conversion plus.
Read EOC signal.
If EOC=1 continuous else go to step (iii).
Read the digital output.
Store it in a memory location.

PROGRAM :INTERFACING ANALOG TO DIGITAAL CONVERTER


ADDRESS LABLE MNEMONICS OPCODE COMMENTS
2000
MOV AL,00
B0 00
Load accumulator with value for
ALE high.
2002
OUT 0C8,AL
E6 C8
Send through output port.
2004
MOV AL,08
B0 08
Load accumulator with value for
ALE low.
2006
OUT
E6 D0
Send through output port.
0C8H,AL
2008
MOV AL,01
B0 01
Store the value to make SOC
high the accumulator
37

200A
200C
200E
2010
2012
2014
2016
2018
201A
201C

201E
2020
2023
2025

L1

OUT 0D0H,AL
MOV AL,00
MOV AL,00
MOV AL,00
MOV AL,00

E6 D0
B0 00
B0 00
B0 00
B0 00

OUT 0D0H,AL
IN AL,0D8H
AND AL,01
CMP AL,01
JMZ 2022

E6 D0
E4 D8
24 01
3C 01
75 04

IN AL,0C0H
MOV
BX,1100
MOV [BX],AL
HLT

E4,C0
BB 00 11
88 07
F4

FLOWCHART:
Start

Select the channel


and latch address

Send the start


conversion pulse

If
EOC=1

Read the digital o/p

Store the digital values in the


memory location specified

stop

38

Send through output port.


Introduce delay.
Store the value to make SOC
low the accumulator
Send through output port.
Read the EOC signal from port &
check for end of conversion.
If the conversion is not yet
completed, read EOC signal from
port again.
Read data from port.
Initialize the memory location to
store data.
Store the data
Stop

MODEL GRAPH:

Amplitude

= 1.8 2v.

Time period = 20 1 ms.

RESULT:
Thus the ADC was interfaced with 8086 and the given analog were converted into its digital
equivalent.
39

EX.NO:6
DATE:

INTERFACE DIGITAL TO ANALOG CONVERTER WITH 8086


MICROPROCESSOR

AIM:
To write an assembly language program (ALP) for digital to analog
conversion and to convert digital output into analog output and to generate
different waveforms.
APPARATUS REQUIRED:
Microprocessor kit - 8086 kit.
Power supply.
DAC interface board.
ALGORITHM:
MEASUREMENT OF ANALOG VOLTAGE

Send the digital value of DAC.


Read the corresponding analog value of the output.

WAVEFORM GENERATION
SQUARE WAVEFORM:

Send low value (00) to the DAC.


Introduce suitable delay.
Send high value to DAC.
Introduce delay.
Repeat the above procedure.

SAWTOOTH WAVEFORM:

Load low value (00) to accumulator.


Send this value to DAC.
Increment the accumulator.
Repeat step (i) and (iii) untill accumulator values
reaches FF.
Repeat the above procedure from step1.
40

TRIANGULAR WAVEFORM:

Load the low value (00) in accumulator.


Send this accumulator content to DAC.
Increment the accumulator.
Repeat step 2 and step 3 untill the accumulator reaches
FF, decrement the accumulator and send the accumulator
content of DAC.
Decrement and sending the accumulator content to DAC.
The above procedure is from repeated from step (i).

PROGRAM:
MESUREMENT OF ANALOG VOLTAGE:
ADDRESS
2000
2002
2003

MNEMONICS
MOV AL,7FH
OUT DX,AL
HLT

OPCODE
B0 00
EE
F4

COMMENTS
Load digital value 00 in accumulator
Send through output port
Stop

PROGRAM SQUARE WAVE:


ADDRESS
2000
2002
2003
2006
2008
2009
200C
200E
2011
2013

LABLE
L2

L1
L3

MNEMONICS
MOV AL,00H
OUT DX,AL
CALL ,200E
MOV AL,FFH
OUT DX,AL
CALL 200E
JMP 2000
MOV CX,05FFH
LOOP 2011
RET

OPCODE
B0 00
EE
E8 15 00
B0 7F
EE
E8 0F 00
EB F2
B9 FF 05
E2 0C
00 E6

41

COMMENTS
Load 00 in accumulator
Send through output port
Give a delay
Load FF in accumulator
Send through output port
Give a delay
Go to starting location
Load count value in CX register
Decrement until it reaches zero
Return to main program

PROGRAM- SAWTOOTH WAVE:


ADDRESS
2000
2002
2004
2005

LABLE
L2
L1

2006

MNEMONICS
MOV AL,00H
OUT DX,AL
INC AL
JNZ 2002

OPCODE
B0 00
EE
FE C0
75 FB

JMP 2000

EB F7

COMMENTS
Load 00 in accumulator
Send through output port
Increment contents of accumulator
Send through output port until it
reaches FF
Go to starting location

PROGRAM - TRIANGULAR WAVE:


ADDRESS
2000
2002
2003
2005
2007
2009
200A
200C
200E

LABLE MNEMONICS
L3
MOV AL,00H
L1
OUT DX,AL
INC AL
JNZ 2002

L2

OPCODE
B0 00
EE
FE C0
75 FB

MOV AL,0FFH
OUT DX,AL
DEC AL
JNZ 2009

B0 00
EE
FE C8
75 FB

JMP 2000

EB F0

42

COMMENTS
Load 00 in accumulator
Send through output port
Increment contents of accumulator
Send through output port until it
reaches FF
Load FF in accumulator
Send through output port
Decrement contents of accumulator
Send through output port until it
reaches 00
Go to starting location

FLOWCHART:
MEASUREMENT OF ANALOG VOLTAGE
START
Send the digital value of
accumulator

Transfer the accumulator

Read the corresponding


analog value

STOP

SQUARE WAVEFORM:
STRAT
Initialize the
accumulator and ACC

Delay
Load the ACC with max
value send ACC content

Delay

43

TRIANGULAR WAVE:
START

Initialize
accumulator

Send accumulator
content to DAC

Increment accumulator

Is
ACC<=FF

yes

NO
Decrement
accumulator content

Send accumulator

Yes

Is
ACC<=00
44

No

SAWTOOTH WAVE:

START
Initialize accumulator

Send accumulator

Increment accumulator

NO

Is
ACC<FF

YES

MODEL GRAPH:
SQUARE WAVE:
amplitude

t(m)

TRIANGULAR WAVE:

amplitude

45

t(m)
SAWTOOTH WAVE:

amplitude

t(m)

RESULT:
Thus the DAC was implemented with 8086 and different waveforms have
been generated .

46

EX.NO:7
DATE:

INTERFACE MODEL TRAFFIC LIGHT CONTROLLER WITH 8086


MICROPROCESSOR

AIM:
Interface Traffic light controller with 8086 using 8255
PROCEDURE:

Connect a 20pin FRC cable between 8086 Microprocessor J6 port (Third port) or
J8 port (First port) and the Traffic light controller.
Program can be tested with GPIOII (8255) J6 or with GPIOI (8255) -J8.
Type the Program by using USB/ PS2 Key board.
Execute the Program. Now Traffic Light Leds are blinking.
PROGRAM:
Comments
ADDRESS
OPCODE
MNEMONICS
1100
BB 00 12
START: MOV BX, 1200H
1103
B9 08 00
MOV CX, 0008H
1106
8A 07
MOV AL,[BX]
1108
BA 36 FF
MOV DX, FF36
110B
EE
OUT DX, AL
110C
43
INC BX
110D
8A 07
NEXT: MOV AL,[BX]
110F
BA 30 FF
MOV DX, FF30
1112
EE
OUT DX,AL
1113
43
INC BX
1114
8A 07
MOV AL,[BX]
1116
BA 32 FF
MOV DX,FF32
1119
EE
OUT DX,AL
111A
E8 06 00
CALL DELAY
111D
43
INC BX
111E
49
DEC CX
111F
75 ED
JNZ NEXT
1121
EB DD
JMP START
1123
51
DELAY: PUSH CX
1124
B9 0F 00
MOV CX,000F
1127
BA FF FF
REPEAT: MOV DX,FFFFH
112A
4A
LOOP2: DEC DX
112B
75 FD
JNZ LOOP2
112D
E2 F8
LOOP REPEAT
112F
59
POP CX
1130
C3
RET
47

ORG 1200H
1200 80

DB 80H

1201 21 09 31 09

DB 21H,09H,31H,09H

1205 0C 09 8C 09

DB 0CH,09H,8CH,09H

1209 64 08 64 0C

DB 64H,08H,64H,0CH

120D 24 03 26 03

DB 24H,03H,26H,03H

48

PRINTER INTERFACE WITH 8086 MICROPROCESSOR

EX.NO:8
DATE:

AIM:
To Interface printer with 8086 using 8255
Apparatus Required:
8086 Processor
Power Supply
Printer
PROGRAM:

ADDRESS
1100
1103
1105
1108
1109
110B
110E
110F
1111
1114
1115
1117
111A
111D
1120
1122
1125
1127
112A
112C
112F
1131

LABEL
PRINT:

MNEMONICS

COMMENTS

MOV SI,1200H
MOV AL,0B6H
MOV DX,0FF06H
OUT DX,AL
MOV AL,040H
MOV DX,0FF04H
OUT DX,AL
MOV AL,01H
MOV DX,0FF04H
OUT DX,AL
MOV AL,00H
CALL SENDUART
CALL SENDUART
CALL SENDUART
MOV AL,040H
CALL SENDUART
MOV AL,04DH
CALL SENDUART
MOV AL,05H
CALL SENDUART
MOV BL,0AH
MOV DX,0FF10H

Load 1200 in to SI
8253 Channel 2
8253 control Reg for channel2
Clock divider LSB
8253 control data for channel2
Clock divider MSB
8253 control data for channel2

49

8251 Starting address


8251 Asynchronous Mode select
8251 Command Instruction

8251 control Data

SENDCHAR:

1134
1136
1137
113A
113B
113D
113F
1141
1144
1145
1148
114A

SENDUART:
DELAY:
DELAY1:

MOV AL,[SI]
OUT DX,AL
CALL DELAY
INC SI
DEC BL
JNZ SENDCHAR
JMP PRINT
MOV DX,0FF12H
OUT DX,AL
MOV CX,1000
LOOP DELAY1
RET

8251 control reg

ORG 1200H
DB

1BH,40H,1BH,31H,31H,32H,33H,34H,35H,0DH

50

EX.NO:9
DATE:

INTERFACE ROLLING DISPLAY USING 8279 WITH 8086


MICROPROCESSOR

AIM:
To display the rolling message 'HELLO' in the display.
PROCEDURE:

Connect a 50 Pin FRC Cable between 8051 Trainer Kit and the 8279
Keyboard/Display Interface card.

Connect USB/PS2 Keyboard on 8086 Microprocessor JP1 port.

Type and Execute the Program by using USB/PS2 Keyboard.

Now the Rolling Message HELLO would be display on 8279 keyboard/ display
interface card.

PROGRAM:
ADDRESS
1100
1103
1106
1108
110B
110C
110E
110F
1111
1112
1114
1117

OPCODE

MNEMONICS

BE 00 12
B9 0F 00
B0 10
BA 52 FF
EE
B0 CC
EE
B0 90
EE
8A 04
BA 50 FF
EE

START:MOV SI,1200
MOV CX,000F
MOV AL,10
MOV DX,FF52
OUT DX,AL
MOV AL,CC
OUT DX,AL
MOV AL,90
OUT DX,AL
LOP1: MOV AL,[SI]
MOV DX,FF50
OUT DX,AL

LOOK-UP TABLE:1200
FFH FFH FFH FFH
1204
FFH FFH FFH FFH
1208
98H 68H 7CH 7CH
120C
0CH FFH FFH FFH

51

Comments

SEVEN SEGMENT DISPLAY TYPES AND DISPLAY FORMAT


The hex decimal data corresponding to the segments which have to glow for displaying a
character is output to port B.

DISPLAY FORMAT
The hex decimal data corresponding to the segments which have to glow for displaying a
character is output to port B.
DISPLAY FORMAT
Display the A character Hexvalue 88H value

D7

D6

D5

D4

D3

D2

D1

D0

dp

52

DC MOTOR INTERFACE WITH 8086


MICROPROCESSOR

EX.NO:10

DATE:

AIM:
To interface DC motor with 8086 and to run the DC motor in forward direction

PROCEDURE:
Connect a 20 Pin FRC cable between 8086 Microprocessor J6 port (Third port) or
J9 port (First port) and the DC MOTOR/STEPPER MOTOR CARD.

Connect a DC motor at the MG1 connector or connect a Stepper Motor in J4.


Connect USB/PS2 keyboard on 8086. Type and execute the DC Motor or Stepper
Motor program.
Now the DC Motor or the Stepper Motor is running

PROGRAM:
ADDRESS
1100
1102
1105
1106
1108
110B
110C
110F
1111
1114
1115
1117

OPCODE

MNEMONICS

B0 80
BA 36 FF
EE
B0 05
BA 32 FF
EE
E8 02 00
EB F5
B9 FF FF
49
75 FD
C3

MOV AL,80
MOV DX,FF36
OUT DX,AL
START: MOV AL,05
MOV DX,FF32
OUT DX,AL
CALL DELAY
JMP START
DELAY: MOV CX,FFFF
LOOP: DEC CX
JNZ LOOP
RET

RESULT:
Execute the program. Now you can see that the DC motor runs in forward direction with
a delay.
53

EX.NO:11
DATE:

STEPPER MOTOR INTERFACE WITH 8086


MICROPROCESSOR

AIM:
To interface the stepper motor with 8086 trainer kit and to run a stepper motor at different
speed in clockwise directions.
PROCEDURE:
Connect a 20 Pin FRC cable between 8086 Microprocessor J6 port (Third port) or
J9 port (First port) and the DC MOTOR/STEPPER MOTOR CARD.

Connect a DC motor at the MG1 connector or connect a Stepper Motor in J4.

Connect USB/PS2 keyboard on 8086. Type and execute the DC Motor or Stepper
Motor program.
Now the DC Motor or the Stepper Motor is running

OPCODE
PROGRAM:
ADDRESS
1100
B0 80
1102
BA 36 FF
1105
EE
1106
BE 00 12
1109
B3 04
110B
8A 04
110D
BA 30 FF
1110
EE
1111
E8 07 00
1114
46
1115
FE CB
1117
75 F2
1119
EB EB
111B
B9 03 09
111E
49
111F
75 FD
1121
C3
ORG 1200H
1200 03
06
0C
09

MNEMONICS
MOV AL,80
MOV DX,FF36
OUT DX,AL
START : MOV SI,1200
MOV BL,04
REPEAT : MOV AL,[SI]
MOV DX,FF30
OUT DX,AL
CALL DELAY
INC SI
DEC BL
JNZ REPEAT
JMP START
DELAY: MOV CX,0903
LOOP : DEC CX
JNZ LOOP
RET
DB

03H, 06H, 0CH, 09H

END

RESULT:
Execute the program. Now we can see that the stepper motor runs in forward direction
with a delay.
54

8051
MICROCONTROLLER

55

EX NO:12

PROGRAMMING USING ARITHMETIC LOGICAL, BIT


MANIPULATION INSTRUCTIONS

EX.NO:12.1

BIT ADDITON AND SUBTRACTION WITHOUT CARRY

DATE:
AIM:
To writ an assembly language program to perform the 8-bit addition & subtraction
without carry using 8051 instruction.
APPARATUS REQUIRED:
*8051 Microcontroller trainer kit
*Power supply
PROGRAM FOR 8-BIT ADDITION WITHOUT CARRY:
ADDRESS LABEL MNEMONICS
8000
MOV DPTR,#8500H
8003
8005

MOV A,#05H
ADD A,#06H

8007

MOVX@DPTR,A

8008

LOOP

SJMP LOOP

OPCODE COMMENTS
90,85,00
Load the 16 bit data 8500h into
DPTR reg
74,05
Load the 8 bit data 05H into A reg
24,06
Add the 8 bit data 06H with
content of A reg
F0
Load the content of A reg into
memory location pointed by DPTR
80,FE
Short jump to the given address
specified by LOOP

INPUT:
DATA 1:05H
DATA 2:06H
OUTPUT:

ADDRESS
8500H

DATA
0BH

56

PROGRAM FOR 8 BIT SUBTRACION WITHOUT CARRY:


ADDRESS LABEL
8000
8001
8004
8006
8008
8009

LOOP

MNEMONICS
CLR C
MOV
DPTR,#8500H
MOV A,#05H
ADD A,#06H

OPCODE COMENTS
C3
Clear the carry flag
90,85,00
Load the 16 bit data 8500h into
DPTR reg
74,05
Load the 8 bit data 05H into A reg
24,06
Add the 8 bit data 06H with content
of A reg
MOVX@DPTR,A F0
Load the content of A reg into
memory location pointed by DPTR
SJMP LOOP
80,FE
Short jump to the given address
specified by LOOP

INPUT:
DATA 1:05H
DATA 2:06H
OUTPUT:

ADDRESS
8500H

DATA
FFH

RESULT:
Thus the program for addition and subtraction of two 8 bit data without carry was
written using 8051 instruction and the output is obtained and verified.

57

EX.NO:12.2

8 BIT ADDITION AND SUBTRACTION WITH CARRY

DATE:
AIM:
To write an assembly language program to perform the 8-bit addition & subtraction
with carry using 8051 instruction.
APPARATUS REQUIRED:
*8051 Microcontroller trainer kit
*Power supply
PROGRAM FOR 8-BIT ADDITION WITH CARRY:
ADDRESS LABEL MNEMONICS
8000
MOV
DPTR,#8500H
8003
MOV A,#05H
8005
ADD A,#06H
8007

MOVX @DPTR,A

8008

INC DPTR

8009
800A

CLR A
ADDC A,#00H

800C

MOVX @DPTR,A

800D

SJMP LOOP

OPCODE COMMENTS
90,85,00
Load the 16 bit data 8500H into
DPTR reg
74,05
Load the 8 bit data 05H into A reg
24,06
Add the 8 bit data 06H with content
of A reg
F0
Load the content of A reg into
memory location pointed by DPTR
A3
Increment the content of DPTR by
1.
E4
Clear the content of A reg.
34,00
Add the 8-bit data 00H and
previous carry with content of A
reg.
F0
Load the content of A reg into
memory location pointed by DPTR.
80,FE
Short jump to the given address
specified by LOOP.

INPUT:
DATA 1:05H
DATA 2:06H
OUTPUT:
ADDRESS
8500H
8501H

DATA
0BH(RESULT)
00H(CARRY)
58

PROGRAM FOR 8 BIT SUBTRACION WITH CARRY:


ADDRESS LABEL
8000
8001
8004
8006

MNEMONICS
CLR C
MOV
DPTR,#8500H
MOV A,#05H
SUBB A,#06H

8008

MOVX @DPTR,A

8009

INC DPTR

800A
800B

CLR A
ADDC A,#00H

800D

MOVX @DPTR,A

800E

SJMP LOOP

OPCODE COMMENTS
C3
Clear the carry flag.
90,85,00
Load the 16 bit data 8500H into
DPTR reg
74,05
Load the 8 bit data 05H into A reg
94,03
Subtract the 8 bit data 06H and
previous borrow from the content
of A reg
F0
Load the content of A reg into
memory location pointed by DPTR
A3
Increment the content of DPTR by
1.
E4
Clear the content of A reg.
34,00
Add the 8-bit data 00H and
previous carry with content of A
reg.
F0
Load the content of A reg into
memory location pointed by DPTR.
80,FE
Short jump to the given address
specified by LOOP.

INPUT:
DATA 1:05H
DATA 2:06H
OUTPUT:

ADDRESS
8500H
8501H

DATA
FFH(RESULT)
01H(CARRY)

RESULT:
Thus the program for addition and subtraction of two 8 bit data with carry was written
using 8051 instruction and the output is obtained and verified.
59

EX.NO:12.4

PROGRAM FOR 8- BIT MULTIPLICATION AND DIVISION

DATE:

AIM:
To write an assembly language program to perform the 8-bit multiplication & division by
using 8051 instruction.
APPARATUS REQUIRED:
*8051 Microcontroller trainer kit
*Power supply
PROGRAM FOR 8-BIT MULTIPLICATION:
ADDRESS LABEL
8000
8002
8005

MNEMONICS
MOV A,#FBH
MOV B,#12H
MUL A,B

OPCODE
77,FB
75,F0,12
A4

8006

90,85,00

8009

MOV
DPTR,#8500H
MOVX @DPTR,A

800A

INC DPTR

A3

800B

MOV A,B

E5,F0

800D

MOVX @DPTR,A

F0

SJMP LOOP

80,FE

800E

LOOP

F0

INPUT:
DATA 1:FBH
DATA 2:12H
OUTPUT:
ADDRESS
8500H
8501H

DATA
A6H
11H
60

COMMENTS
Load the 8 bit data FBH into A reg
Load the 8 bit data 12H into B reg
Multiply the content of A reg
with content of B reg.
Load the 16 bit data 8500H into
DPTR reg
Load the content of A reg into
memory location pointed by DPTR
Increment the content of DPTR by
1.
Move the content of B reg into B
reg.
Load the content of A reg into
memory location pointed by DPTR
Short jump to the given address
specified by LOOP.

PROGRAM FOR 8-BIT DIVISION:


ADDRESS LABEL
8000
8002
8005

MNEMONICS
MOV A,#FBH
MOV B,#12H
DIV A,B

OPCODE
77,FB
75,F0,12
84

8006

90,85,00

8009

MOV
DPTR,#8500H
MOVX @DPTR,A

800A

INC DPTR

A3

800B

MOV A,B

E5,F0

800D

MOVX @DPTR,A

F0

SJMP LOOP

80,FE

800E

LOOP

F0

61

COMMENTS
Load the 8 bit data FBH into A reg
Load the 8 bit data 12H into B reg
Divide the content of A reg with
content of B reg.
Load the 16 bit data 8500H into
DPTR reg
Load the content of A reg into
memory location pointed by DPTR
Increment the content of DPTR by
1.
Move the content of B reg into B
reg.
Load the content of A reg into
memory location pointed by DPTR.
Short jump to the given address
specified by LOOP.

EX.NO:13

PROGRAM FOR FINDING SQUARE AND CUBE PROGRAM,2S


COMPLEMENT OF A NUMBER USING 8051

DATE:

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


AIM:
To convert Square and Cube program, Find 2s complement of a number using 8051 micro
controller
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
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
62

end

RESULT:
Thus the Square and Cube program, Find 2s complement of a number is done in 8051
microcontroller
63

EX.NO:14
PROGRAM LOGICAL AND BIT MANIPULATION USING 8051
DATE:
AIM:
To write an ALP to perform logical and bit manipulation operations using 8051

microcontroller.
APPARATUS REQUIRED:
8051 microcontroller kit
ALGORITHM:
1. Initialize content of accumulator as FFH
2. Set carry flag (cy = 1).
3. AND bit 7 of accumulator with cy and store PSW format.
4. OR bit 6 of PSW and store the PSW format.
5. Set bit 5 of SCON.
6. Clear bit 1 of SCON.
7. Move SCON.1 to carry register.
8. Stop the execution of program.

64

65

66

EX.NO:15

Unpacked BCD to ASCII

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

67

FLOWCHART

68

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

69

S.No

Date

Description

70

Page
No.

Signature

S.No

Date

Description

71

Page
No.

Signature

You might also like