You are on page 1of 106

MICROPROCESSOR &

MICROCONTROLLER
LAB MANUAL

For Second Year B.E-CSE Students

UNITED INSTITUTE

OF

TECHNOLOGY
COIMBATORE-20

Prepared by,
Mr.S.KEERTHI M.E.,

UNITEDINSTITUTEOFTECHNOLOGY
PERIYANAICKENPALAYAM641020

DepartmentofComputer&ScienceEngineering

RECORDNOTE
CS6412MICROPROCESSORANDMICROCONTROLLER
LABORATORY

STUDENTNAME

REGISTERNO

SEMESTER

YEAR

STAFF INCHARGE

First Edition

HOD/DEAN

: Dec 2014

All Rights reserved by the publisher/author

Printed & Published by: United Institute of Technology,


G.Koundampalayam, Periyanaickenpalayam, Coimbatore 641 020

PREFACE

Preface
This workbook is prepared with an object of giving a firsthand
experience to the students in translating and experiencing theories of
Microprocessors

&

Microcontrollers

thorough

experimental

applications. The topic includes all relevant experiments as


prescribed by Anna University, Chennai. Enough care and efforts
have been taken to clarify every aspect of the theory involved in each
experiment.
The authors however prescribe the students to find analogies for
these theories and also to lookout for practical applications of each
proof of the theory explained.
.

Acknowledgement
I place my sincere thanks to the management, especially to the
Chairman, Shri. R.Shanmugam of United Institute of Technology for
having provided a scope for designing and formulating a laboratory
workbook on Microprocessors and Microcontrollers Laboratory.
I thank the principal, Dr.P.Prakasam, for all his encouragement
and inputs. I place my special thank to Dr.S.Natarajan Dean-ES and
Mrs. D Gokila Head of the department (ECE) for their valuable
inputs and editorial suggestions. Last but not the least I thank all the
other colleagues of United Institute of Technology for their support.

INSTRUCTIONS:
Wear shoes compulsorily.

Shirts should be tucked in.

Women students should protect their hairs.

Do not allow chains to hang.

Do not lean over rotating machinery.

Energize the circuit only after getting approval from the faculty in
charge.

Supply to your test table should be obtained only through the lab
technician.

Return the apparatus to stores and get permission from faculty in


charge before leaving the laboratory.

PREPARATION FOR LABORATORY RECORDS:

Each experiment should begin on a new page.

The name of the experiments should be written in capital letters on


the top of the page.

Experiment number and date should be written at the top left


corner.

Each record should contain the following


Aim of the Experiment
Apparatus Required
Procedure
Model Calculation
Results / Discussions.

All the above should be written on the right page of the


record.
Neat Circuit Diagram
Name Plate Details / Specifications / Design Details
Tabulations
Graph
The above should be written / drawn on the left page of the
record using pencil.

Graphs / figures drawn on sheets should be firmly pasted to the


record.

Before writing the record, the student should get the corresponding
observations approved by the faculty in - charge and carry over the
marks obtained to the record.

The record be completed in all respects and submitted in the next


class.

SYLLABUS
CS6412

MICROPROCESSOR AND MICROCONTROLLER LABORATORY

OBJECTIVES:
The student should be made to:
Introduce ALP concepts and features
Write ALP for arithmetic and logical operations in 8086 and 8051
Differentiate Serial and Parallel Interface
Interface different I/Os with Microprocessors
Be familiar with MASM
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

LTPC
0 032

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
TOTAL: 45 PERIODS
OUTCOMES:
At the end of the course, the student should be able to:

Write ALP Programs for fixed and Floating Point and Arithmetic
Interface different I/Os with processor
Generate waveforms using Microprocessors
Execute Programs in 8051
Explain the difference between simulator and Emulator

INDEX
Exp.No
1.
2.
3.
4.
4.a
4.b
4.c
4.d
5.a
5.b
5.c
6
7.
8
9

Experiment Name

Page Marks
No
16 BIT MICROPROCESSOR (8086)
Arithmetic Operations & Logical operations using 8086
Move a Data Block without Overlap
Code Conversions
Decimal Arithmetic & Matrix Operations
Floating point operations
String Copy, String Length
Sorting(Ascending &Descending order)
Searching
Password Checking
Print RAM Size
System Date
Counters and Time delay
PERIPHERALS AND INTERFACING EXPERIMENTS
Traffic light control
Stepper motor control
Digital clock

Signature

10

Key board and Display

11
12.a
12.b
13.a

Printer status
Serial interface and Parallel interface
Parallel Interface
A/D Interface

13.b

D/A interface and Waveform Generation


8051 Experiments using kits and ASM
Arithmetic Operations
Logical Operations
Square, Cube and 2s complement of a Number
Unpacked BCD to ASCII
Total Marks

14.a
14.b
15
16

8086 MICROPROCESOR

INTRODUCTION TO MASM
EDITOR:
An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes for the
letters and numbers in successive RAM locations. When you have typed in all of your programs, you
then save the file on a floppy of hard disk. This file is called source file. The next step is to process the
source file with an assembler. In the MASM /TASM assembler, you should give your source file name
the extension, .ASM
ASSEMBLER:
An assembler program is used to translate the assembly language mnemonics for instructions
to the corresponding binary codes. When you run the assembler, it reads the source file of your
program the disk, where you saved it after editing on the first pass through the source program the
assembler determines the displacement of named data items, the offset of labels and pails this
information in a symbol table. On the second pass through the source program, the assembler
produces the binary code for each instruction and inserts the offset etc that is calculated during the

10

first pass. The assembler generates two files on floppy or hard disk. The first file called the object file
is given the extension.OBJ. The object file contains the binary codes for the instructions and
information about the addresses of the instructions. The second file generated by the assembler is
called assembler list file. The list file contains your assembly language statements, the binary codes
for each instructions and the offset for each instruction. In MASM/TASM assembler, MASM/TASM
source file name ASM is used to assemble the file. Edit source file name LST is used to view the list
file, which is generated, when you assemble the file.
LINKER:
A linker is a program used to join several object files into one large object file and convert to
an exe file. The linker produces a link file, which contains the binary codes for all the combined
modules. The linker however doesnt assign absolute addresses to the program, it assigns is said to be
reloadable because it can be put anywhere in memory to be run. In MASM/TASM, LINK/TLINK
source filename is used to link the file.
DEBUGGER:
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look at the
contents of registers and memory locations after your program runs. It allows you to change the
contents of register and memory locations after your program runs. It allows you to change the
contents of register and memory locations and return the program. A debugger also allows you to set a
break point at any point in the program. If you inset a breakpoint the debugger will run the program
upto the instruction where the breakpoint is set and stop execution. You can then examine register and
memory contents to see whether the results are correct at that point. In MASM/TASM, td filename is
issued to debug the file.
DEBUGGER FUNCTIONS:
1. Debugger allows looking at the contents of registers and memory locations.
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and then stop
execution of program. At this point, we can examine registry and memory contents at that point.
5. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8
The DOS -Debugger:
The DOS Debug program is an example of simple debugger that comes with MS-DOS.
Hence it is available on any PC .it was initially designed to give the user the capability to
trace logical errors in executable file.
Below, are summarized the basic DOS - Debugger commands
COMMAND

SYNTAX

Assemble

A [address]

Compare

C range address

Dump

D [range]

11

Enter

E address [list]

Fill

F range list

Go

G [=address] [addresses]

Hex

H value1 value2

Input

I port

Load

L[address] [drive][first sector][number]

Move

M range address

Name

N[pathname][argument list]

Output

O port byte

Proceed

P [=address] [number]

Quit

Register

R[register]

Search

S range list

Trace

T [=address] [value]

Unassembled

U [range]

Write

W[address] [drive] [first sector] [number]

MS-MASM:
Microsofts Macro Assembler (MASM) is an integrated software package Written by
Microsoft Corporation for professional software developers. It consists of an editor, an assembler, a
linker and a debugger (Code View). The programmers workbench combines these four parts into a
user-friendly programming environment with built in on line help. The following are the steps used if
you are to run MASM from DOS.
PC PROGRAMMING WITH ASSEMBLY LANGUAGE USING MASM
Procedure:
1. Open command window (click: start->run->type cmd )

12

2. Paste the 8086 or MASM software in any drive.


3. In that window change the directory [Where you paste the masm software]

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

13

5. After changing directory type edit then you get one window in that window you can
write a program

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

14

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

8. Type: link filename,,; [This will create a list file you can see this
masm(8086)software]
Note:

inside the

Here we no need to use stack segment so no need to worry about stack error

15

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

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

16

11. Type:

WCS: 1000

[writing code segment]

17

12. Type:

g =1000 [to execute a program]

13. Type: u 1000 [to see opcode]

18

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

15. Type: q [terminate a line]

19

16. Downloading procedure


Note: dont use these command while down loading
Mov ah, 4ch
[These commands are used to see the results system itself]
Int 21h
(Bin file is used to downloading)
Type: dc then you can get the following window

20

17. Press f1 key and set the port settings

18. Press esc key to abort


19. Now in micro 86 kit select receiving mode (i.e.) type Si 1000(starting address) then press
enter key. Then the kit is ready to receive data and press any in the host to start transmission.
During transmission the message display as, transmission progress.
Press esc to abort.
Now binary files are downloaded to kit.

21

Ex. No: 1

ARITHMETIC OPERATIONS

AIM:
To write and execute an assembly language program for add, subtract, multiply and divide two
16 bit unsigned numbers in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
2. Add the two data and get the sum in AX-register.
3. Store the sum in memory location.
4. Stop the program.
PROGRAM:
i) By Using Masm:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 1234H
MOV BX, 1234H
ADD AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS

22

END
ii) By using 8086 kit:
ADDRESS

OPCODE

LABEL

MNEMONIC

COMMENTS

1000
1004
1008

C7,C0,34,12
C7,C3,34,12
01,D8

MOV AX,1234H
MOV BX,1234H
ADD AX,BX

Load AX-register with 1st data


Load BX-register with 2nd data
Add the contents of AX with BX

100A

C7,C6,00,12

MOV SI,1200H

Assign SI-reg to 1200H

100E

89,04

MOV [SI],AX

Store the sum

1010

F4

HLT

Stop the program

OUTPUT:
INPUT
Register
AX
BX

OUTPUT
Data
1234H
1234H

Address
1200H
1201H

Data
68
24

16-BIT SUBTRACTION:
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
3. Subtract the content of BX-reg from AX-register.
4. Store the result in memory location.
5. Stop the program.
PROGRAM:
i) BY USING MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 0FFFFH
MOV BX, 0EEEEH
SUB AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
1000

C7,C0,FF,FF

LABEL

MNEMONIC

COMMENTS

MOV AX,FFFFH

Load AX-register with 1st data

23

1004

C7,C3,EE,EE

MOV BX,EEEEH

1008

29,D8

SUB AX,BX

100A

C7,C6,00,12

MOV SI,1200H

Load BX-register with 2nd


data
Subtract the contents of BX
from AX-register
Assign SI-reg to 1200H

100E

89,04

MOV [SI],AX

Store the result

1010

F4

HLT

Stop the program

OUTPUT:
INPUT
Register
AX
BX

OUTPUT
Data
FFFFH
EEEEH

Address
1200H
1201H

Data
11
11

16-BIT MULTIPLICATION
ALGORITHM:
1.
2.
3.
4.
5.

Load the First Data in AX-register.


Load the First Data in BX-register.
Subtract the content of BX-reg from AX-register.
Store the result in memory location.
Stop the program.

PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 4444H
MOV BX, 4444H
MUL BX
MOV SI, 1200H
MOV [SI], DX
MOV SI, 1202H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS

OPCODE

LABEL

MNEMONIC

1000
1004
1008

C7,C0, 4444
C7, C3, 4444
F7, E3

MOV AX,4444H
MOV BX,4444H
MUL BX

100a

C7, C6,

MOV SI,1200H

24

COMMENTS
Load AX-register with 1st data
Load BX-register with 2nd data
Multiply the contents of AX with
BX-register
Assign SI-reg to 1200H

00,12
89, 14

100e
1010
1014

C7, C6,
02,12
89,04

1016

F4

MOV [SI],DX

Store the result

MOV SI,1202H

Assign SI-reg to 1202H

MOV [SI],AX

Store the result

HLT

Stop the program

OUTPUT:
INPUT
Register
AX
BX

OUTPUT
Data
4444H
4444H

Address
1200H
1201H
1202H
1203H

Data
34
12
10
32

32-BIT BY 16-BIT DIVISION


ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
3. Subtract the content of BX-reg from AX-register.
4. Store the result in memory location.
5. Stop the program.

PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV DX, 0000H
MOV AX, 8888H
MOV CX, 4444H
DIV CX
MOV SI, 1200H
MOV [SI], AX
MOV SI, 1202H
MOV [SI], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C7, C2,00,00
1004

C7, C0,88,88

MNEMONICS
MOV DX,0000H
MOV AX,8888H

25

COMMENTS
Initialize DX-register with Lsb of
Dividend
Load AX-register with Msb of
Dividend

1008

C7, C1,44,44

MOV CX, 4444H

Load CX-register with Divisor

100C
100E
1012
1014

F7, F1
C7, C6,00,12
89, 04
C7, C6,02,12

DIV CX
MOV SI,1200H
MOV [SI],AX
MOV SI,1202H

Divide AX by CX-register
Assign SI-reg to 1200H
Store the Quotient
Assign SI-reg to 1202H

MOV [SI],DX

Store the Remainder

HLT

Stop the program

1018

89, 14

101A

F4

OUTPUT:
INPUT
Register
DX
AX
CX

OUTPUT
Data
0000H
8888H
4444H

Address
1200H
1202H
1203H
1204H

Data
00(quotient)
02(quotient)
00(remainder)
00(remainder)

RESULT:
Thus an assembly language program for add, subtract, multiply and divide two 16 bit
unsigned numbers was executed using MASM and 8086 kit.
Ex. No: 1B

LOGICAL OPERATION

AIM:
To write and execute an assembly language program for performing logical OR, AND,
NAND operation in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically OR the content of AL with BL-register.
4. Store the result in memory location.
5. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL

26

INT 3H
CODE ENDS
END START
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C6,C0,85
1003
C6,C3,99

MNEMONICS
MOV AL,85H
MOV BL,99H

COMMENTS
Load AL-register with 1st Data
Load BX-register with 2nd Data

1006

08,D8

OR AL, BL

1008

C7,C6,00,12

MOV SI,1200H

OR the contents of AL with BLregister


Assign SI-reg to 1200H

100C

89,04

MOV [SI],AX

Store the Result

100E

F4

HLT

Stop the program

OUTPUT:
INPUT

OUTPUT

Register
AL
BL

Data
85H
95H

Address
1200H

Data
9D

LOGICAL AND OPERATION


ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically AND the content of AL with BL-register.
4. Store the result in memory location.
5. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
INT 3H
CODE ENDS
END START
ii) By using 8086 kit:
ADDRESS
OPCODE
1000
1000
C6,C0,85

LABEL

MNEMONICS
Org 1000h
MOV AL,85H

27

COMMENTS
Starting address of the program
Load AL-register with 1st Data

1003

C6,C3,99

MOV BL,99H

Load BX-register with 2nd Data

1006

20,D8

AND AL, BL

1008

C7,C6,00,12

MOV SI,1200H

AND the contents of AL with BLregister


Assign SI-reg to 1200H

100C

89,04

MOV [SI],AX

Store the Result

100E

F4

HLT

Stop the program

OUTPUT:
INPUT
Register
AL
BL

OUTPUT
Data
85H
95H

Address
1200H

Data
81H

LOGICAL NAND OPERATION


ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BX-register.
3. Logically AND the content of AX with BX-register.
4. Logically the content of AX register is complemented.
5. Store the result in memory location.
6. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
ADD AL, BL
NOT AL
INT 3H
CODE ENDS
END START
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C6,C0,85
1003
C6,C3,99

MNEMONICS
MOV AL,85H
MOV BL,99H

COMMENTS
Load AL-register with 1st Data
Load BX-register with 2nd Data

MOV SI,1200H

AND the contents of AL with BLregister


Complement the contents of ALregister
Assign SI-reg to 1200H

MOV [SI],AX

Store the Result

HLT

Stop the program

1006

20,D8

AND AL, BL

1008

F6,D0

NOT AL

100A

C7,C6,00,12

100E

89,04

1010

F4

28

OUTPUT:
INPUT
Register
AL
BL

OUTPUT
Data
85H
95H

Address
1200H

Data
7EH

VIVA QUESTIONS:
1.
2.
3.
4.
5.

What is a Microprocessor?
What is the need for timing diagram?
Define mnemonics.
What is the difference between min mode and max mode of 8086?
What is flag?

6.
7.
8.
9.

What is stack?
What is interrupt?
What are the various interrupts in 8086?
What is the difference between compiler and assembler?

10. Which interrupts are generally used for critical events?

RESULT:
Thus an assembly language program for performing logical OR, AND, NAND operation was
executed using MASM and 8086 kit.

29

Ex. No: 2

MOVE A DATA BLOCK WITHOUT OVERLAP

AIM:
To write and execute an assembly language program for transferring data from one block to
another block without overlapping using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Initialize counter.
2. Initialize source block pointer.
3. Initialize destination block pointer.
4. Get the byte from source block.
5. Store the byte in destination block.
6. Increment source, destination pointers and decrement counter.
7. Repeat steps 4, 5 and 6 until counter equal to zero.
8. Stop.
PROGRAM:
i) By using MASM:
DATA SEGMENT
ARRAY1 DW 1111H,2222H,3333H,4444H,5555H
ARRAY2 DW 5 DUP (0)
COUNT DW 0005H
CODE SEGMENT
MOV AX,@DATA
MOV DS, AX
LEA SI, ARRAY1
LEA DI, ARRAY2
MOV CX, COUNT
NEXT: MOV AX,[SI]
MOV DI, 1200H
MOV [DI], AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH, 4Ch
INT 21h
END
i) By using 8086 kit:
ADDRESS
OPCODE
1000
1000
C7 C6 0012
1004
C7 C7 0013
1008
C7 C1 0600

LABEL

MNEMONICS
Org 1000h
MOV SI, 1200H
MOV DI,1300H
MOV CX,0006 H

30

COMMENTS
Starting address of the program
Initialize the source address.
Initialize the destination address.
Initialize count value to the
count register.

100C

88,25

100F
1010
1011

FC
A4
E2,F3

1013

F4

MOV [DI], AH
REPEAT:

CLD
MOVSB
LOOP: REPEAT
HLT

Move content of AH to DIregister.


Clear the direction flag.
Move the string byte.
Unconditional loop to address
specified by the label REPEAT.
Stop the program

OUTPUT:
INPUT
Address
1200
1201
1202
1203
1204
1205

OUTPUT
Data
55
65
75
85
95
A5

Address
1300
1301
1302
1303
1304
1305

Data
55
65
75
85
95
A5

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.

What is the fabrication technology used for 8086?


What are the functional units available in 8086 architecture?
Write the flags of 8086.
What are control bits?
What are the flag manipulation instructions of 8086?
What is Macro?
Which bus controller used in maximum mode of 8086?
What is the size of data bus and address bus in 8086?
What are the various segment registers in 8086?

10. What is the maximum memory addressing capability of 8086?

RESULT:
Thus an assembly language program for transferring data from one block to another block
without overlapping was executed using 8086 kit and MASM.

31

Ex. No: 3A

CODE CONVERSION

AIM:
To write and execute an assembly language program for converting BCD to Binary data,
packed to unpacked BCD code using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the address of BCD data in SI-register.
2. Copy the BCD data to BL-register
3. Get the BCD data in AL-register.
4. Copy the BCD data in DL-register from AL-register.
5. Logically AND DL with 0Fh to mask upper nibble and get units digit in DL-reg.
6. Move the count value for rotation in CL-register.
7. Rotate the content of AL to move the upper nibble to lower nibble position.
8. Move 0Ah to DH-register.
9. Multiply AL with DH-register. The product will be in AL-register.
10. Add the units digit in DL-register to product in AL-register.
11. Save the binary data (AL) in memory.
12. Stop.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
MOV BL, 75
MOV AL, BL
MOV DL, AL
AND DL, 0FH
AND AL, 0F0H
MOV CL, 4
ROR AL, CL
MOV DH, 0AH
MUL DH
ADD AL, DL
MOV [BX+1], AL
MOV SI, 1200H
MOV [SI], BX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
1000
C6 C3 75
1003
88 D8

LABEL

MNEMONICS
MOV BL, 75
MOV AL, BL

32

COMMENTS
Copy BL-reg with data 7510.
Copy the contents of BL-reg to the

AL-register.
Copy the input data to DX-reg.

1005

88 C2

MOV DL, AL

1007

80 E2 0F

AND DL, 0Fh

100A

80 E0 F0

AND AL, 0F0h

100D

C6 C1 04

MOV CL, 4

1010

D2 C8

ROR AL, CL

1012

C6 C6 0A

MOV DH, 0Ah

1015

F6 E6

MUL DH

1017

00 D0

ADD AL, DL

1019

88 47 01

MOV [BX+1], AL

101C

C7 C6 00 12

MOV SI, 1200H

10

89 1C

MOV [SI], BX

10

F4

HLT

Logically AND the content of DLreg with 0Fh and store the resultant
data in DL-register.
Logically AND the content of DLreg with F0h and store the resultant
data in AL-register
Copy the data 4 to CL-reg.
Rotate right the contents of ALregister with the number of
counts in CL-register
Copy the data 0Ah to DH-reg.
Multiply AL with DH-register.
The product will be in AL-register.
Add the units digit in DL-register
to product in AL-register.
Copy the content of AL-reg to the
address pointed by BX-register.
Initialize SI-reg with address
1200H
Copy the contents of BX-reg to
address pointed by SI-reg.
Stop the program

OUTPUT:
INPUT
Register
BL

OUTPUT
Data
7410

Address
1200

PACKED BCD TO UNPACKED BCD CODE


ALGORITHM:
1. Load number into AL-register with packed BCD data.
2. Mask the lower nibble.
3. Rotate 4 times to right to make MSB=LSB.
4. Display the digit.
5. Load number into AL-register with upper nibble.
6. Mask upper nibble.
7. Display the result in memory location.
8. Stop.
PROGRAM:
i)
By using MASM:
CODE SEGMENT

33

Data
4Bh

ASSUME CS: CODE, DS: CODE


MOV AX, 45h
MOV AH, AL
MOV CL, 4h
SHR AH, CL
AND AX, 0F0FH
MOV SI, 1200H
MOV [SI], AX
INT 3H
CODE ENDS
END
ii)
ADDRESS
1000
1004

By using 8086 kit:


OPCODE LABEL
C7 C0 4500
88 C4

MNEMONICS
MOV AX, 45h
MOV AH, AL

1006

C6 C1 04

MOV CL, 4h

1009

D2 EC

SHR AH, CL

100B

81 E0 0F0F

AND AX, 0F0FH

100F
1013

C7 C6 0012
89 04

MOV SI, 1200H


MOV [SI], AX

1015

F4

HLT

COMMENTS
Copy AX-reg with data 45.
Copy the contents of AL-reg to the
AH-register.
Copy the data to CL-register.
Shift right the data of AL-register
based on the data on CL-register.
Logically AND the content of AXreg with 0F0Fh and store the
resultant data in AX-register
Load Si-reg with address 1200.
Copy the contents of AX-reg to
1200 address.
Stop the program

OUTPUT:
INPUT
Register
AX

OUTPUT
Data
45H

Address
1200
1201

Data
05
04

RESULT:
Thus an assembly language program for converting BCD to Binary data, packed to unpacked
BCD code using 8086 kit and MASM was implemented and its output was verified.

34

Ex. No: 3B

DECIMAL OPERATIONS

AIM:
To write and execute an assembly language program to add, subtract, multiply and divide
two 8-bit BCD data using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Add two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i)

ii)
ADDRESS
1000
1000

By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOV AL, 09H
MOV BL, 02H
ADD AL, BL
DAA
MOV CH, 02H
MOV SI, 1400H
MOV [SI], AL
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
By using 8086 kit:
OPCODE LABEL
C6 C0 09

MNEMONICS
Org 1000h
MOV AL, 09H

35

COMMENTS
Starting address of the program
Load AL-reg with data 09h.

1003

C6 C3 02

MOV BL, 02H

Load BL-reg with data 02h.

1006

00 D8

ADD AL, BL
DAA

Add the contents of AL-reg with


BL-register and the result will be
stored in AL-register.
Adjust result to valid BCD number.

1008

27

1009

C6 C5 02

MOV CH, 02H

Count of digits to be displayed

100C

MOV SI, 1400H

Load Si-reg with address 1400.

1010

C7 C6 00
14
88 04

MOV [SI], AL

1012
1015

C6 C1 04
88 C7

MOV CL, 04H


MOV BH, AL

1017

D2 CF

1019

88 FA

MOV DL, BH

101B
101E
1021
1023
1026
1029
102B

80 E2 0F
80 FA 09
76 03
80 C2 07
80 C2 30
FE CD
75 EA

AND DL, 0FH


CMP DL, 09
JBE L4
ADD DL, 07
ADD DL, 30H
DEC CH
JNZ L2

102D

F4

Copy the contents of AL-reg to


address 1400.
Count to roll by 4-digits
Copy the contents of AL-reg to
BH-register
Roll BL-reg so that MSB comes to
LSB.
Load DL-reg with data to be
displayed.
Get only LSB data.
check if digit is 0-9 or letter A-F
If byte jump to label L4
If letter add 37H
Else only add 30H
Decrement Count
If count is not zero then goto label
L2
Stop the program

L2:

ROL BH, CL

L4:

HLT

OUTPUT:
INPUT
Register
AL
BL

OUTPUT
Data
09
02

Address
1400

BCD SUBTRACTION
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Subtract two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i)

By using MASM:
CODE SEGMENT

36

Data
11

ASSUME CS: CODE


MOV AL, 32H
MOV BL, 17H
SUB AL, BL
DAS
MOV CH, 02H
MOV SI, 1400H
MOV [SI], AL
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
iii)
ADDRESS
1000

By using 8086 kit:


OPCODE LABEL
C6 C0 32

MNEMONICS
MOV AL, 32H

COMMENTS
Load AL-reg with data 32h.

1003

C6 C3 17

MOV BL, 17H

Load BL-reg with data 17h.

1006

28 D8

SUB AL, BL

1008

2F

DAS

Subtract the contents of BL-reg


from AL-register and the result will
be stored in AL-register.
Adjust result to valid BCD number.

1009

C6 C5 02

MOV CH, 02H

Count of digits to be displayed

100C

MOV SI, 1400H

Load Si-reg with address 1400.

1010

C7 C6 00
14
88 04

MOV [SI], AL

1012
1015

C6 C1 04
88 C7

MOV CL, 04H


MOV BH, AL

1017

D2 C7

1019

88 FA

MOV DL, BH

101B
101E
1021

80 E2 0F
80 FA 09
76 03

AND DL, 0FH


CMP DL, 09
JBE L4

Copy the contents of AL-reg to


address 1400.
Count to roll by 4-digits
Copy the contents of AL-reg to
BH-register
Roll BL-reg so that MSB comes to
LSB.
Load DL-reg with data to be
displayed.
Get only LSB data.
check if digit is 0-9 or letter A-F
If byte jump to label L4

L2:

ROL BH, CL

37

1023
1026
1029
102B

80 C2 07
80 C2 30
FE CD
75 EA

102D

F4

ADD DL, 07
ADD DL, 30H
DEC CH
JNZ L2

L4:

HLT

If letter add 37H


Else only add 30H
Decrement Count
If count is not zero then goto label
L2
Stop the program

OUTPUT:
INPUT
Register
AL
BL

OUTPUT
Data
32
17

Address
1400

BCD MULTIPLICATION
ALGORITHM:
1.
2.
3.
4.
5.

Get the 1st BCD number.


Get the 2nd BCD number.
Multiply two BCD numbers.
Adjust result to valid BCD numbers.
Display the result.

PROGRAM:
ii)

By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOV AL, 04H
MOV BL, 06H
MUL BL
AAM
MOV CH, 04H
MOV SI, 1400H
MOV [SI], AX
MOV CL, 04H
MOV BH, AL
L2:
ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END

38

Data
15

iv)
ADDRESS
1000
1000

By using 8086 kit:


OPCODE LABEL
C6 C0 32

MNEMONICS
Org 1000h
MOV AL, 06H

COMMENTS
Starting address of the program
Load AL-reg with data 04h.

1003

C6 C3 04

MOV BL, 04H

Load BL-reg with data 06h.

1006

F6 E3

MUL BL

1008

D4 0A

AAM

Multiply the contents of AL-reg


with BL-register and the result will
be stored in AL-register.
Adjust result to valid BCD number.

100A

C6 C5 04

MOV CH, 04H

Count of digits to be displayed

100D

MOV SI, 1400H

Load Si-reg with address 1400.

1011

C7 C6 00
14
88 04

MOV [SI], AL

1013
1016

C6 C1 04
88 C7

MOV CL, 04H


MOV BH, AL

1018

D2 C7

101A

88 FA

MOV DL, BH

101C
101F
1022
1024
1027
102A
102C

80 E2 0F
80 FA 09
76 03
80 C2 07
80 C2 30
FE CD
75 EA

AND DL, 0FH


CMP DL, 09
JBE L4
ADD DL, 07
ADD DL, 30H
DEC CH
JNZ L2

102E

F4

Copy the contents of AL-reg to


address 1400.
Count to roll by 4-digits
Copy the contents of AL-reg to
BH-register
Roll BL-reg so that MSB comes to
LSB.
Load DL-reg with data to be
displayed.
Get only LSB data.
check if digit is 0-9 or letter A-F
If byte jump to label L4
If letter add 37H
Else only add 30H
Decrement Count
If count is not zero then goto label
L2
Stop the program

L2:

ROL BH, CL

L4:

HLT

OUTPUT:
INPUT
Register
AL
BL

OUTPUT
Data
04
06

Address
1400
1401

BCD DIVISION
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Multiply two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:

39

Data
04
02

i).

iii)
ADDRESS

By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOVAL, 000FH
MOV BL, 08H
DIV BL
MOV CH, 04H
MOV SI, 1400H
MOV [SI], AX
MOV SI, 1402H
MOV [SI], BL
MOV CL, 04H
MOV BH, AL
L2:
ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4:
ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
By using 8086 kit:
OPCODE
LABEL

MNEMONICS

COMMENTS

1000

C6,C0,0F

MOVAL, 000FH

Load AL-reg with data 0Fh.

1003
1006

C6,C3,08
F6,F3

MOV BL, 08H


DIV BL

1008

C6,C5,04

MOV CH, 04H

Load BL-reg with data 08h.


Divide the contents of AL-reg with
BL-register and the result will be
stored in AL-register.
Count of digits to be displayed

100b

C7,C6,00,14

MOV SI, 1400H

Load SI-reg with address 1400.

100f

89,04

MOV [SI], AX

Copy the contents of AL-reg to


address 1400.

1011

C7,C6,02,14

MOV SI, 1402H

Load SI-reg with address 1402.

1015

88,1C

MOV [SI], BL

1017
101a

C6,C1,04
88,C7

MOV CL, 04H


MOV BH, AL

101c

D2,C7

Copy the contents in BL-reg to


address 1402.
Count to roll by 4-digits
Copy the contents of AL-reg to
BH-register
Roll BL-reg so that MSB comes to
LSB.

L2:

ROL BH, CL

40

101e

88,FA

MOV DL, BH

1020
1023
1026
1028
102b
102e
1030

80,E2,0F
80,FA,09
76,03
80,C2,07
80,C2,30
FE,CD
75,EA

AND DL, 0FH


CMP DL, 09
JBE L4
ADD DL, 07
ADD DL, 30H
DEC CH
JNZ L2

1032
OUTPUT:

F4

L4:

HLT

Load DL-reg with data to be


displayed.
Get only LSB data.
check if digit is 0-9 or letter A-F
If byte jump to label L4
If letter add 37H
Else only add 30H
Decrement Count
If count is not zero then goto label
L2
Stop the program

INPUT
Register
AL
BL

OUTPUT
Data
F(Dividend)
08(Divisor)

Address
1400
1401

41

Data
01(Quotient)
07(Remainder)

RESULT:
Thus an assembly language program for performing addition, subtraction,
multiplication and division of two 8-bit BCD numbers was performed and its output was verified.

Ex. No: 3C

MATRIX ADDITION

AIM:
To write and execute an assembly language program for performing addition of two matrices
using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Multiply two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i).
By using MASM:
.MODEL SMALL
.DATA
M1 DB 00H,01H,10H,12H,02H,03H,0F0H,0C0H,04H
M2 DB 00H,05H,01H,02H,50H,90H,03H,04H,0AAH
.CODE
.STARTUP
MOV BX, OFFSET M1
MOV BP, OFFSET M2
MOV SI, 0001H
MOV CL, 09H
REPEAT: MOV AL,[BX+SI]
ADD AL, [BP+SI]
MOV [DI], AL
INC SI
INC DI
LOOP REPEAT
MOV AH, 4CH
INT 21H
END
ii)
ADDRESS
1000

By using 8086 kit:


OPCODE
LABEL
C7,C3,00,13

MNEMONICS
MOV BX,1300H

1004

C7,C5,00,14

MOV BP,1400H

1008

C7,C6,00,00

MOV SI,0000H

42

COMMENTS
Load the base address of the 1st
input matrix in BX.
Load the base address of the 2 nd
input matrix in BP
Initialize pointer for element of

100C

C7,C7,00,15

MOV DI,1500H

1010

C6,C1,09

MOV CL, 09H

1013

8A,00

1015

02,02

MOV AL,[BP+SI]

1017

88,05

MOV [DI],AL

1019

46

INC SI

101A
101B

47
E2,F6

101D

F4

REPEAT:

L2:

MOV AL,[BX+SI]

INC DI
LOOP REPEAT
HLT

matrix.
Set DI-register as pointer for sum
matrix.
Set CL as count for elements in
matrix.
Get an element of 1st matrix in
AL.
Add corresponding element of 2nd
matrix to AL.
Store the sum of an element in
memory.
Increment the pointers.
Increment the pointers.
Repeat addition until count is
zero.
Stop the program

OUTPUT:
ADDRESS
1300
1301
1302
1303
1304
1305
1306
1307
1308

INPUT
DATA
ADDRESS
00H
1400
01H
1401
10H
1402
12H
1403
02H
1404
03H
1405
0F0H
1406
0C0H
1407
04H
1408

OUTPUT
DATA
00H
05H
01H
02H
50H
90H
03H
04H
0AAH

Address
1501
1502
1503
1504
1505
1506
1507
1508
1509

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What is the fabrication technology used for 8086?


What are the features of Intel 8086?
What is Logical Address?
What is The Effective Address:
What is Program counter?
Distinguish between packed BCD and unpacked BCD
What is 1st / 2nd / 3rd / 4th generation processor?
Name the processor lines of two major manufacturers?
What are the different types of Addressing Modes?
What are the General Data Registers & their uses?

43

Data
00
06
11
14
52
93
F3H
C4H
AEH

RESULT:
Thus an assembly language program for performing addition of two matrices numbers was
performed and its output was verified.
Ex. No: 4A
FLOATING POINT OPERATIONS
AIM:
To write and execute an assembly language program for computing the area of a circle using
8087 instruction using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Start
2. Initialize the 8087 processor.
3. Fetch the Radius from Memory location 1500h.
4. To obtain r2 multiply using the instruction ST with ST (0)
5. Then is loaded employing a constant load operation.
6. Now perform *r*r using fmul instruction.
7. Now convert the resultant data to packed decimal before storing it in memory location.
8. Store the result in memory location 1600H.
9. Stop.
PROGRAM:
(i)

BY USING MASM:
.MODEL SMALL
.DATA
RADIUS DD 3.4
AREA DD ?
END
.CODE
MOV AX,@DATA
MOV DS,AX
FINIT
FLD RADIUS
FMUL ST, ST(0)
FLDPI
FMUL
FSTP AREA
END

i)
ADDRESS
1000
1003
1008

By using 8086 kit:


OPCODE
LABEL
9B DB E3
PB DF 06
0015
9B D8 C8

MNEMONICS
FINIT
FILD DS:[1500H]

COMMENTS
Initialize
radius

FMUL ST, ST(0)

St = r*r

44

100B
100E

9B D9 EB
9B D8 C9

FLDPI
FMUL ST, ST(1)

1011 9B
1016

DF 36 0016
F4

FBSTP DS: [1600H]


HLT

OUTPUT:
INPUT
ADDRESS
DATA
1500
2

ADDRESS
1600

OUTPUT
DATA
12.56

45

St (0) = pi
St (1) = r*r
St = pi*r*r
Area
Stop the program

RESULT:
Thus an assembly language program for finding the area of a circle using 8087 instruction
was performed and its output was verified.
Ex. No: 4B

STRING OPERATIONS

AIM:
To write and execute an assembly language program to find the length and copying string,
using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the source and destination index register with starting and the ending address
respectively.
2. Load the terminate data value as FF.
3. Load the content of source index to the AL register.
4. Increment SI register and compare with register AH.
5. If it is non- zero value, increment the memory location by using the control instruction to
store the data.
6. Compare the string byte with FF, if it is not equal, repeat.
7. Count the string byte till zero flag is set. If zero flag is set then store the count value to the
memory.
8. Terminate the program when FF is matched.
9. Stop
PROGRAM:
i)
By using MASM:

START:

BACK:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
STRING1 DB 'MICROPROCESSOR AND INTERFACING LAB$'
DATA ENDS
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
SUB CL, CL
MOV SI, OFFSET STRING1
LODSB
INC CL
CMP AL,'$'
JNZ BACK
MOV BL, CL
MOV SI, 1200H
MOV [SI], BL

46

INT 03H
CODE ENDS
END START
ii)
ADDRESS

By using 8086 kit:


OPCODE
LABEL

1000
1004

C7,C6,00,12
C7,C7,FF,FF

1008
100B
100C
100E

C6,C4,FF
42
8A,04
46

100F

38,C4

CMP AH,AL

1011

75,FB

JNZ : NOEND

1013

89,16,00,11

MOV [1100],DX

1017

F4

MNEMONICS
MOV SI,1200H
MOV DX, FFFFH

NOEND:

MOV AH, FFH


INC DX
MOV AL,[SI]
INC SI

HLT

COMMENTS
SI 1200
DXFFFF
AH FF, check FF
Increment the DX reg by 1
AL [SI]
Increment the SI reg. by 1
Compare the content of AH
& AL
If the Compared result is not
0 go to by the address
specified label NOEND.
[1100] DX ie. store the
result
Terminate the program

INPUT:
ADDRESS (Hex)
1200
1201
1202
1203
1204
1205
1206
1207

Data (Hex)
E3
F4
54
66
88
99
10
FF

OUTPUT:
ADDRESS (Hex)
1100

String length Hex)


07

STRING COPYING
ALGORITHM:
1. Load the source and destination index register with starting and the ending address
respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction MOVSW with the prefix REP to copy a string from
source to destination.
5. Stop

47

PROGRAM:
i)

By using MASM:
.MODEL SMALL
DATA SEGMENT
SRC DB MICROPROCESSOR
DB 10 DUP (?)
DST DB 20 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA, ES: DATA
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
LEA SI, SRC
LEA DI, DST
MOV CX, 20
CLD
REP MOVSB
INT 3H
CODE ENDS
END START

ii)
By using 8086 kit:
ADDRESS
OPCODE
1000
C7,C6,00,20

LABEL

MNEMONICS
MOV SI,2000H

1003

C7,C7,00,21

MOV DI,2100H

1007

C7,C1,06,00

MOV CX,0006 H

100B
100E
100F

C6,C4,55
FC
A4

1010

E2,FB

1013

F4

REPEAT:

address.
Initialize count value to the

MOV AH,55H
CLD
MOVSB

count register.
Move 55 to AH register.
Clear the direction flag.
Move the string byte.
Unconditional loop to

LOOP:REPEAT

address specified by the

HLT

label REPEAT.
Stop the program.

OUTPUT:
INPUT
ADDRESS
DATA
2000
55
2001
55
2002
55
2003
55
2004
55
2005
55

COMMENTS
Initialize the source address.
Initialize the destination

OUTPUT
ADDRESS
DATA
2100
55
2101
55
2102
55
2103
55
2104
55
2105
55

48

RESULT:
Thus an assembly language program for copying, finding the length of a string was
implemented and its output was verified.

49

Ex. No: 4C

SORTING (ASCENDING AND DESCENDING ORDER)

AIM:
To write and execute an assembly language program to sort an array of numbers in ascending
and descending order.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
SORTING IN ASCENDING ORDER:
1.
Start
2.
Load the array count in two registers C1 and C2.
3.
Get the first two numbers.
4.
Compare the numbers and exchange if necessary so that the two numbers are in
ascending order.
5.
Decrement C2.
6.
Get the third number from the array and repeat the process until C2 is 0.
7.
Decrement C1 and repeat the process until C1 is 0.
8.
Stop
SORTING IN DESCENDING ORDER:
1.
Start
2.
Load the array count in two registers C1 and C2.
3.
Get the first two numbers.
4.
Compare the numbers and exchange if necessary so that the two numbers are in
descending order.
5.
Decrement C2.
6.
Get the third number from the array and repeat the process until C2 is 0.
7.
Decrement C1 and repeat the process until C1 is 0.
8.
Stop
PROGRAM:
i)
By using MASM:
.MODEL SMALL
.STACK 100
.DATA
NUM DB 12H, 45H, 79H, 66H
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV BX, 3
LOOP2: MOV CX, BX
MOV DI, 0
MOV AL, NUM [DI]
MOV DX, DI
LOOP1: INC DI
CMP AL, NUM [DI]
JNB NEXT
MOV AL, NUM [DI]
MOV DX, DI

50

NEXT:

LOOP LOOP1
XCHG AL, NUM [DI]
MOV SI, DX
MOV NUM [SI], AL
DEC BX
JNZ LOOP2
MOV AH, 4CH
INT 21H
END START

DESCENDING ORDER:
ii)
By using MASM:
.MODEL SMALL
.STACK 100
.DATA
NUM DB 12H, 45H, 79H, 66H
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV BX, 3
LOOP2: MOV CX, BX
MOV DI, 0
MOV AL, NUM [DI]
MOV DX, DI
LOOP1: INC DI
CMP AL, NUM [DI]
JB NEXT
MOV AL, NUM [DI]
MOV DX, DI
NEXT: LOOP LOOP1
XCHG AL, NUM [DI]
MOV SI, DX
MOV NUM [SI], AL
DEC BX
JNZ LOOP2
MOV AH, 4CH
INT 21H
END START
ASCENDING ORDER:
iii)
By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
1004
1006
1008
100c
100e
1010
1011
1013

C7,C6,00,20
8A,0C
FE,C9
C7,C6,00,20
8A,2C
FE,CD

MOV SI, 2000

REPEAT:

46
8A,04
46

MNEMONICS

MOV CL,[SI]
DEC CL
MOV SI,2000
MOV CH,[SI]
DEC CH
INC SI

RECMP:

MOV AL,[SI]
INC SI

51

COMMENTS
Initialize the memory pointer.
Move the content SI to CL.
Decrement the count value
Move 2000 to SI.
Move the content of to CH.
Decrement the CH by one.
Increment the memory
pointer
Move the content of SI to AL.
increment the memory

1014
3A,04

CMP AL,[SI]

72,05

JC :AHEAD

86,04

XCHG AL,[SI]

1016
1018
101a
86,44,FF
101d
101f

FE,CD

XCHG AL,[SI-1]
AHEAD:

DEC CH

75,F0
JNZ :RECMP

1021
1023

FE,C9
75,E3

DEC CL
JNZ: REPEAT

1025

F4

HLT

pointer
Compare the content of AL
and content of address hold
by SI.
If carry occur jump to the
address specify by the label
AHEAD.
Exchange the content of AL
and the content hold by the
address specify in SI.
Exchange the content of AL
and the content hold by the
address specify in
SI-1.
Decrement the CH register by
1.
In the count value not reach
to zero jumps to address
specify by RECMP.
Decrement the content of CL.
In the count value not reach
to zero jump to address
specify by REPEAT.
Stop the program

OUTPUT:
INPUT
Address
2000
2001
2002
2003
2004
2005

OUTPUT
Data
05
05
04
03
02
01

DESCENDING ORDER:
iv)
By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C7,C6,00,20
1004
8A,0C
1006
FE,C9
1008
C7,C6,00,20 REPEAT:
100C
8A,2C
100E
FE,CD
1010
46
1011
8A,04
RECMP:
1013
46
1014
3A,04
1016

73,05

Address
2001
2002
2003
2004
2005

MNEMONICS
MOV SI, 2000
MOV CL,[SI]
DEC CL
MOV SI,2000
MOV CH,[SI]
DEC CH
INC SI
MOV AL,[SI]
INC SI
CMP AL,[SI]
JNC :AHEAD

52

Data
01
02
03
04
05

COMMENTS
Initialize the memory pointer.
Move the content SI to CL.
Decrement the count value
Move 2000 to SI.
Move the content of to CH.
Decrement the CH by one.
Increment the memory pointer
Move the content of SI to AL.
increment the memory pointer
Compare the content of AL
and content of address hold by
SI.
If carry occur jump to the
address specify by the label

1018
86,04

XCHG AL,[SI]

101a
86,44,FF
101d
101f

FE,CD

XCHG AL,[SI-1]
AHEAD:

DEC CH

75,F0
JNZ :RECMP

1021
1023

FE,C9
75,E3

DEC CL
JNZ: REPEAT

1025

F4

HLT

AHEAD.
Exchange the content of AL
and the content hold by the
address specify in SI.
Exchange the content of AL
and the content hold by the
address specify in
SI-1.
Decrement the CH register by
1.
In the count value not reach to
zero jumps to address specify
by RECMP.
Decrement the content of CL.
In the count value not reach to
zero jump to address specify
by REPEAT.
Stop the program

OUTPUT:
INPUT
Address
2000
2001
2002
2003
2004
2005

Data
05
05
04
03
02
01

OUTPUT
Address
2001
2002
2003
2004
2005

Data
05
04
03
02
01

RESULT:
Thus an assembly language program for sorting an array of number in ascending and
descending order was performed and its output was verified.
Ex.No:4C

SEARCHING A NUMBER

53

AIM:
To write and execute an assembly language program for searching a number using 8086 kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the count in register for number of data.
2. Initialize the array address.
3. Compare the selected two numbers and check carry.
4. If bigger, store the largest value in accumulator.
5. Otherwise interchange the contents with register.
6. Decrement the count.
7. Continue the same operation till the count becomes zero.
8. Store the result in memory locations.
PROGRAM:
LARGEST:
(i)
By using MASM:
DATA SEGMENT
X DW 0060H, 0020H, 0030H, 0040H, 0050H
MES DB 10, 13,'LARGEST NUMBER AMONG THE SERIES IS $'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV CX, 05H
LEA SI, X
MOV AX, [SI]
DEC CX
UP: CMP AX, [SI+2]
JNB CONTINUE
MOV AX, [SI+2]
CONTINUE: ADD SI, 2
DEC CX
JNZ UP
AAM
ADD AX, 3030H
MOV BX, AX
MOV AH, 09H
LEA DX, MES
INT 21H
MOV DL, BH
MOV AH, 02H
INT 21H
MOV DL, BL
INT 21H
MOV AH, 4CH
INT 21H

54

CODE ENDS
END START
(ii)
By using 8086 kit:
ADDRESS
OPCODE
LABEL

MNEMONICS

1000

C7,C6,00,20

MOV SI,2000H

1004

C7,C7,00,21

MOV DI,2100H

1008

8A,0C

MOV CL,[SI]

100A
100B
100D
100F

46
8A,04
FE,C9
46

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

1010
1012

8A,1C
3A,C3

MOV BL,[SI]
CMP AL,BL

1014

73,02

JNB AHEAD

1016

8A,C3

MOV AL,BL

1018
101A

FE,C9
75,F3

AHEAD: DEC CL
JNZ AGAIN

101C

88,05

MOV [DI],AL

101E

F4

HLT

AGAIN:

COMMENTS
Set SI-register as pointer for
array.
Set DI-register as pointer for
array.
Set CL-register as count for
elements in the array.
Increment the SI-register
Set first data as largest
Decrement the count
Increment the SI-register to
point to next data in array
Get the next data in BL-reg.
Compare the current largest data
in AL with BL.
If carry is not set then AL is
greater than BL, hence proceed
to AHEAD
If carry is set then make BL as
current largest
Decrement the count
If count is not zero repeat
search.
Store the largest data in
memory.
Stop the program.

OUTPUT:
INPUT
Address
2000
2001
2002
2003
2004
2005

OUTPUT
Data
05 (COUNT)
15
19
02
01
06

Address
2100

SMALLEST:
iii)

By using MASM:
DATA SEGMENT
X DW 0060H, 0020H, 0030H, 0040H, 0050H
MES DB 10, 13,'SMALLEST NUMBER AMONG THE SERIES IS $'
DATA ENDS
CODE SEGMENT

55

Data
19

ASSUME CS: CODE, DS: DATA


START: MOV AX, DATA
MOV DS, AX
MOV CX, 05H
LEA SI, X
MOV AX, [SI]
DEC CX
UP: CMP AX, [SI+2]
JB CONTINUE
MOV AX, [SI+2]
CONTINUE: ADD SI, 2
DEC CX
JNZ UP
AAM
ADD AX, 3030H
MOV BX, AX
MOV AH, 09H
LEA DX, MES
INT 21H
MOV DL, BH
MOV AH, 02H
INT 21H
MOV DL, BL
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
iv)
By using 8086:
ADDRESS
OPCODE

LABEL

MNEMONICS

1000

C7,C6,00,20

MOV SI,2000H

1004

C7,C7,00,21

MOV DI,2100H

1008

8A,0C

MOV CL,[SI]

100A
100B
100D
100F

46
8A,04
FE,C9
46

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

1010
1012

8A,1C
3A,C3

MOV BL,[SI]
CMP AL,BL

1014

72,02

JB AHEAD

1016

8A,C3

MOV AL,BL

1018
101A

FE,C9
75,F3

AHEAD: DEC CL
JNZ AGAIN

AGAIN:

56

COMMENTS
Set SI-register as pointer for
array.
Set DI-register as pointer for
array.
Set CL-register as count for
elements in the array.
Increment the SI-register
Set first data as largest
Decrement the count
Increment the SI-register to
point to next data in array
Get the next data in BL-reg.
Compare the current largest data
in AL with BL.
If carry is not set then AL is
greater than BL, hence proceed
to AHEAD
If carry is set then make BL as
current largest
Decrement the count
If count is not zero repeat
search.

101C

88,05

MOV [DI],AL

101E

F4

HLT

Store the largest data in


memory.
Stop the program.

OUTPUT:
INPUT
Address
2000
2001
2002
2003
2004
2005

OUTPUT
Data
05 (COUNT)
15
19
02
01
06

Address
2100

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What are Data Copy/Transfer Instructions?


What are Machine Control Instructions?
What are Flag Manipulation Instructions?
What are String Instructions?
Explain the difference between a JMP and CALL instruction?
What is meant by Polling?
Define Pipelining?
Explain about "LEA"?
Define Pipelining?
What is a bus?

57

Data
01

RESULT:
Thus an assembly language program for searching a smallest and largest was
performed and its output was verified.

58

Ex.No:5A

PASSWORD CHECKING

AIM:
To write and execute an assembly language program for password checking using 8086 kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i)
By using MASM
.MODEL SMALL
.DATA
NAM DB KRISHNA$
PASS DB 50
DB?
DB 10 DUP (?)
MSG1 DB 10, 13,"ENTER THE PASSWORD: $", 10, 13
MSG2 DB 10, 13,"PASSWORD VALID: CONGRATS!!!! $", 10, 13
MSG3 DB 10, 13,"PASSWORD INVALID, SORRY TRY AGAIN ## $", 10, 13
PRINT MACRO MSG; MACRO DEFINITION TO PRINT A STRING ON SCREEN
LEA DX, MSG
MOV AH, 09
INT 21H
ENDM
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV ES, AX
XOR AX, AX
PRINT MSG1
LEA DX, PASS
MOV AH, 0AH; READ PASSWORD FROM KEYBOARD
INT 21H
MOV DI, DX
INC DI
MOV CL, BYTE PTR [DI]; LENGTH OF THE STRING IN CL REGISTER
MOV CH, 00
INC DI
LEA SI, NAM
CLD
BACK: CMPSB
JNE XX
LOOP BACK
PRINT MSG2
JMP XXY
XX: PRINT MSG3
XXY: MOV AH, 4CH
INT 21H
END START

59

(ii) By using 8086 kit:


ADDRESS
OPCODE

LABEL

0000

E8,00,79

AGAIN:

0003
0006
0008

E8,00,6F
8C, C8
8E, D8

CALL POS
MOV AX,CS
MOV DS,AX

000A

B4, 09

MOV AH,09H

000C

BA, 04,50

MOV DX,450H

000F
0011
0014

CD, 21
BE, 04,00
B9, 00,00

INT 21H
MOV SI,400H
MOV CX,0000H

0017
0019

B4, 00
CD, 16

001B

3C,0D

CMP AL,CR

001D
001F

74,0C
88,04

JE CHECK
MOV [SI],AL

0021
0023

B4,02
B2, 2A

MOV AH,02H
MOV DL, *

0025
0027
0028
0029
002B
002E

CD,21
46
41
EB,EC
83,F9,07
75,20

INT 21H
INC SI
INC CX
JMP L1
CMP CX,0007H
JNE REPEAT

0030
0033
0036

BE,04,00
BF,05,00
8A,04

0038

3A,05

CMP AL,[DI]

003A
003C
003D
003E

75,14
46
47
E2,F6

JNE REPEAT
INC SI
INC DI
LOOP L2

0040
0043
0046

E8,00,79
E8,00,6F
B4,09

CALL CLRS
CALL POS
MOV AX,09H

L1:

CHECK:

L2:

MNEMONICS
CALL CLRS

MOV AH,00H
INT 16H

MOV SI, 400H


MOV DI,500H
MOV AL, [SI]

60

COMMENTS
Assign ASCII value for carriage
return
Position The Cursor
Initialize DS To Code Segment
Copy The Content Of AX To
DS-Register
Load The Function Code IN
AH-register
Load address of string to display
in DX-register
Call DOS service for display
Initialize the pointer
Initialize count in CX-register as
zero.
Load the function code in AH.
Call BIOS to get keyboard
character in AL.
Compare the key code with
carriage return
If equal go to CHECK
Store the keyboard character in
memory
Load the function code in AH.
Load the ASCII value of * in
DL
Call DOS service for display
Increment Pointer
Increment the count
Jump to L1 to get next character
Compare count with 07H
If count not equal to 07H then
goto repeat
Initialize the pointers
Copy the value 500H to DI-reg
Get a character of entered
password in AL-register
Compare entered character with
corresponding character of
stored password
If not equal jump to repeat
Increment the pointer
Increment the DI-register
Repeat comparison until counter
expires
Clear the screen
Position the cursor
Load the function code in AHregister

004A

BA,06,00

MOV DX,600H

004B
004D
0050
0053
0056
0058

CD,21
E9,06,0F
E8,00,79
E8,00,6F
B4,09
BA,05,50

INT 21H
JMP EXIT
CALL CLRS
CALL POS
MOV AH,09H
MOV DX,550H

005B
005D
005F

CD,21
B4,09
BA,05,80

INT 21H
MOV AH,09H
MOV DX,580H

0062
0064
0066

CD,21
B4,00
CD,16

INT 21H
MOV AH,00H
INT 16H

0068
006A

3C,1B
75,94

CMP AL,1BH
JNE AGAIN

006C

E9,06,0F

JMP EXIT

006F
0071
0073

B4,02
B7,00
BA,00,00

MOV AH,02H
MOV BH,00H
MOV DX,0000H

0076

CD ,10

INT 10H

0078
0079

C3

RET
POS ENDP

0079

REPEAT

CLRS PROC NEAR

0079
007B

B4,07
B0,00

MOV AH,07H
MOV AL,00H

007D

B7 07

MOV BH,07H

007F

B9 0000

MOV CX, 0000H

0082

BA 184F

MOV DX,184FH

0085

CD 10

INT 10H

0087
0088

C3

RET
CLRS ENDP

0450
0450

45 4E 54 45
52 20 54 48
45 20 50 41
53 53 57 4F

ORG 450H
DB
ENTER
THE
PASSWORD : ,$

61

Load the address of String to


display in DX-register
Call DOS service for display
GO to EXIT.
Clear the screen
Position the cursor
Load the function code in AH
Load the address of string to
display in DX-register
Call DOS service for display
Load the function code in AH
Load address of string to display
in DX
Call DOS service for display
Load the function code in AH
Call Bios service to get
keyboard
Check for Esc key
If key pressed is not esc, then go
to again
If key pressed is not esc, then go
to exit
Load the function code in AH
Load the video page in BH
Load the X and Y coordinate in
DL and DH.
Call Bios service for cursor
positioning
Return to main program
End of procedure to position the
cursor
Start of procedure to clear the
screen.
Load the function code in AH
Load number of lines to scroll
down in AL
Load the blanked area attribute
in BL
Load the X and Y coordinates of
upper left corner in CL and CH
Load the X and Y coordinates
of lower right corner in DL and
DH
Call BIOS video service for
clearing screen.
Return to main program
End of procedure to clear the
screen.

52 44 20 3A
20 24
0500
0500
0500
0550

0580
0580

0600
0600

060F
0611
0613

ORG 500H
DB WELCOME,$

57 45 4C 43
4F 4D 45
24

ORG 550H
DB
INCORRECT
PASSWORD. ,$.

49 4E 43 4F
52 52 45 43
54 20 50 41
53 53 57 4F
52 44 2E 20
20 24

ORG 580H
DB PRESS ANY KEY
TO TRY AGAIN OR
PRESS ESC TO EXIT
,$

50 52 45 53
53 20 41 4E
59 20 4B 45
59 20 54 4F
20 54 52 59
20 41 41 41
49 4E 20 4F
52 20 50 52
45 53 53 20
45 53 43 20
54 4F 20 45
58 49 54 20
24
45 4E 54 52
59 20 41 43
43 45 50 54
45 44 24
B4 4C
CD 21

ORG 600H
DB
ENTRY
ACCEPTED ,$.
EXIT

MOV AH,4CH
INT 21H
CODE ENDS
END

OUTPUT:
ENTER THE PASSWORD: WELCOME
INCORRECT PASSWORD
PRESS ANY KEY TO TRY AGAIN OR PRESS ESC TO EXIT
ENTRY ACCEPTED

62

Load the function in AH


Call DOS service to return to
command prompt.
Ends of code segment
Assembly end

RESULT:
Thus an assembly language program for password checking using 8086 was implemented
and its output was verified.
Ex.No:5B
PRINT RAM SIZE
AIM:
To write and execute an assembly language program to print the size of the file in RAM using
8086kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i)
By using MASM
PROMPT MACRO MESSAGE
PUSH AX
MOV AH, 09H
LEA DX, MESSAGE
INT 21H
POP AX
ENDM
DATA SEGMENT
MES DB 10, 13, 'THE SIZE OF CONVENTIONAL RAM MEMORY IS: $'
MES1 DB
'KBYTES$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE
LEA DX, MES
INT 12H
CALL D_BCD
LEA DX, MES1
MOV AH, 4CH
INT 21H
D_BCD PROC NEAR
MOV CX, 00H
MOV BX, 10H
BACK1: MOV DX, 00H
DIV BX
PUSH DX
INC CX
OR AX, AX
JNZ BACK1
MOV AH, 02H
DISP:
POP DX
ADD DL, 30H
INT 21H
LOOP DISP

63

RET
ENDP
CODE ENDS
END
RESULT:
Thus an assembly language program to print the size of the file in RAM using 8086 was
implemented and its output was verified.

64

Ex.No:5C

SYSTEM DATE

AIM:
To write and execute an assembly language program for reading system date using 8086kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i)
By using MASM
.MODEL SMALL
.DATA
.CODE
START: MOV AX,@DATA
MOV DS, AX
; Day Part
DAY: MOV AH, 2AH ; To get System Date
INT 21H
MOV AL, DL ; Day is in DL
AAM
MOV BX, AX
CALL DISP
MOV DL,'/'
MOV AH, 02H ; To Print / in DOS
INT 21H
MONTH:

YEAR:

; Month Part
MOV AH, 2AH ; To get System Date
INT 21H
MOV AL, DH ; Month is in DH
AAM
MOV BX, AX
CALL DISP
MOV DL,'/' ; To Print / in DOS
MOV AH, 02H
INT 21H
; Year Part
MOV AH, 2AH ; To get System Date
INT 21H
ADD CX, 0F830H; To negate the effects of 16bit value,
MOV AX, CX ; since AAM is applicable only for AL (YYYY -> YY)
AAM
MOV BX, AX
CALL DISP
; To terminate the Program
MOV AH, 4CH ; To Terminate the Program

65

INT 21H
; Display Part
DISP PROC
MOV DL, BH
; since the values are in BX, BH Part
ADD DL, 30H ; ASCII Adjustment
MOV AH, 02H ; To Print in DOS
INT 21H
MOV DL, BL ; BL Part
ADD DL, 30H ; ASCII Adjustment
MOV AH, 02H ; To Print in DOS
INT 21H
RET
DISP ENDP ; End Disp Procedure
END START ; End of MAIN
PROGRAM:
ADDRESS OPCODE
1000
1003
1006
1009
100B
100E
1011
1013
1016
1018
1019
101A
101B
101C
101E

LABEL
DELAY:
S2:

S1:

MNEMONICS
CALL CONVERT
CALL DISPLAY
MOV AL,0B0H
OUT 16H,AL
MOV CL,07H
MOV AL,88H
OUT 14H,AL
MOV AL,80H
OUT 14H,AL
NOP
NOP
NOP
NOP
IN AL,14H
MOV DL,AL

1020
1022
1024
1026
1028
102A
102E
1030
1032

IN AL,14H
OR AL,DL
JNZ S1
DEC CL
JNZ S2
MOV SI,1500H
MOV AL,[SI]
INC AL
MOV [SI],AL

1034
1037
1039
103C
103E
103F
1041
1043

CMP AL,3CH
JNZ START
MOV AL,00H
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL

66

COMMENTS
Call subroutine for conversion
Call subroutine for Display
Copy the data 0B0H to AL-reg
Configure output port
Copy the data 07H to AL-reg
Copy 88H to AL-register
Configure output port
Copy the data 80H to AL-reg
Configure output port
No operation
No operation
No operation
No operation
Copy 14H to AL-reg
Copy the Content of AL reg to
DL-reg.
Copy 14H to AL-reg
OR the contents of AL with DL
Jump on no zero to S1
Decrement CL-register
Jump on no zero to S2
Copy SI-reg with data 1500H
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg
Compare AL with 3CH
Jump on no zero to start
Copy AL with data 00H
Copy the content of Al to SI-reg
Increment SI-register
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg

1045
1048
104A
104D

CMP AL,3CH
JNZ START
MOV AL,0
MOV [SI],AL

104F
1050
1052
1054

INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL

1056
1059
105B
105E

CMP AL,18H
JNZ START
MOV AL,0
MOV [SI],AL

1060
1063
1066
106A
106D
1070
1072
1073
1077
107B
107E
1080
1082
1085
1088
108A
108D
108E

DISPLAY:

CONVERT:

JMP START
MOV AH,06H
MOV DX,1600H
MOV CH,01H
MOV CL,0H
INT 5
RET
MOV SI,1500H
MOV BX,1608H
MOV AL,24H
MOV [BX],AL
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
DEC BX
MOV [BX],AH

1090
1091
1094
1096
1097
109A
109C
109D
109E
10A0
10A3
10A6
10A8
10AB

DEC BX
ADD AL,30H
MOV [BX],AL
DEC BX
MOV AL,3AH
MOV [BX],AL
DEC BX
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AH

10AD
10AE
10B1

DEC BX
ADD AL,30H
MOV [BX],AL

67

Compare AL with 3CH


Jump on no zero to start
Copy AL with data 00H
Copy the content of AL reg to SIreg
Increment SI-register
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg
Compare AL with 18H
Jump on no zero to start
Copy AL with data 00H
Copy the content of AL reg to SIreg
Jump to start
Copy 06H to AH-register
Copy 1600H to DX-register
Copy 01H to CH-register
Copy 00H to CL-register
Call Interrupt
Return from subroutine
Copy 1500H to SI-register
Copy 1608H to BX-register
Copy 24H to AL-register
Copy the content of AL-reg to BX
Copy the content of SI-reg to AL
Copy AL with data 00H
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Decrement BX-register
Copy the data from AH to DHreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Copy the 3AH to AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Increment SI-register
Copy the content of SI-reg to AL
Copy the data 0 to AH-reg
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Copy the data from AH to BXreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg

10B3
10B4
10B7
10B9
10BA
10BB
10BD
10C0
10C3
10C5
10C8

DEC BX
MOV AL,3AH
MOV [BX],AL
DEC BX
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AH

10CA
10CB
10CE
10D0
10D1
10D3
10D6
10D9

DEC BX
ADD AL,30H
MOV [BX],AL
RET
IN AL,02H
AND AL,0FFH
CMP AL,0F0H
JNE GETC

GETC:

Decrement BX-register
Copy the 3AH to AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Increment SI-register
Copy the content of SI-reg to AL
Copy the data 0 to AH-reg
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Copy the data from AH to BXreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg
Return from subroutine
Copy 02H to AL-reg
AND data AL with 0FFH
Compare AL with 0F0H
If no zero jump to getc

OUTPUT:
1500- 99 YEAR
1501- 09 MONTH
1502- 09 DATE
VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Why data bus is bi-directional?


Why address bus is unidirectional?
Define machine cycle.
What is DMA?
What is a port?
What are nibble, byte and word?
What is PSW? Give its structure and explain
What does EU and BIU do?
Describe about LOOP instructions
Explain about DAA instruction.

RESULT:
Thus an assembly language program for reading system date using 8086 was implemented
and its output was verified.
Ex.No:6

COUNTERS AND TIME DELAY

AIM:
To write and execute an assembly language program for creating time delay using counters in
8086kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1

68

2. Power card ----1


3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i)
By using MASM
.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
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

69

NXT2:

(iii)

LOOP LP
MOV AH, 4CH
INT 21H
END
By using 8086 kit:

Square wave Generation:


ADDRESS
1000
1000
1003

OPCODE

LABEL

C6,C0,36
E6,CE

MNEMONICS
ORG 1000H
MOV AL,36
OUT CE,AL

1005
1008

C6,C0,10
E6,C8

MOV AL,10
OUT C8,AL

100A
100D

C6,C0,00
E6,C8

MOV AL,00
OUT C8,AL

100F

F4

HLT

COMMENTS
Starting address
Move 36 to AL-register
The content of AL-reg is
copied to Port.
Move 10 to AL-register
The content of AL-reg is
copied to Port.
Move 00 to AL-register
The content of AL-reg is
copied to Port.
Stop the program.

OUTPUT:
WAVEFORM GENERATION
WAVEFORMS
Square wave

AMPLITUDE
10v

TIME PERIOD
1ms

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What are the advantages of modular programming?


What is the BHE signal? Explain its significance?
What does MASM stand for and what is its use?
Which interrupt in the 8086 has the highest priority?
Where 8086 is mainly used and tell its applications?
Abbreviation of ASCII.
Define Signed and Unsigned number?
What do you mean by assembler directives?
What is the Maximum clock frequency in 8086?
What is meant by cross-compiler?

RESULT:
Thus an assembly language program for creating time delay using counters in 8086 was
implemented and its output was verified.

70

INTERFACING EXPERIMENTS

71

Ex. No: 7

TRAFFIC LIGHT CONTROL

AIM:
To write and execute an assembly language Program for interfacing the Traffic Light
Controller in 8086 kit.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Traffic Light Controller Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS
OPCODE
1000
B0,80
1002
E6,26

LABEL
START:

MNEMONICS
MOV AL,80H
OUT CONTROL,AL

1004

BB 6B 10

REPEAT:

MOV BX, LOOKUP

1007

BE 77 10

MOV SI, LABEL

100A
100D

E8 32 00
8A 04

CALL OUT
MOV AL, [SI]

100F

E6 20

OUT PORTA, AL

1011
1014
1015
1016
1019

E8 4A 00
46
43
E8 26 00
8A 04

CALL DELAY1
INC SI
INC BX
CALL OUT
MOV AL, [SI]

101B

E6 22

OUT PORTB, AL

101D
1020
1021
1022
1025

E8 3E 00
46
43
E8 1A 00
8A 04

CALL DELAY1
INC SI
INC BX
CALL OUT
MOV AL, [SI]

1027

E6 24

OUT PORTC, AL

1029
102C
102D
102E
1031

E8 32 00
46
43
E8 0E 00
8A 04

CALL DELAY1
INC SI
INC BX
CALL OUT
MOV AL, [SI]

1033

E6 24

OUT PORTC, AL

1035

46

INC SI

72

COMMENTS
Move 80 to AL-register
Copy the AL-reg content to
output port.
Copy the lookup data value
to BX-register
Copy the direction of rotation
value to SI-reg.
Call to OUT port
Copy the contents of SI-reg
to Al-register
Move the AL-reg value to
PORTA
Call Delay program
Increment SI-register
Increment BX-register
Call to OUT port
Copy the contents of SI-reg
to Al-register
Move the AL-reg value to
PORTB
Call Delay program
Increment SI-register
Increment BX-register
Call to OUT port
Copy the contents of SI-reg
to Al-register
Move the AL-reg value to
PORTC
Call Delay program
Increment SI-register
Increment BX-register
Call to OUT port
Copy the contents of SI-reg
to Al-register
Move the AL-reg value to
PORTC
Increment SI-register

1036

8A 04

MOV AL, [SI]

1038

E6 20

OUT PORTC, AL

103A
103D
103F

E8 21 00
EB C5
8A 07

CALL DELAY1
JMP REPEAT
MOV AL, [BX]

1041

E6 24

OUT PORTC, AL

1043
1044

43
8A 07

INC BX
MOV AL, [BX]

1046

E6 22

OUT PORTB, AL

1048
1049

43
8A 07

INC BX
MOV AL, [BX]

104B

E6 20

OUT PORTA, AL

OUT:

Copy the contents of SI-reg


to Al-register
Move the AL-reg value to
PORTC
Call Delay program
Jump to label REPEAT
Copy the content of BX to
AL-register
Move the AL-reg value to
PORTC
Increment BX-register
Copy the content of BX to
AL-register
Move the AL-reg value to
PORTB
Increment BX-register
Copy the content of BX to
AL-register
Move the AL-reg value to
PORTA
Call Delay program
Return from subroutine
Move 40h to DI-register
Move 0FFFFh to DX-register
Decrement DX-register
Jump on no zero to A1.
Decrement D1-register
Jump on no zero to A

104D
E8 01 00
CALL DELAY
1050
C3
RET
1051
BF 40 00
DELAY:
MOV DI, 00040H
1054
BA FF FF
A:
MOV DX, 0FFFFH
1057
4A
A1:
DEC DX
1058
75 FD
JNZ A1
105A
4F
DEC D1
105B
75 F6
JNZ A
105D
C3
RET
105E
BF 15 00
DELAY1:
MOV DI, 00015H
Move 15h to DI-register
1061
BA FF FF
B:
MOV DX, 0FFFH
Move 0FFFh to DX-register
1064
4A
B1:
DEC DX
Decrement DX-register
1065
75 FD
JNZ B1
Jump on no zero to B1
1067
4F
DEC D1
Decrement D1-register
1068
75 F6
JNZ B
Jump on no zero to B
106A
C3
RET
106B
12 27 44 10 LOOKUP: DB 12H,27H,44H,10H
106F
2B 92 109D
2BH,92H,10H,9DH
1073
84 48 2E 84
84H,48H,2EH,84H
1077
48 4B 20 49 LABEL:
DB 48H,4BH,20H,49H
For traffic light control.
107B
04
04H
107C
END
VIVA QUESTIONS:
1. Which Segment is used to store interrupt and subroutine return address registers?
2. What is the difference between instructions RET & IRET?
3. What .model small means?
4. Difference between small, medium, tiny, huge?
5. What is dd, dw, db?
6. What is the function of 01h of Int 21h?
7. What is the function of 02h of Int 21h?
8. What is the function of 09h of Int 21h?
9. What is the function of 0Ah of Int 21h?

73

10. What is the function of 4ch of Int 21h?


RESULT:
Thus the assembly language program for interfacing the traffic light controller was
implemented in 8086 kit.

74

Ex.No:8

STEPPER MOTOR INTERFACING

AIM:
To write and execute an assembly language Program to run a stepper motor at different
speed, and to control its speed of direction.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Stepper Motor ----1
3. Stepper Motor Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS

OPCODE

LABEL

1000

MNEMONICS

COMMENTS

Org 1000H

Starting address of the program

1000

C7,C7,18,10 Ahead

MOV DI, 1018

Copy the data 1018 to DI-reg

1004

C6, C1,04

MOV CL, 04

Copy the value 04 to CLregister

1007

8A, 05

MOV AL, [DI]

1009

E6 , C0

OUT C0, AL

100B
100F
1010
1012
1013
1015
1018

C7,C2,10,10
4A
loop
75,FD
47
E2,F2
E9,E8, FF
09,05,06,0A TABLE

MOV DX, 1010


DEC DX
JNZ loop
INC DI
LOOP loop1
JMP Ahead
09 05 06 0A
HLT

Copy the content of DI-reg to


AL-register
The content of AL is moved to
Out port
Copy the data 1010 to DX-reg
Decrement DX-register
Jump on no zero to loop
Increment DI-register
Loop to label loop1
Jump to ahead

Loop1

Stop the program.

DIRECTION CONTROL OF STEPPER MOTOR


PROGRAM:
ADDRESS

OPCODE

LABEL

MNEMONICS

COMMENTS

1000

C6,C3, 20

MOV BL, 20

Copy the data 20h to BLregister.

1003

C7,C7,3F,10

MOV DI, 103F

Copy the data 103F to DI-reg

1007
100A
100C
100E
1011
1014

E8
FE
75
E8
C6
C7

CALL 1025
DEC BL
JNZ 1003
CALL 103B
MOV BL, 20
MOV DI, 1043

Call subroutine program


Decrement BL-register
Jump on no zero to label 1003
Call subroutine program
Copy the data 20 to BL-register
Copy the data 1043 to DI-reg

1B
CB
F5
2A
C3
C7

00
00
20
43

75

1018
101B
101D
101F
1022
1025
1028

10
E8
FE
75
E8
E9
C6
8A

102A

E6 C0

OUT C0, AL

102C

C7 C2 10
10
4A
75 FD
47
E2 F2
C3
C7,C2,FF,FF
4A
75 FD
C3
09,05,06,0A
0A,06,05, 09

MOV DX, 1010

1030
1031
1033
1034
1036
1037
103B
103C
103E
103F
1043

0A
CB
75
19
DB
C1
05

1047

00
00
FF
04

CALL 1025
DEC BL
JNZ 1014
CALL 103B
JMP 1000
MOV CL, 04
MOV AL, [DI]

DEC DX
JNZ 1030
INC DI
LOOP 1028
RET
MOV DX, 0FFFF
DEC DX
JNZ 103B
RET
FORWARD DATA
REVERSE DATA

Call subroutine program


Decrement BL-register
Jump on no zero to 1014
Call subroutine program
Jump to label 1000
Copy the data 04 to CL-register
Copy the content of DI to ALregister
Assign the content of AL to
Output
Copy the content 1010 to Dxregister
Decrement DX-register
Jump on no zero to label 1030
Increment DI-register
Loop to label 1028
Return from subroutine
Copy FFFF in DX-register
Decrement DX-register
Jump on no zero 103B
Return from subroutine
To rotate in forward direction
To rotate in Reverse direction

HLT

Stop the program.

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What MASM is?


What do u mean by emulator?
What is SI, DI and their functions?
What do you mean by IVT in 8086?
Why we indicate FF as 0FF in program?
.stack 100 means?
What do you mean by 20 dup (0)?
What is 8087? How it is different from 8086?
What do you mean by debugger?
When divide overflow error occurs?

RESULT:
Thus an assembly language Program to run the stepper motor in both forward and reverse
direction with delay was executed and its output was verified.

76

Ex. No: 9

DIGITAL CLOCK

AIM:
To write and execute an assembly language Program for digital clock in 8086 kit.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Traffic Light Controller Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS OPCODE
1000
1003
1006
1009
100B
100E
1011
1013
1016
1018
1019
101A
101B
101C
101E

LABEL
DELAY:
S2:

S1:

MNEMONICS
CALL CONVERT
CALL DISPLAY
MOV AL,0B0H
OUT 16H,AL
MOV CL,07H
MOV AL,88H
OUT 14H,AL
MOV AL,80H
OUT 14H,AL
NOP
NOP
NOP
NOP
IN AL,14H
MOV DL,AL

1020
1022
1024
1026
1028
102A
102E
1030
1032

IN AL,14H
OR AL,DL
JNZ S1
DEC CL
JNZ S2
MOV SI,1500H
MOV AL,[SI]
INC AL
MOV [SI],AL

1034
1037
1039
103C
103E
103F
1041
1043

CMP AL,3CH
JNZ START
MOV AL,00H
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL

1045
1048

CMP AL,3CH
JNZ START

77

COMMENTS
Call subroutine for conversion
Call subroutine for Display
Copy the data 0B0H to AL-reg
Configure output port
Copy the data 07H to AL-reg
Copy 88H to AL-register
Configure output port
Copy the data 80H to AL-reg
Configure output port
No operation
No operation
No operation
No operation
Copy 14H to AL-reg
Copy the Content of AL reg to
DL-reg.
Copy 14H to AL-reg
OR the contents of AL with DL
Jump on no zero to S1
Decrement CL-register
Jump on no zero to S2
Copy SI-reg with data 1500H
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg
Compare AL with 3CH
Jump on no zero to start
Copy AL with data 00H
Copy the content of Al to SI-reg
Increment SI-register
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg
Compare AL with 3CH
Jump on no zero to start

104A
104D

MOV AL,0
MOV [SI],AL

104F
1050
1052
1054

INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL

1056
1059
105B
105E

CMP AL,18H
JNZ START
MOV AL,0
MOV [SI],AL

1060
1063
1066
106A
106D
1070
1072
1073
1077
107B
107E
1080
1082
1085
1088
108A
108D
108E

DISPLAY:

CONVERT:

JMP START
MOV AH,06H
MOV DX,1600H
MOV CH,01H
MOV CL,0H
INT 5
RET
MOV SI,1500H
MOV BX,1608H
MOV AL,24H
MOV [BX],AL
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
DEC BX
MOV [BX],AH

1090
1091
1094
1096
1097
109A
109C
109D
109E
10A0
10A3
10A6
10A8
10AB

DEC BX
ADD AL,30H
MOV [BX],AL
DEC BX
MOV AL,3AH
MOV [BX],AL
DEC BX
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AH

10AD
10AE
10B1
10B3
10B4

DEC BX
ADD AL,30H
MOV [BX],AL
DEC BX
MOV AL,3AH

78

Copy AL with data 00H


Copy the content of AL reg to SIreg
Increment SI-register
Copy the content of SI-reg to AL
Increment AL-register
Copy the content of AL reg to SIreg
Compare AL with 18H
Jump on no zero to start
Copy AL with data 00H
Copy the content of AL reg to SIreg
Jump to start
Copy 06H to AH-register
Copy 1600H to DX-register
Copy 01H to CH-register
Copy 00H to CL-register
Call Interrupt
Return from subroutine
Copy 1500H to SI-register
Copy 1608H to BX-register
Copy 24H to AL-register
Copy the content of AL-reg to BX
Copy the content of SI-reg to AL
Copy AL with data 00H
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Decrement BX-register
Copy the data from AH to DHreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Copy the 3AH to AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Increment SI-register
Copy the content of SI-reg to AL
Copy the data 0 to AH-reg
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Copy the data from AH to BXreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg
Decrement BX-register
Copy the 3AH to AL-reg

10B7
10B9
10BA
10BB
10BD
10C0
10C3
10C5
10C8

MOV [BX],AL
DEC BX
INC SI
MOV AL,[SI]
MOV AH,0
MOV DH,0AH
DIV DH
ADD AH,30H
MOV [BX],AH

10CA
10CB
10CE
10D0
10D1
10D3
10D6
10D9

DEC BX
ADD AL,30H
MOV [BX],AL
RET
IN AL,02H
AND AL,0FFH
CMP AL,0F0H
JNE GETC

GETC:

Copy the data from AL to BX-reg


Decrement BX-register
Increment SI-register
Copy the content of SI-reg to AL
Copy the data 0 to AH-reg
Copy the data 0AH to DH-register
Divide DH-reg by AH reg
Add the data 30H with AH-reg
Copy the data from AH to BXreg
Decrement BX-register
Add the data 30H with AL-reg
Copy the data from AL to BX-reg
Return from subroutine
Copy 02H to AL-reg
AND data AL with 0FFH
Compare AL with 0F0H
If no zero jump to getc

OUTPUT:
1500- 00 SECONDS
1501- 00 MINUTES
1502- 09 HOURS
VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What is ASCII code?


What is assembler?
What is linker?
What is Loader?
What is Debugger?
Difference between Assembly and high level language.
Name an IC used to display time, date?
What is I2C?
What is Machine language?
Which is faster? Machine language or high level language.

RESULT:
Thus an assembly language Program for digital clock in 8086 kit was written and executed.
Ex.No:10

KEYBOARD AND DISPLAY

AIM:

79

ADDRESS
1000
1003
1006

OPCODE
BE 00
B9 0F
B0 10

LABEL
START

PROGRAM
MOV SI,1200H
MOV CX,000FH
MOV AL,10

COMMENTS
Initialize array
Initialize array size
Store the control word for
display mode
1008
E6 C2
OUT C2,AL
Send through output port
100A
B0 CC
MOV AL,CC
Store the control word to
clear display
100C
E6 C2
OUT C2,AL
Send through output port
100E
B0 90
MOV AL,90
Store the control word to
write display
1010
E6 C2
OUT C2,AL
Send through output port
1012
8A 04
NEXT
MOV AL,[SI]
Get the first data
1014
E6 C0
OUT C0,AL
Send through output port
1016
E8 E7
CALL DELAY
Give delay
1019
46
INC SI
Go & get next data
101A
E2 F6
LOOP NEXT
Loop until all the datas have
been taken
101C
EB E2
JMP START
Go to starting location
1500
BA FF A0
DELAY
MOV DX,0A0FFH
Store 16bit count value
1503
4A
LOOP1
DEC DX
Decrement count value
1504
74 FD
JNZ LOOP1
Loop until count values
becomes zero
1506
C3
RET
Return to main program
To write and execute an assembly language Program to display the rolling message HELP
US in the display.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. 8279 Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
ALGORITHM:
Display of rolling message HELP US
1. Initialize the counter
2. Set 8279 for 8 digit character display, right entry
3. Set 8279 for clearing the display
4. Write the command to display
5. Load the character into accumulator and display it
6. Introduce the delay
7. Repeat from step 1.
PROGRAM:
LOOK-UP TABLE:
1200

98

68

7C

C8

1204

FF

1C

29

FF

80

OUTPUT:
MEMORY
LOCATION
1200H
1201H
1202H
1203H
1204H
1205H
1206H
1207H

d
1
0
0
1
1
0
0
1

7-SEGMENT LED FORMAT


c
b
a
dp e
g
0
0
1
1
0
0
1
1
0
1
0
0
1
1
1
1
1
0
1
0
0
1
0
0
1
1
1
1
1
1
0
0
0
1
1
0
0
1
0
1
0
0
1
1
1
1
1
1

HEX DATA
f
0
0
0
0
1
0
1
1

98
68
7C
C8
FF
1C
29
FF

VIVA QUESTIONS:
1. What are the types of interfacing?
2. Compare memory interfacing and IO interfacing.
3. What is the difference between memory mapped IO and IO mapped IO
interfacing?
4. What IC 8279 is?
5. What are the tasks involved in keyboard interface?
6. What is scanning in keyboard and what is scan time?
7. What is the difference between 2-key and n-key rollover?
8. What is the control registers available in 8279?
9. What is key debouncing?
10. What are the command words available in 8279?

RESULT:
Thus the rolling message HELP US is displayed using 8279 interface kit.
Ex.No:11

PRINTER INTERFACE

AIM:
To write and execute an assembly language program for printer interface with
microprocessor 8086 kit and to print a single character A.

81

APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----2
2. Centronics printer interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:
00C8
00D0
00C0
ADDRESS

OPCODE

DATA EQU 00C8H


CONTL EQU 00D0H
STUS EQU 00C0H
LABEL

MNEMONICS

1000
1000
1002

B0 05
E6 D0

Org 1000h
MOV AL,05H
OUT CONTL,AL

1004

E4 C0

IN AL,STUS

1006

24 20

AND AL,20H

1008

3C 20

CMP AL,20H

100A

75 44

JNZ ERR

COMMENTS
Starting address of the program
Load the AL-reg with value 05H
Copy the contents of AL-reg to
CONTL
Load the contents of STUS to ALregister.
Logically AND the contents of ALreg with 20H
Compare the contents of AL-reg
with 20H
Jump on no-zero to label ERR

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What are the different types of printer interfacing techniques available?


What type of interface is 8295?
What are the different types of printers available?
What is the expansion of LPT?
What is meant by serial and parallel interface?
What is g in the output of the program?
What does u mean by directives?
What does d mean by directives?
Whether 8086 is compatible with Pentium processor
Types of procedure?

RESULT:
Thus an assembly language program for printer interface to print a single character A
was performed and its output was verified.

82

Ex.No:12A

SERIAL INTERFACE

AIM:
To write and execute assembly language program to establish serial communication
between two 8086 kits.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----2
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. Initialize8253 to give an output of 150 KHz at channel 0 which will give a 9600 baud rate
of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent operations
4. The status word is read from the 8251 on completion of a serial I/O operation, or when the
host CPU is checking the status of the device before starting the next I/O operation
PROGRAM:
TRANSMITTER END:

ADDRESS

OPCODE

1000

C7,C6,00,
15

LABEL

MNEMONICS
MOV SI,1500H

83

COMMENTS
Initialize Si-register with address 1500H

1004
1007
1009
100C
100E
1011
1013
1016
1018
101B
101D
101F
1021
1022
1025
1027
1029
102B

C6,C0,36
E6,16
C6,C0,40
E6,10
C6,C0,01
E6,10
C6,C1,05
E4,0A
80,E0,04
74,F9
E4,08
88,04
46
80,F8,3F
75,EC
FE,C9
75,EB
CD,02

RELOAD:
CHECK:

MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
MOV CL,05H
IN AL,0AH
AND AL,04H
JZ CHECK
MOV AL,[SI]
OUT 08H,AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK
INT 02

Copy 36H data to AL-register


Configure output port
Copy the data 40H to AL-register
Configure output port
Copy 01H data to AL-register
Configure output port
Count value for number of datas
Configure input port to transmit data
AND the contents of AL-reg with 04H
If zero Jump to Label Check
Copy the content of SI-reg to AL-register
Configure output port
Increment SI-register
Compare AL-reg with 3FH data
If no zero jump to label reload
Decrement CL-register
If CL not zero jump to label Check
Call interrupt routine

RECEIVER END:

ADDRESS

OPCODE

1000

C7,C6,00,1
5
C6,C0,36
E6,16
C6,C0,40
E6,10
C6,C0,01
E6,10
C6,C1,05
E4,0A
80,E0,02
74,F9
E4,08
88,04
46
80,F8,3F
75,EC
FE,C9
75,EB

1004
1007
1009
100C
100E
1011
1013
1016
1018
101B
101D
101F
1021
1022
1025
1027
1029

LABEL

RELOAD:
CHECK:

MNEMONICS

COMMENTS

MOV SI,1500H

Initialize Si-register with address 1500H

MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
MOV CL,05H
IN AL,0AH
AND AL,02H
JZ CHECK
MOV AL,[SI]
OUT 08H,AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK

Copy 36H data to AL-register


Configure output port
Copy the data 40H to AL-register
Configure output port
Copy 01H data to AL-register
Configure output port
Count value for number of datas
Configure input port to transmit data
AND the contents of AL-reg with 02H
If zero Jump to Label Check
Copy the content of SI-reg to AL-register
Configure output port
Increment SI-register
Compare AL-reg with 3FH data
If no zero jump to label reload
Decrement CL-register
If CL not zero jump to label Check

84

102B

CD,02

INT 02

Call interrupt routine

OUTPUT:
INPUT(Transmitter end)
Address
Data
1500
11
1501
22
1502
33
1503
44
1504
3F

OUTPUT (Receiver end)


Address
Data
1500
11
1501
22
1502
33
1503
44
1504
3F

RESULT:
Thus an assembly language program to establish a serial communication between two 8086
kits was implemented and its output was verified.
EXP. NO: 12B

PARALLEL INTERFACE

AIM:
To write and execute assembly language program to establish parallel communication
between two 8086 kits.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1.
Initialize accumulator to hold control word
2.
store control word in control word register
3.
Read data port A.
4.
Store data from port A in memory
5.
Place contents in port B
PROGRAM:
TRANSMITTER:
ADDRESS
OPCODE
1000
C6, C0,82
1003
E6,26

LABEL

PROGRAM
MOV AL,82H
OUT 26H,AL

85

COMMENTS
Copy 82H to AL-register
Configure output port

1005
1008
100a
100c
100f
1011
1014
1016
1019
101b
101e
1021
1023
1025
1027
1029

C6,C0,3F
E6,20
E4,22
80,E8,3f
75,F9
C6,C0,24
E6,20
E8,02,00
CD,02
C6,C3,05
C6,C2,FF
FE,CA
75,F9
FE,CB
75,F5
C3

Loop:

Delay:
Lion:
L2:

MOV AL,3FH
OUT 20H,AL
IN AL,22H
SUB AL,3FH
JNZ LOOP
MOV AL,24H
OUT 20H,AL
CALL DELAY
INT 02
MOV BL,05H
MOV DL,0FFH
DEC DL
JNZ L2
DEC BL
JNZ LION
RET

Copy 3F to AL-register
Configure output port
Configure AL-register
Subtract 3F from AL-register
Jump on no zero to loop
Copy 24H to AL-register
Configure output port
Call delay program
Call interrupt routine
Copy 05H to BL-register
Copy FFH to DL-register
Decrement DL-register
Jump on no zero to Label L2
Decrement BL-register
Jump on no zero to lion
Return from subroutine

PROGRAM
MOV AL,90H
OUT 26H,AL

COMMENTS
Copy 90H to AL-register
Configure output port

IN AL,20H
SUB AL,3FH

Configure AL-register
Subtract 3F from AL-register

RECEIVER:
ADDRESS
1000
1003

OPCODE
C6 C0 90
E6 26

1005
1007

E4 20
80 E8 3F

100A
100C

75 F9
C6 C0 3F

JNZ CHECK
MOV AL,3FH

Jump on no zero to loop


Copy 3FH to AL-register

100F
1011

E6 22
C6 C1 08

OUT 22H,AL
MOV CL,08H

Configure output port


Copy 08H to AL-register

1014
1017

E8 12 00
C7,C6,00,12

CALL DELAY
MOV SI,1200H

Call delay program


Copy 1200H TO SI-register

101b
101d

E4 20
88,04

IN AL,20H
MOV [SI],AL

101F
1022

E8 07 00
46

CALL DELAY
INC SI

Configure AL-register
copy content of AL-register to
SI-register
Call delay program
Increment SI-register

1023
1025

FE C9
75 F4

DEC CL
JNZ L1

Decrement CL-register
Jump on no-zero to L1

1027
1029

CD 02
C6 C3 05

INT 02
MOV BL,05H

Call interrupt routine


Copy 05H to BL-register

102C
102F
1031
1033
1035
1037
1038

C6 C2 FF
FE CA
75 FC
FE CB
75 F5
C3
C3

MOV DL,0FFH
DEC DL
JNZ L2
DEC BL
JNZ LION
RET
RET

Copy FFH to DL-register


Decrement DL-register
Jump on no zero to L2
Decrement BL-register
Jump on no-zero to Lion
Return from subroutine
Return from subroutine

LABEL

CHECK:

L1:

DELAY:
LION:
L2:

86

OUTPUT:
INPUT(Transmitter end)
Address
Data
1200
24

OUTPUT (Receiver end)


Address
Data
1200
24

VIVA QUESTIONS:
1. What is Baud rate?
2. What is the difference between synchronous and asynchronous communication?
3. What is the expansion of RS?
4. What is the expansion of USART?
5. What is the role of RS-232?
6. What type of interface is 8255?
7. What are the different types of modes in 8255?
8. What are the features of mode 0 in 8255?
9. What are the features of mode 1 in 8255?
10. What are the features of mode 2 in 8255?

RESULT:
Thus an assembly language program to establish a parallel communication between two
8086 kits was implemented and its output was verified.

87

EXP. NO: 13A

INTERFACING ANALOG TO DIGITAL CONVERTER

AIM:
To write and execute an assembly language program to convert an analog signal into a digital
signal using an ADC interfacing.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. ADC Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
ALGORITHM:
(i)
Select the channel and latch the address.
(ii)
Send the start conversion pulse.
(iii)
Read EOC signal.
(iv)
If EOC = 1 continue else go to step (iii)
(v)
Read the digital output.
(vi)
Store it in a memory location.
PROGRAM:

ADDRESS

OPCODE

LABEL

PROGRAM

1000

B0 10

MOV AL,00

1002
1004

E6 C8
80 18

OUT 0C8H,AL
MOV AL,08

88

COMMENTS
Load accumulator with value for
ALE high
Send through output port
Load accumulator with value for
ALE low

1006
1008

E6 C8
B0 01

OUT 0C8H,AL
MOV AL,01

100A
100C
100E
1010
1012

E6 D0
B0 00
B0 00
B0 00
B0 00

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

1014
1016
1018
101A
101C

E6 D0
E4 D8
24 01
3C 01
75 F8

OUT 0D0H,AL
IN AL, 0D8H
AND AL,01
CMP AL,01
JNZ L1

101E
1020

E4 C0
BB 00 11

IN AL,0C0H
MOV BX,1100

1022
1024

88 07
F4

MOV [BX],AL
HLT

L1

Send through output port


Store the value to make SOC high
in the accumulator
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

OUTPUT:
ANALOG VOLTAGE
5
3.84
3.83
3.79
3.76
0

DIGITAL DATA ON LED


DISPLAY
1111 1111
0000 0111
1001 0010
0111 0100
0100 0011
0000 0000

89

HEX CODE IN MEMORY


LOCATION
FF
07
92
74
43
00

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

EXP. NO: 13B

INTERFACING DIGITAL TO ANALOG CONVERTER

AIM:
To write and execute an assembly language program for digital to analog conversion.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. DAC Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
ALGORITHM:
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv)Introduce delay.
(v) Repeat the above procedure.
Saw-tooth waveform:
(i) Load low value (00) to accumulator.
(ii) Send this value to DAC.
(iii) Increment the accumulator.
(iv)Repeat step (ii) and (iii) until accumulator value reaches FF.
(v) Repeat the above procedure from step 1.
Triangular waveform:
(i) Load the low value (00) in accumulator.

90

(ii) Send this accumulator content to DAC.


(iii) Increment the accumulator.
(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.
(v) Decrementing and sending the accumulator contents to DAC.
(vi)The above procedure is repeated from step (i)
PROGRAM:
ADDRESS

SQUARE WAVE
OPCODE
LABEL

1000

B0 00

1002

L2

PROGRAM

COMMENTS

MOV AL,00H

Load 00 in accumulator

E6 C8

OUT C8,AL

Send through output port

1004

E8 09 00

CALL L1

Give a delay

1007

B0 FF

MOV AL,FFH

Load FF in accumulator

1009

E6 C8

OUT C8,AL

Send through output port

100B

E8 02 00

CALL L1

Give a delay

100E

EB F0

JMP L2

Go to starting location

1010

B9 FF C5

L1

MOV CX,05FFH

Load count value in CX


register

1013

E2 FE

L3

LOOP L3

Decrement until it reaches


zero

1015

C3

RET

Return to main program

PROGRAM: SAWTOOTH WAVE


ADDRESS
OPCODE
LABEL
1000
B0 00
L2

PROGRAM
MOV AL,00H

COMMENTS
Load 00 in accumulator

1002

E6 C0

OUT C0,AL

Send through output port

1004

FE C0

INC AL

Increment contents of
accumulator

1006

75 FA

JNZ L1

Send through output port


until it reaches FF

1008

EB F6

JMP L2

Go to starting location

L1

PROGRAM: TRIANGULAR WAVE


ADDRESS
OPCODE
LABEL
1000
B0 00
L3
1002
E6 C8
L1
1004
FE C0

PROGRAM
MOV AL,00H
OUT C8,AL
INC AL

1006

75 F8

JNZ L1

1008
100A
100C

B0 FF
E6 C8
FE C0

L2

MOV AL,0FFH
OUT C8,AL
DEC AL

91

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

100E

75 F8

JNZ L2

1110

EB EA

JMP L3

Send through output port until


it reaches 00
Go to starting location

OUTPUT:
WAVEFORM GENERATION
WAVEFORMS
Square wave
Saw-tooth wave
Triangular wave

AMPLITUDE
10v
10v
10v

TIME PERIOD
1ms
1.4ms
3.2ms

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What are the different types of ADC?


What is meant by conversion time?
What are the different types of ADC techniques available?
Name the ADC IC available using serial interface technique?
Name the ADC IC available using parallel interface technique?
What are the different types of DAC techniques available?
Name the DAC IC available
What is resolution?
What is settling time?
What is range of operation in DAC?

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

92

8051 MICROCONTROLLER

93

EXP. NO: 14A

ARITHMETIC OPERATIONS USING 8051

AIM:
To write and execute an assembly language program for Add, subtract, multiply and division of
two 8-bit numbers using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Add the two data with carry.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS
4100
4102
4105

OPCODE
74,05
75,F0,05
35,F0

LABEL

PROGRAM
MOV A,#data
MOV B,#data
ADDC A,B

4107

90,45,00

MOV DPTR,#4500H

410A
410B

F0
80, FE

MOVX @ DPTR,A
SJMP STOP

STOP:

COMMENTS
Load data 1 in accumulator.
Load data 2 in B-register
Add the contents of
accumulator and B-reg with
carry.
Initialize DPTR with
address 4500H
Store the result in 4500H
Stop the program

OUTPUT:
INPUT
Register
A-register
B-register

OUTPUT
Data
02H
04H

Address
4500

Data
06H

SUBTRACTION
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Subtract the two data with borrow.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS
4100

OPCODE
74,05

LABEL

PROGRAM
MOV A,#data

94

COMMENTS
Load data 1 in accumulator.

4102
4105

75,F0,04
95,F0

MOV B,#data
SUBB A,B

4107

90 45 00

MOV DPTR,#4500H

410A
410B

F0
80, FE

STOP:

MOVX @ DPTR,A
SJMP STOP

Load data 2 in B-register


Subtract the contents of Breg from accumulator with
borrow.
Initialize DPTR with
address 4500H
Store the result in 4500H
Stop the program

OUTPUT:
INPUT
Register
A-register
B-register

OUTPUT
Data
05H
01H

Address
4500

Data
04H

MULTIPLICATION
ALGORITHM:
1. Get the multiplier in the accumulator.
2. Get the multiplicand in the B register.
3. Multiply A with B.
4. Store the product in memory location.
5. Stop the program.
PROGRAM:
ADDRESS

OPCODE

LABEL

PROGRAM

COMMENTS

4100

74,05

MOV A,#data

Load data 1 in accumulator.

4102

75,F0,05

MOV B,#data

Load data 2 in B-register

4105

A4

MUL AB

A*B, Higher byte of result


in B and lower byte of result
in A.

4106

90,45,00

MOV DPTR,#4500H

Initialize DPTR with


address 4500H

4109

F0

MOVX @ DPTR,A

Store the LSB in 4500H

410A

A3

INC DPTR

Increment Data pointer

410B

E5,F0

MOV A,B

Copy the content of B-reg to


A-register.

410D

F0

MOVX @ DPTR,A

Store the MSB in 4501H

410E

80, FE

SJMP STOP

Stop the program

STOP:

OUTPUT:
INPUT
REGISTER
A
B

OUTPUT
DATA
5
5

ADDRESS
4500

95

DATA
19H

DIVISION
ALGORITHM:
1. Get the Dividend in the accumulator.
2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.
5. Stop the program.
PROGRAM:
ADDRESS

OPCODE

LABEL

PROGRAM

COMMENTS

4100

74,data1

MOV A,#data 1

Load data 1 in accumulator.

4102

75,data2

MOV B,#data 2

Load data 2 in B-register

4104

84

DIV AB

Divide. Remainder in A and


quotient in B

4105

90,45,00

MOV DPTR,#4500H

Initialize DPTR with


address 4500H

4108

F0

MOVX @ DPTR,A

Store the Remainder in


4500H

4109

A3

INC DPTR

Increment Data pointer

410A

E5,F0

MOV A,B

Copy the content of B-reg to


A-register.

410C

F0

MOVX @ DPTR,A

Store the quotient in 4501H

410D

80, FE

SJMP STOP

Stop the program

STOP:

OUTPUT:
INPUT
REGISTER
A-Register
B-Register

OUTPUT
DATA
05
03

ADDRESS
4500
4501

DATA
01(quotient)
02(remainder)

RESULT:
Thus an assembly language program for Division of two 8-bit numbers and 16-bit numbers
using 8051 was performed and its output was verified.

96

EXP. NO: 14B

LOGICAL OPERATIONS USING 8051

AIM:
To write and execute an assembly language program to perform logical operations using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data 1 in the R0-register.
2. Get the Data 2 in the A register.
3. Logical AND, OR, XOR A with R0.
4. Store the result in memory.
5. Stop the program.
PROGRAM: AND OPERATION
ADDRESS
4100

OPCODE
78,14

LABEL

4102
4104

74,12
58

4105

90,45,00

MOV DPTR,#4500H

4108
4100

F0
80, FE

MOVX @ DPTR,A
SJMP STOP

STOP:

PROGRAM
MOV R0,#DATA 1

COMMENTS
Load data 1 in R0-reg.

MOV A,#DATA 2
ANL A,R0

Load data 2 in A-register


Logical AND the contents of
A-reg with R0-register.
Initialize DPTR with
address 4500H
Store the result in 4500H
Stop the program

OUTPUT:
INPUT

OUTPUT

REGISTER
R0-Register
A-Register

DATA
14
12

ADDRESS
4500

DATA
10

PROGRAM: OR OPERATION
ADDRESS

OPCODE

LABEL

4100

78,14

MOV R0,#DATA 1

Load data 1 in R0-reg.

4102

74,12

MOV A,#DATA 2

Load data 2 in A-register

4104

58

ORL A,R0

Logical OR the contents of


A-reg with R0-register.

4105

90,45,00

MOV DPTR,#4500H

Initialize DPTR with


address 4500H

4108

F0

MOVX @ DPTR,A

Store the result in 4500H

4100

80, FE

SJMP STOP

Stop the program

STOP:

PROGRAM

97

COMMENTS

OUTPUT:
INPUT
REGISTER
R0-Register
A-Register

OUTPUT
DATA
14
12

ADDRESS
4500

DATA
16

PROGRAM: XOR OPERATION


ADDRESS

OPCODE

LABEL

4100

78,14

MOV R0,#DATA 1

Load data 1 in R0-reg.

4102

74,12

MOV A,#DATA 2

Load data 2 in A-register

4104

68

XRL A,R0

Logical EX-OR the contents


of A-reg with R0-register.

4105

90,45,00

MOV DPTR,#4500H

Initialize DPTR with


address 4500H

4108

F0

MOVX @ DPTR,A

Store the result in 4500H

4100

80, FE

SJMP STOP

Stop the program

STOP:

PROGRAM

COMMENTS

OUTPUT:
INPUT
REGISTER
R0-Register
A-Register

OUTPUT
DATA
14
12

ADDRESS
4500

DATA
06

VIVA QUESTIONS:

1. Difference between microprocessor and microcontroller.


2. Explain DJNZ instructions of Intel 8051 microcontroller?
3. Why 8051 is called 8 bit microcontroller?
4. What is the difference between Harvard and Newman architecture?
5. Intel 8051 follows which architecture: Harvard or Newman?
6. How much on-chip RAM is available?
7. What is special function registers?
8. What are the different industrial applications of micro controllers?
9. What is the difference between the CISC and RISC processors?
10. List the addressing modes of 8051.

RESULT:
Thus an assembly language program for logical operations using 8051 was performed and its
output was verified.

98

99

EXP. NO: 15

SQUARE OF A NUMBER USING 8051

AIM:
To write and execute an assembly language program to find the square, cube and 2s
complement of a number using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS

OPCODE

4100

90, 45, 00

4103

LABEL

PROGRAM

COMMENTS

MOV DPTR,#4200H

Initialize data pointer with


address 4200H

E0

MOVX A,@DPTR

Copy the content of data


from address 4200H to
accumulator

4104

F8

MOV R0,A

Copy the content of data


from R0-reg to accumulator

4105

F5,F0

MOV B,A

Copy the content of data


from A-reg to B-register.

4107

A4

MUL AB

Multiply AB

4108

A3

INC DPTR

Increment data pointer to


store the result

4109

F0

MOVX @DPTR,A

Store the result in 4500H

410A

E5,F0

MOV A,B

Copy the content of data


from B-reg to A-register.

410C

A3

INC DPTR

Increment data pointer to


store the result

410D

F0

MOVX @ DPTR,A

Store the result in 4501H

410E

80, FE

SJMP STOP

Stop the program

STOP:

OUTPUT:
INPUT
ADDRESS
4200

OUTPUT
DATA
FF

ADDRESS
4201
4202

100

DATA
01
FE

CUBE OF A NUMBER USING 8051


ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS
4100

OPCODE
90 42 00

LABEL

PROGRAM
MOV DPTR,#4200H

4103

E0

MOVX A,@DPTR

4104

F8

MOV R0,A

4105

F5,F0

MOV B,A

4107
4108

A4
C0,F0

MUL AB
PUSH B

410A

F5,F0

MOV B,A

410C

E8

MOV A,R0

410D
410E

A4
A3

MUL AB
INC DPTR

410F

F0

MOVX @DPTR,A

4110

AA,F0

MOV R2,B

4112
4114

D0,F0
E8

POP B
MOV A,R0

4115
4116

A4
2A

MUL AB
ADD A,R2

4117

A3

INC DPTR

4118
4119

F0
E5,F0

411B

A3

INC DPTR

411C

F0

MOVX @DPTR,A

MOVX @ DPTR,A
MOV A,B

101

COMMENTS
Initialize data pointer with
address 4200H
Copy the content of data from
address 4200H to accumulator
Copy the content of data from
A-reg to R0-register.
Copy the content of data from
A-reg to B-register.
Multiply AB
Store the content of B-reg in
stack
Copy the content of data from
A-reg to B-register.
Copy the content of data from
R0-reg to accumulator
Multiply AB
Increment data pointer to store
the result
Copy the content of data from
address 4201H to accumulator
Copy the content of data from
R2-reg to B-register
Retrieve the data from stack
Copy the content of data from
R0-reg to accumulator
Multiply AB
Add the contents of A and R2
register and store the data in
A-reg.
Increment data pointer to store
the result
Store the result in 4500H
Copy the content of data from
B-reg to A-register.
Increment data pointer to store
the result
Copy the content of data from

411D

80, FE

STOP:

address 4202H to accumulator


Stop the program

SJMP STOP

OUTPUT:
INPUT
ADDRESS
4200

OUTPUT
DATA
56

ADDRESS
4201
4202
4203

DATA
98
B4
09

2S COMPLEMENT OF A NUMBER USING 8051


ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS
4100

OPCODE
90 42 00

LABEL

PROGRAM
MOV DPTR,#4200H

4103

E0

MOVX A,@DPTR

4104

F4

CPL A

4105

24,01

4107

A3

INC DPTR

4108

F0

MOVX @DPTR,A

4109

80, FE

ADD A,#01H

STOP:

SJMP STOP

COMMENTS
Initialize data pointer with
address 4200H
Copy the content of data
from address 4200H to
accumulator
Complement the contents
of Accumulator
Add the contents of
Accumulator and 01 data
and store the data in A-reg.
Increment data pointer to
store the result
Copy the content of data
from address 4201H to
accumulator
Stop the program

OUTPUT:
INPUT
ADDRESS
4200

OUTPUT
DATA
05

ADDRESS
4201

VIVA QUESTIONS:

102

DATA
0BH

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Give the format of PSW register of 8051.


What is the use of PCON register?
Give the interrupt priorities of 8051.
What is the significance of DPTR?
Draw the format of TMOD register of 8051
List the modes of Timer in 8051.
Draw the format of TCON register of 8051
Draw the format of IE register.
Draw the format of IP register
Draw the format of SCON register of 8051

RESULT:
Thus an assembly language program to find square, cube and 2s complement of a number
using 8051 was performed and its output was verified.

103

104

EXP. NO: 16

UNPACKED BCD TO ASCII USING 8051

AIM:
To write and execute an assembly language program to convert unpacked BCD to ASCII using
8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS
4100

OPCODE
90 42 00

LABEL

PROGRAM
MOV DPTR,#4200H

4103

E0

MOVX A,@DPTR

4104

F5,F0

MOV B,A

4106

55,0F

ANL A, 0FH

4108

44,30

ORL A,#30H

410A

A3

INC DPTR

410B

F0

MOVX @DPTR,A

410C

E5,F0

MOV A,B

410E

55,F0

ANL A,F0H

4110
4111
4112
4113
4114

03
03
03
03
44,30

RR A
RR A
RR A
RR A
ORL A,#30H

105

COMMENTS
Initialize data pointer with
address 4200H
Copy the content of data from
address 4200H to accumulator
Copy the content of data from
A-reg to B-register.
AND the contents of A-reg
with 0F and store the data in Aregister.
Add the contents of
Accumulator and 30 data and
store the data in A-reg.
Increment data pointer to store
the result
Copy the content of data from
address 4201H to accumulator
Copy the content of data from
B-reg to A-register.
AND the contents of A-reg
with F0 and store the data in Aregister
Rotate right accumulator
Rotate right accumulator
Rotate right accumulator
Rotate right accumulator
Add the contents of
Accumulator and 30 data and
store the data in A-reg.

4116

A3

INC DPTR

4117

F0

MOVX @DPTR,A

4118

80, FE

STOP:

SJMP STOP

Increment data pointer to store


the result
Copy the content of data from
address 4201H to accumulator
Stop the program

OUTPUT:
INPUT
ADDRESS
4200

OUTPUT
DATA
29

ADDRESS
4201
4202

DATA
39
32

VIVA QUESTIONS:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

How will you configure ports as input and output port?


What are the flags supported by 8051 controller?
What is meant by Power-on- Reset in 8051 controller?
What are the different groups of instructions supported by 8051?
What is the need of pull up registers in 8051?
How many bytes of internal RAM and ROM supported by 8051 micro controller?
What are the alternative functions of port 3 of 8051?
What are the uses of scratch pad area of internal RAM of 8051?
Write a program to find the 2s complement using 8051?
How to calculate the execution time for instruction in 8051?

RESULT:
Thus an assembly language program for conversion of Unpacked BCD to ASCII number
using 8051 was performed and its output was verified.

106

You might also like