Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 226

SYLLABUS

CS6412 MICROPROCESSOR AND MICROCONTROLLER LABORATOR


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

LIST OF EXPERIMENTS:
8086 Programs using kits and MASM
1. Basic arithmetic and Logical operations
2. Move a data block without overlap
3. Code conversion, decimal arithmetic and Matrix operations.
4. Floating point operations, string manipulations, sorting and searching
5. Password checking, Print RAM size and system date
6. Counters and Time Delay
Peripherals and Interfacing Experiments
7. Traffic light control
8. Stepper motor control
9. Digital clock
10. Key board and Display
11. Printer status
12. Serial interface and Parallel interface
13. A/D and D/A interface and Waveform Generation
8051 Experiments using kits and MASM

14. Basic arithmetic and Logical operations


15. Square and Cube program, Find 2s complement of a number
16. Unpacked BCD to ASCII
TOTAL: 45 PERIODS
OUTCOMES:
At the end of the course, the student should be able to:

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

https://sites.google.com/site/ecerjt/tutorials/the-8051-microcontroller-and-embeddedsystems-

LAB EQUIPMENT FOR A BATCH OF 30 STUDENTS:


HARDWARE:
8086 development kits - 30 nos
Interfacing Units - Each 10 nos
Microcontroller - 30 nos
SOFTWARE:
Intel Desktop Systems with MASM - 30 nos
8086 Assembler
8051 Cross Assembler

INTRODUCTION TO MASM
Programming of a microprocessor usually takes several iterations before the right
sequence of machine code instruction is written. The process, how machine code is
facilitated casing a special program called an assembler. The assembler allows the user
to write alphanumeric instructions (or) mnemonics called assembly language instructions.
An assembler takes the written assembly code and converts it into machine code. Often it
will come with a linker that links the assembled file and produces an executable from
it.Window executables have the extension. Here are some of the popular ones
MASM:- Microsofts macro assembler(MASM) is an integrated software package
written by Microsoft co-operation for professional software developers. It consists of an
editor, an assembler, a linker and a debugger the programmers work bench combines
these four path into a user friendly programming environment with built in online help.
FAMILIARITY WITH MASM:-

-DOS and windows environments.

TASM:- Another popular assembler made by Borland but it is still a commercial


product.
ASSEMBLING THE PROGRAM:The assembler is used to convert the assembly language instructions to machine
code. It is used immediately after writing the assembly language program. The assembler
starts by checking the syntax or validity of the structure of each instruction in the source
file. If any errors are found the assembler displays a report on these errors along with

brief explanation of their nature. However, if the program does not contain any errors.
The assembler produces an object file that the same name as original file but with the
.obj extension.
LINKING THE PROGRAM:The linker is used to convert the object file to an executable file the executable
file is the final set of machine code instructions that can directly be executed by
microprocessor. It is difficult and different than the object file on the sense that it is selfcontained
and locatable. An object file may represent on segment of long program. This
program cannot operate by itself and must be integrated with other object file
representing the rest of the program in order to produce the final self contained exactable
file.
DEBUGGING THE PROGRAM:The debugger can also be used to find logical errors in the program. Even if a
program does not contain syntax errors. It may not produce the desired result after
execution. Logical errors may be found by tracing the action of the program. Once found
the source file called Debugger is designed for that purpose.
The debugger allows the user to trace the action of the program by single stepping
through the program (or) executing the program up to a desired point called breakpoint. It
allows the user to inspect (or) change the contents of MP internal register (or) the
contents of any memory location.
EXECUTING THE PROGRAM:The executable file contains the machine language code. It can be based on the RAM and
be executed by the micro processor. Simply by typing from the DOS prompt. It the
program produces an output on the screen or a sequence of control a piece of on
hardware, if the programming manipulates data in memory nothing would seem to have

happened as a result of executing the program.


THE DOS-DEBUGGER:THE DOS-Debug program is an example of a simple debugger that comes with MS
DOS. Hence it will available on any pc. It was initially designed to give the user
capability to trace logical errors in executable files. It allows the user to take an existing
executable file and unassembled it i.e., convert into assembly language also it allows the
user to write assembly language instructions directly and then convert them to machine
language.
MS-PWB:The PWB allows the user to define a project that means it contains one or more files then
the user may select and save all the necessary assembly linking and debugging option for
that project the PWB allows the leaving the PWB environment it also allows the user to
get help on any keyword by pointing to the keyboard a

Exp No : 1

DATE:

Programs for 16 bit Arithmetic operations (Using 8086).


(a) ADDITION OF TWO 16-BIT NUMBERS
AIM: To write an assembly language program to add the two 16-bit numbers
residing in memory and store the result in memory using 8086.
APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board
ii. Power chord.

ALGORITHM:
1. Load the Addend data to accumulator.
2. Get the Augends and Add with Accumulator content.
3. Store the result.

FLOW CHART:

START

Load theAddend data to accumulator

Get the Augend and Add with Accumulator content

Store the result

STOP

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENT

1000

MOV AX,[2000]

8B, 06,00,20 Move addend to accumulator

1003

ADD AX,[2002]

03,06,02,20

Add addend with augends

1007

MOV [2004],AX

89,06,04,20

Move accumulator content to


memory

100A

HLT

F4

Stop

OBSERVATION:

16 BIT ADDITIONS

INPUT

ADDRESS BYTE

SET I (Hex)

SET II(Hex)

16-bit
Data 1

2000h

LB

13

FF

2001h

HB

12

D1

16-bit
Data2

2002h

LB

10

7F

2003h

HB

11

CF

OUTPUT ADDRESS BYTE

SET I (Hex)

SET II(Hex)

Without
carry
16 bit
Sum

2004h

LB

2005h

HB

Carry

2006h

LB

With carry

RESULT: Thus the assembly language program to add the two 16-bit numbers is
Written and executed successfully.

(b) SUBTRACTION OF TWO 16-BIT NUMBERS USING 8086


AIM: To write an assembly language program to subtract two 16-bit numbers
residing in memory and store the result in memory using 8086.
APPARATUS REQUIRED:
i. 8086 Microprocessor kit with key board,
ii. Power chord.
ALGORITHM:
1. Load the Minuend data to accumulator.

2. Get the Subtrahend and subtract with Accumulator content.


3. Store the result.

FLOW CHART:
START

Load the Minuend data to accumulator

Get the Subtrahend and subtract with Accumulator


content
Store the result

STOP

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENT

1000

MOV AX,[2000]

8B,06,00,20

Move minuend to
accumulator

1003

SUB AX,[2002]

2B,06,22,20

Subtract minuend with


subtrahend

1007

MOV [2004],AX

89,06,04,20

Move accumulator
content to memory.

100A

HLT

F4

Stop

OBSERVATION:16 BIT SUBTRACTIONS


INPUT

ADDRESS BYTE

SET I (Hex)

SET II(Hex)

Minuend

2000h

LB

15

FD

2001h

HB

13

DE

Subtrahend 2002h

LB

13

6A

2003h

HB

14

18

OUTPUT

ADDRESS BYTE

SET I (Hex)
Without
Borrow

16 bit

2004h

LB

Difference 2005h

HB

Borrow

LB

2006h

SET II(Hex)
with Borrow

RESULT: Thus the assembly language program to subtract the two 16-bit
Numbers is written and executed successfully.

(C) MULTIPLICATION OF TWO 16-BIT NUMBERS


AIM: To write an assembly language program to multiply two 16 bit numbers and
store the result in memory using 8086.
APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board,
ii. Power chord.

ALGORITHM:
1. Get the multiplier and multiplicand.
2. Multiply the given two numbers.
3. Store the result in consecutive memory locations.
FLOW CHART:

START

Get the multiplier and multiplicand

[Multiplier] x [multiplicand]

Store the result

STOP

PROGRAM:
ADDRESS
1000

LABEL

MNEMONICS
MOV AX,[2000]

OPCODE
8B,06,00,20

COMMENT
Move the data to
accumulator
Multiply memory

1003

MUL[2002]

F7,26,02,11

content
with accumulator

1007

MOV [2004],DX

8B,1E,02,20

Store MSW

100B

MOV[2006],AX

89,16,02,20

Store LSW

100E

HLT

F4

Stop

OBSERVATION:16 BIT MULTIPLICATION


INPUT

ADDRESS BYTE

Multiplicand 2000h

LB

SET I (Hex)

SET II(Hex)

12

23

Multiplier

2001h

HB

12

FD

2002h

LB

13

1C

2003h

HB

14

1F

OUTPUT

ADDRESS

BYTE

32 bit

2004h

LB

Result

2005h

HB

2006h

LB

2007

HB

SET I (Hex)

SET II(Hex)

RESULT: Thus the assembly language program to multiply the two 16-bit
numbers is written and executed successfully.

(D) DIVISION OF TWO 16-BIT NUMBERS


AIM: To write an assembly language program to divide two 16 bit numbers and
store the result in memory using 8086.
APPARATUS REQUIRED:
i. 8086 Microprocessor kit with key board,
ii. Power chord.
ALGORITHM:

1. Get the dividend and divisor.


2. Divide the given two numbers.
3. Store the result in consecutive memory locations.
FLOW CHART:

START

Get the Dividend and Divisor

[Dividend] / [Divisor]

Store the result

STOP

PROGRAM:
ADDRESS
1000

LABEL

MNEMONICS
MOV AX,[1100]

OPCODE
8B,06,02,00

COMMENT
Move the data to
accumulator
divide memory

1003

DIV AX, [1102]

F7,36,02,11

content
with accumulator

1007

MOV [1200],AX

8D,1E,02,20 Store MSW

100B

MOV[1202],DX

A3,02,12

Store LSW

100E

HLT

F4

Stop

OBSERVATION:16 BIT DIVISION

INPUT

ADDRESS BYTE

SET I (Hex)

SET II(Hex)

Dividend 2000h

LB

23

AD

2001h

HB

43

AE

2002h

LB

12

CB

2003h

HB

14

CA

Divisor

OUTPUT

ADDRESS BYTE

16 bit

2004h

LB

Quotient

2005h

HB

Remainder 2006h

LB

SET I (Hex)

SET II(Hex)

RESULT: Thus the assembly language program to divide the two 16-bit numbers
is written and executed successfully.
(E) SUM OF N NUMBERS IN AN ARRAY
AIM: To write an assembly language program to add a given numbers in an
Array and store the result in memory.
APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board ii. Power chord.
ALGORITHM:
1.
2.
3.
4.

Get the count in register for number of data.


Initialize the array address.
Add the given N numbers.
Continue the addition till the count becomes zero.

5. Store the result in consecutive memory locations.


6. Stop the program.
FLOW CHART:
START

Get the count to count register from first location of source

Get the first and second data by increment the pointer

Increment the
pointer
Add the two numbers and decrement the count value by
1

Is count
value 0 ?

Store the result

STOP

No

yes

Yes

ADDRESS

LABEL

PROGRAM:

MNEMONICS

OPCODE

COMMENT

1000

MOV SI, 2000

C7,C6,00,2
0

1003

MOV CL,[SI]

1007

INC SI

100B

MOV AH,[SI]

8A,24

INC SI

FE,09

100E

NEXT:

8A,0C

46

Initialize the memory pointer


Move the content of 2000 to
count register CL.
increment the memory pointer
Move the content of SIie 2001

1010

ADD AH, [SI]

46

1014

DEC CL

02,24

to AH register.
increment the memory pointer
Add the content of AH and
content of 2002.
Decrement the count value by 1.
If the count is non zero go to the

1018

JNZ :NEXT

75,79

address specify by the label


NEXT. if count is zero continue
with next instruction.

110B

INC SI

46

101C

MOV [SI],AH

88,24

101D

HLT

F4

Increment the SI for store result.


Finally sum in AH is store in the
memory specify by SI.
Stop the program.

OBSERVATION: SUM OF N DATA IN AN ARRAY

INPUT

ADDRESS BYTE

SET I (Hex)

SET II(Hex)

Count (N)
value

2000h

05

0A

Data 1

2001h

LB

77

23

Data 2

2002h

LB

56

53

Data 3

2003h

LB

54

76

Data 4

2004h

LB

12

FA

Data 5

2005h

LB

09

CD

Data 6

2006h

LB

23

Data 7

2007h

LB

65

Data 8

2008h

LB

98

Data 9

2009h

LB

FC

Data 10

200Ah

LB

BC

OUTPUT

ADDRESS

BYTE

Sum of N

2004h

LB

Numbers

2005h

HB

SET I (Hex)

SET II(Hex)

RESULT: Thus the assembly language program to add N numbers in a given array
is written and executed successfully.

Ex.No : 2

DATE:
Programs for Sorting and Searching (Using 8086).

(a)Largest Number in an array


AIM: To write an assembly language program to find a largest value in a given
array and store the result in memory.
APPARATUS REQUIRED:
i. 8086 Microprocessor kit with key board,

ii. Power chord.


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

Get the count in register for number of data.


Initialize the array address.
Compare the selected two numbers and check carry.
If bigger, store the largest value in accumulator.
Otherwise interchange the contents with register.
Decrement the count.
Continue the same operation till the count becomes zero.
Store the result in memory locations.

FLOW CHART:

PROGRAM:
ADDRESS

LABEL

1000

MNEMONICS
MOV SI, 2000
MOV CL,[SI]

INC SI

MOV AL,[SI]
NEXT:

INC SI

OPCODE

COMMENT
Initialize the memory pointer.
Move the content of 2000 to
count register CL.
Increment the memory pointer
as 2001.
Move the content of 2001 to
the AL register.
Increment the memory pointer
After getting the first data

DEC CL

decrement the count value by


1.

INC SI
MOV BL,[SI]
CMP AL,BL

Increment the memory pointer


Move the content of SI to
register BL.
Compare the content of AL,BL

If no carry occur jump to the


address specify by SKIP.
JNC: SKIP
if carry occur continue the next
instruction.
Move the content of BL to AL

MOV AL,BL

SKIP:

register.
Decrement the count value in

DEC CL

CL by 1.
If count is not zero jump to
address specify by NEXT.

JNZ: NEXT

otherwise continue the next


instruction.
Increment the memory pointer

INC SI

to store the result.


Move the largest no hold by AL

MOV [SI],AL

to the address hold by SI.

HLT

Stop the program

OBSERVATION :LARGEST OF N DATA IN AN ARRAY


INPUT

ADDRESS

BYTE

SET I
(Hex)

SET
II(Hex)

Count (N) 2000h


value

LB

05

0A

Data 1

2001h

LB

16

12

Data 2

2002h

LB

FD

34

Data 3

2003h

LB

DC

56

Data 4

2004h

LB

CD

75

Data 5

2005h

LB

14

89

Data 6

2006h

LB

9F

Data 7

2007h

LB

FC

Data 8

2008h

LB

AD

Data 9

2009h

LB

BC

Data 10

200Ah

LB

BB

OUTPUT

ADDRESS

BYTE

Largest
Value

2006h

LB

200Bh

LB

SET I
(Hex)

SET
II(Hex)

RESULT: Thus an assembly language program to find the largest value in a given
array is written and executed successfully.
(b) Smallest Number in an array
AIM: To write an assembly language program to find a smallest value in a given
array and store the result in memory.

APPARATUS REQUIRED:
i. 8086 Microprocessor kit with key board,
ii .Power chord.
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 smaller, 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.
FLOW CHART:

PROGRAM:
ADDRESS

LABEL

1000

MNEMONICS

COMMENT

MOV SI, 2000

SI 2000

MOV CL,[SI]

CL [SI]

INC SI
MOV AL,[SI]
NEXT:

OPCODE

INC SI

DEC CL

Increment the content of SI by


one.
AL [SI]
Increment the content of SI by
one.
Decrement the content of CL by
one.

INC SI

Increment the content of SI one

MOV BL,[SI]

BL [SI]

SKIP:

CMP AL,BL

Compare the content of AL,BL

JC SKIP

If have carry jump to skip.

MOV AL,BL

AL BL
Decrement the content of CL by

DEC CL

one.

JNZ NEXT

If CL is not zero go to next


Increment the content of SI by

INC SI

OBSERVATION:

one

MOV [SI],AL

[SI] AL

HLT

Terminate the program

SMALLEST OF N DATA IN AN ARRAY

INPUT

ADDRESS

BYTE

SET I (Hex)

SET II(Hex)

Count (N)
value

2000h

LB

05

0A

Data 1

2001h

LB

16

12

Data 2

2002h

FD

34

Data 3

2003h

DC

56

Data 4

2004h

CD

75

Data 5

2005h

14

89

Data 6

2006h

9F

Data 7

2007h

FC

Data 8

2008h

AD

Data 9

2009h

BC

Data 10

200Ah

BB

OUTPUT

ADDRESS

BYTE

Smallest
Value

2006h

LB

200Bh

LB

SET I
(Hex)

SET II(Hex)

RESULT: Thus an assembly language program to find the smallest value in a

given array is written and executed successfully.

(c)

Arranging the given numbers in ascending order

AIM: To write and execute an assembly language program to arrange in ascending


order in a given array of memory.
APPARATUS REQUIRED:
i. 8086 Microprocessor kit with key board,
ii. Power chord.
ALGORITHM:
1. Get the count in register for number of data.
2. Initialize the array address.
3. Compare the first two numbers and if the first number is larger than second
then interchange the number.
4. If the first number is smaller, go to step 5
5. Repeat steps 2 and 3 until the numbers are in required order
FLOW CHART:

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENT

CODE
Initialize the memory

1000
MOV SI, 2000

pointer.

MOV CL,[SI]

Move the content SI to


CL.
Decrement the count
value
Move 2000 to SI.

DEC CL
REPEAT:

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

RECMP:

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

JC :AHEAD

XCHG AL,[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 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 jump 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.

XCHG AL,[SI-1]

AHEAD:

DEC CH

JNZ: RECMP

DEC CL

JNZ: REPEAT
HLT

OBSERVATION:ASCENDING ORDER
INPUT

Count(N)

ADDRESS

BYTE

SET I

OUTPUT

SETII

OUTPUT

(Hex)

Ascending

(Hex)

Ascending

2000h

LB

05

0A

Data 1

2001h

LB

34

AD

Data 2

2002h

56

DC

Data 3

2003h

78

EB

value

Data 4

2004h

87

EE

Data 5

2005h

DB

12

Data 6

2006h

76

Data 7

2007h

31

Data 8

2008h

58

Data 9

2009h

89

Data 10

200Ah

90

RESULT: Thus an assembly language program to arrange the numbers of an array


in ascending order is written and executed successfully.
(d) Arranging the given numbers in descending order
AIM: To write and execute an assembly language program to arrange in
descending order in a given array of memory.
APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board,
ii. Power chord.
ALGORITHM:
1. Get the count in register for number of data.
2. Initialize the array address.
3. Compare the first two numbers and if the first number is smaller than second
then interchange the number.
4. If the first number is smaller, go to step 5
5. Repeat steps 2 and 3 until the numbers are in required order

FLOW CHART:

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENT

1000

MOV SI, 2000


MOV CL,[SI]
DEC CL
REPEAT:

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

RECMP:

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

JNC :AHEAD

XCHG AL,[SI]

XCHG AL,[SI-1]

AHEAD:

DEC CH

JNZ :RECMP

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

DEC CL

JNZ: REPEAT
HLT

OBSERVATION :DESCENDING ORDER


INPUT

Count
(N)

ADDRESS

BYTE

SET I

OUTPUT

SETII

OUTPUT

(Hex)

Ascending

(Hex)

Ascending

2000h

LB

05

0A

Data 1

2001h

LB

33

16

Data 2

2002h

45

67

Data 3

2003h

DB

56

Data 4

2004h

FD

88

Data 5

2005h

EA

90

Data 6

2006h

64

Data 7

2007h

32

Data 8

2008h

11

Data 9

2009h

AD

Data 10 200Ah

EB

value

RESULT: Thus an assembly language program to arrange the numbers of an array


in descending order is written and executed successfully.

Ex.no.3

Date:
Programs for String manipulation operations (Using 8086).

(a) 8086 STRING MANIPULATION FILL A STRING

AIM: To fill a given string byte to a given destination location.

APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board,
ii. Power chord.

ALGORITHM:

1. Load the 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 STOSB with the prefix REP to fill a
string to destination.

FLOW CHART:

PROGRAM:
ADDRESS
1000

LABEL

MNEMONICS
MOV CX,0100

OPCODE

COMMENT
Move 0100 to CX register.

1003

MOV DI,1FFF

Move 1FFF to DI register.

1007

MOV AH,FF

Move FF to AH register.

100B

NOP

No operation

CLD

Clear the direction flag.

STOSB

Store the string byte

100E

REPEAT:

100F

Unconditional loop to
1010

LOOP: REPEAT

address specified by the


label REPEAT.

1013

HLT

stop the program

OBSERVATION:
ADDRESS

DATA

1FFF

FF

2000

FF

2001

FF

2002

FF

2003

FF

2005

FF

2006

FF

RESULT: Thus the assembly language program to fill a given string in a selected
array is written and executed successfully.

(b) 8086 COPY A STRING


AIM: To copy a string of data words from one location to the other.

APPARATUS REQUIRED:
i.8086 Microprocessor kit with key board,
ii. Power chord.

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.

FLOW CHART:

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OPCODE

COMMENT

1000

MOV SI,2000H

1003

MOV DI,2100H

1007

MOV CX,0006 H

100B

MOV AH,55H

Move 55 to AH register.

CLD

Clear the direction flag.

100E

REPEAT:

Initialize the source address.


Initialize the destination
address.
Initialize count value to the
count register.

100F

MOVSB

1010

LOOP:REPEAT

1013

HLT

Move the string byte.


Unconditional loop to address
specified by the label REPEAT.
Stop the program.

OBSERVATION:
INPUTS

OUTPUTS

ADDRESS

DATA

ADDRESS

DATA

2000

55

2100

55

2001

55

2101

55

2202

55

2102

55

2203

55

2103

55

2204

55

2104

55

2205

55

2105

55

RESULT: Thus the assembly language program to copy a string of data byte
from one location to other is written and executed successfully.
(c) 8086 FINDING STRING LENGTH
AIM: To write & execute an ALP to find the length of a given string using
8086 Microprocessor kit.

APPARATUS REQUIRED:

i. 8086 Microprocessor kit with key board,


ii. Power chord
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.

FLOW CHART:

PROGRAM:
ADDRESS

LABEL

MNEMONICS

OP CODE

COMMENT

1000

MOV SI,2000h

C7,C6,00,12

SI 1200

1004

MOV DX,FFFFh

C7,C7,FF,FF

DXFFFF

1008

MOV AH,FFh

C6,C4,FF

AH FF, check FF

INC DX

42

Increment the DX reg. by 1

100C

MOV AL,[SI]

8A,04

AL [SI]

100E

INC SI

46

Increment the SI reg. by 1

100F

CMP AH,AL

38,C4

Compare the content of AH &


AL

100B

NOEND

1011

JNZ : NOEND

75,FB

If the Compared result is not 0


go to by the address specified
label NOEND.

1013

MOV [1100],DX

89,16,00,11

[1100] DXie. store the result

1017

HLT

F4

Terminate the program

OBSERVATION: INPUT
ADDRESS (Hex)

Data (Hex)

1200

E3

1201

F4

1202

54

1203

66

1204

88

1205

99

1206

10

1207

FF

ADDRESS (Hex)

String length (Hex)

1100

08

1101

00

OUTPUT :

RESULT: Thus the assembly language program to find length of a given string of
data bytes in an array is written and executed successfully.
EX. NO.4

DATE:

PROGRAMS FOR DIGITAL CLOCK (USING 8086)


ADDRESS

LABEL

MNEMONICS

OP-CODE

1000

START

CALL CONVERT

E8 00 60

CALL DISPLAY

E8 00 51

MOV AL,B0

B0 B0

OUT 16H,AL

E6 16

1003
1006
1008

DELAY

COMMANDS

100A

MOV CL,07H

B1 07

MOV AL,88H

B0 88

100E

OUT 14H,AL

E6 14

1010

MOV AL,80H

B0 80

1012

OUT 14H,AL

E6 18

MOV AL,80H

B0 80

1016

OUT 16H,AL

E6 16

1018

NOP

90

1019

NOP

90

101A

NOP

90

101B

NOP

90

101C

IN AL,14H

E4 14

101E

MOV DL,AL

8A D0

1020

IN AL,14H

E4 14

1022

OR AL,DL

0A C2

1024

JNZ S1

75 F2

1026

DEC CL

FE C9

1028

JNZ S2

75 E6

102A

MOV SI,1500H

BE 00 15

102D

MOV AL,[SI]

8A 04

102F

INC AL

FE C0

100C

1014

S2

S1

1031

MOV [SI],AL

88 04

1033

CMP AL,3CH

3C 3C

1035

JNZ START

75 CD

1037

MOV AL,00

B0 00

1039

MOV [SI],AL

88 04

103B

INC SI

46

103C

MOV AL,[SI]

8A 04

103E

INC AL

FE C0

1040

MOV [SI],AL

88 04

1042

CMP AL,3CH

3C 3C

1044

JNZ START

75 BE

1046

MOV AL,00

B0 00

1048

MOV [SI],AL

88 04

104A

INC SI

46

104B

MOV AL,[SI]

8A 04

104D

INC AL

FE C0

104F

MOV [SI],AL

88 04

MNEMONICS

OP-CODE

1051

CMP AL,18H

3C 18

1053

JNZ START

75 AF

1055

MOV AL,00

B0 00

ADDRESS

LABEL

COMMANDS

1057

MOV [SI],AL

88 04

1059

JMP START

EB A9

MOV AH,06H

B4 06

105D

MOV DX,1600H

BA 00 16

1060

MOV CH,01H

B5 01

1062

MOV CL,00H

B1 00

1064

INT 5

CD 05

1066

RET

C3

MOV SI,1500H

BE 00 15

106A

MOV BX,1608H

BB 08 16

106D

MOV AL,24H

B0 24

106F

MOV[BX],AL

88 07

1071

MOV AL,[SI]

8A 04

1073

MOV AH,00

B4 00

1075

MOV DH,0AH

B6 0A

1077

DIV DH

F6 F6

1079

ADD AH,30H

80 C4 30

107C

DEC BX

4B

107D

MOV[BX],AH

88 27

107F

DEC BX

4B

1080

ADD AL,30H

04 30

105B

1067

DISPLAY

CONVERT

1082

MOV[BX],AL

88 07

1084

DEC BX

4B

1085

MOV AL,3AH

B0 3A

1087

MOV[BX],AL

88 07

1089

DEC BX

4B

108A

INC SI (minutes)

46

108B

MOV AL.[SI]

8A 04

108D

MOV AH,00

B4 00

108F

MOV DH,0AH

B6 0A

1091

DIV DH

F6 F6

1093

ADD AH,30H

80 C4 30

1096

MOV [BX],AH

88 27

1098

DECBX

4B

1099

ADD AL,30H

04 30

109B

MOV[BX],AL

88 07

109D

DEC BX

4B

109E

MOV AL,3AH

B0 3A

10A0

MOV [BX],AL

88 07

10A2

DEC BX

4B

10A3

INC SI(hours)

46

MNEMONICS

OP-CODE

ADDRESS

LABEL

COMMANDS

10A4

MOV AL,[SI]

8A 04

10A6

MOV AH,00

B4 00

10A8

MOV DH,0AH

B6 0A

10AA

DIV DH

F6 F6

10AC

ADD AH,30H

80 C4 30

10AF

MOV[BX],AH

88 27

10B1

DEC BX

4B

10B2

ADD AL,30H

04 30

10B4

MOV [BX],AL

88 07

10B6

RET

C3

IN AL,02H

E4 02

10B9

AND AL,FFH

24 FF

10BB

CMP AL,F0H

3C F0

10BD

JNE GETC

75 F8

10B7

GETC

TIMING DISPLAY
ADDRESS

SPECIFICATION

VALUE

1500

SECONDS

32

1501

MINUTES

0F

1502

HOURS

05

Result: Thus the ALP for digital clock was written and executted succesfully

BIOS/DOS CALLS

2.a.i 16 bit Addition/Subtraction


.MODEL TINY .CODE
MOV BX,1234h
MOV CX,7698h
MOV AL,BL ; for subtraction replace with
ADD AL,CL ; SUB AL,CL
DAA ; DAS
MOV DL,AL
MOV AL,BL
ADC AL,CH ; SBB AL,CH
DAA ; DAS
MOV DH,AL
MOV AH,4Ch
INT 21h
END

2.c.i 16 bit Multiplication/Division


.MODEL TINY
.CODE
MOV AX,1234h
MOV BX,7698h
ADD AL,31h ; for Division replace with
MUL BX ; DIV BX
MOV AH,4Ch
INT 21h
END

1.(A).DISPLAY A MESSAGE

AIM: To display a message on CRT screen of computer using DOS calls

PROCEDURE:
Step1: Switch on computer
Step2: Go to start menu and select run prompt, type cmd

Step3: Then type edit and open MASM window


Step4: Type your programme and save filename.asm
Step5: Go to command prompt and then compile the programme
Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
MSG DB 0DH,0AH,GOOD MORNING,0DH,0AH,$
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,09H
MOV DX,OFFSET MSG
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

OUTPUT: GOOD MORNING

RESULT: Thus the above bios/dos-> display a message program has been successfully executed
the output is verified.

1(B).FILE CREATION

AIM: To create a file using DOS calls

PROCEDURE:

Step1: Switch on computer


Step2: Go to start menu and select run prompt, type cmd

&

Step3: Then type edit and open MASM window


Step4: Type your programme and save filename.asm
Step5: Go to command prompt and then compile the programme
Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS: CODE, DS:DATA


DATA SEGMENT
FILENAME DB SAMPLE.DAT,$
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET FILENAME
MOV AH,3CH
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

OUTPUT:

SAMPLE.DAT

file was created( in documents and settings folder )

RESULT: Thus the above program has been successfully executed and the output is verified

1( C).ASCII EQUIVALENT OF A TEXT

AIM: To display ASCII equivalent of a text

PROCEDURE:
Step1: Switch on computer
Step2: Go to start menu and select run prompt, type cmd
Step3: Then type edit and open MASM window
Step4: Type your programme and save filename.asm

Step5: Go to command prompt and then compile the programme


Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS:CODE, DS:DATA


DATA SEGMENT
MESSAGE DB 0DH,0AH,GOOD MORNING,0DH,0AH,$
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,36H
MOV DX,OFFSET MSG
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

OUTPUT:

GOOD MORNING

RESULT: Thus the above program has been executed successfully and the output is verified.

1(D) .LARGEST NUMBER IN ARRAY USING MASM

AIM: To implement sorting and searching of Largest number in an array using MASM software

PROCEDURE:

Step1: Switch on computer


Step2: Go to start menu and select run prompt, type cmd
Step3: Then type edit and open MASM window

Step4: Type your programme and save filename.asm


Step5: Go to command prompt and then compile the programme
Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 52H, 23H, 56H, 45H
COUNT EQU 04
LARGEST DB 01H DUP (?)
DATA ENDS
CODE SEGMENTS
START:

MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET LIST
MOV CL,COUNT
MOV AL,[SI]

AGAIN: CMP AL,[SI+1]


JNL NEXT
MOV

AL,[SI+1]

NEXT: INC SI
DEC CL
JNZ AGAIN

MOV SI,OFFSET LARGEST


MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END STAR

RESULT: Thus the above program has been successfully executed and the output is verified

1(E).DESCENDING ORDER OF AN UNSORTED ARRAY USING MASM

AIM: To implement sorting and searching of Largest number in an array using MASM software

PROCEDURE:

Step1: Switch on computer


Step2: Go to start menu and select run prompt, type cmd
Step3: Then type edit and open MASM window

Step4: Type your programme and save filename.asm


Step5: Go to command prompt and then compile the programme
Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 53H,25H,19H,02H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0:

MOV CX,DX
MOV SI,OFFSET LIST

AGAIN1:

MOV AX,[SI]
CMP AX,[SI+2]
JNL PR1
XCHG [SI+2],AX
XCHG [SI],AX

PR1:

ADD SI,02
LOOP AGAIN1
DEC DX

JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT: Thus the above program has been successfully executed and the output is verified.

1(F).DISPLAY THE STRING

AIM: To implement string display using MASM software and verify result

PROCEDURE:
Step1: Switch on computer
Step2: Go to start menu and select run prompt, type cmd
Step3: Then type edit and open MASM window
Step4: Type your programme and save filename.asm

Step5: Go to command prompt and then compile the programme


Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS: CODE, DS:DATA


DATA SEGMENT
MESSAGE DB 0DH, 0AH,MICROPROCESSOR,$
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,09H
MOV DX,OFFSET MESSAGE
INC 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

OUTPUT: MICROPROCESSOR

RESULT: Thus the MASM programme is executed successfully and output verified

1.8086 STRING MANIPULATION SEARCH A WORD

AIM:
To search a word from a string.

ALGORITHM:
5. Load the source and destination index register with starting and the ending address
respectively.
6. Initialize the counter with the total number of words to be copied.

7. Clear the direction flag for auto incrementing mode of transfer.


8. Use the string manipulation instruction SCASW with the prefix REP to search a word
from string.
9. If a match is found (z=1), display 01 in destination address. Otherwise, display 00 in
destination address.
RESULT:
A word is searched and the count of number of appearances is displayed.

PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 15H, 19H, 02H
DEST EQU 3000H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 15H
MOV SI, OFFSET LIST
MOV DI, DEST
MOV CX, COUNT
MOV AX, 00
CLD
REP

SCASW
JZ LOOP
MOV AX, 01

LOOP

MOV [DI], AX
MOV AH, 4CH

INT 21H
CODE ENDS
END START

INPUT:
LIST: 53H, 15H, 19H, 02H

OUTPUT:
3000

01

2.8086 STRING MANIPULATION FIND AND REPLACE A WORD

AIM:
To find and replace a word from a string.

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 SCASW with the prefix REP to search a word
from string.
5. If a match is found (z=1), replace the old word with the current word in destination
address. Otherwise, stop.

RESULT:
A word is found and replaced from a string.

PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 15H, 19H, 02H
REPLACE EQU 30H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 15H

MOV SI, OFFSET LIST


MOV CX, COUNT
MOV AX, 00
CLD
REP

SCASW
JNZ LOOP
MOV DI, LABEL LIST
MOV [DI], REPLACE

LOOP

MOV AH, 4CH


INT 21H

CODE ENDS
END START

INPUT:
LIST: 53H, 15H, 19H, 02H

OUTPUT:
LIST: 53H, 30H, 19H, 02H

3. 8086 STRING MANIPULATION COPY A STRING

AIM:
To copy a string of data words from one location to the other.

ALGORITHM:
10. Load the source and destination index register with starting and the ending address
respectively.
11. Initialize the counter with the total number of words to be copied.
12. Clear the direction flag for auto incrementing mode of transfer.
13. Use the string manipulation instruction MOVSW with the prefix REP to copy a string
from source to destination.
RESULT:
A string of data words is copied from one location to other.

PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
SOURCE EQU 2000H
DEST EQU 3000H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV SI, SOURCE

MOV DI, DEST


MOV CX, COUNT
CLD
REP

MOVSW
MOV AH, 4CH
INT 21H

CODE ENDS
END START

INPUT:

OUTPUT:

2000

48

3000

48

2001

84

3001

84

2002

67

3002

67

2003

90

3003

90

2004

21

3004

21

4.8086 STRING MANIPULATION SORTING

AIM:
To sort a group of data bytes.

ALGORITHM:

Place all the elements of an array named list (in the consecutive memory locations).

Initialize two counters DX & CX with the total number of elements in the array.

Do the following steps until the counter B reaches 0.

Load the first element in the accumulator

Do the following steps until the counter C reaches 0.

1. Compare the accumulator content with the next element present in the
next memory location. If the accumulator content is smaller go to next
step; otherwise, swap the content of accumulator with the content of
memory location.
2. Increment the memory pointer to point to the next element.
3. Decrement the counter C by 1.
Stop the execution.

RESULT:
A group of data bytes are arranged in ascending order.

PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 25H, 19H, 02H
COUNT EQU 04H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV DX, COUNT-1
LOOP2: MOV CX, DX
MOV SI, OFFSET LIST
AGAIN: MOV AX, [SI]
CMP AX, [SI+2]
JC LOOP1

XCHG [SI +2], AX


XCHG [SI], AX
LOOP1: ADD SI, 02
LOOP AGAIN
DEC DX
JNZ LOOP2
MOV AH, 4CH
INT 21H
CODE ENDS
END START

INPUT:
LIST: 53H, 25H, 19H, 02H

OUTPUT:
LIST: 02H, 19H, 25H, 53H

1(G).ARITHMETIC OPERATIONS USING MASM

AIM: To Implement the programme for arithmetic operations using MASM software

PROCEDURE:

Step1: Switch on computer


Step2: Go to start menu and select run prompt, type cmd
Step3: Then type edit and open MASM window
Step4: Type your programme and save filename.asm
Step5: Go to command prompt and then compile the programme
Step6: Run the programme and see the output in the memory window and register windows

PROGRAMME:

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
OPR1 EQU 98H
OPR2 EQU 49H
SUM DW 01 DUP(00)
SUBT DW 01 DUP(00)
PROD DW 01 DUP(00)
DIVS DW 01 DUP(00)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BL,OPR2
XOR AL,AL

MOV AL,OPR1
ADD AL,BL
DAA
MOV BYTE PTR SUM,AL
JNC MSB0
INC [SUM+1]
MSB0: XOR AL,AL
MOV AL,OPR1
SUB AL,BL
DAS
MOV BYTE PTR SUBT,AL
JNB MSB1
INC [SUBT+1]
MSB1: XOR AL,AL
MOV AL,OPR1
MUL BL
MOV WORD PTR PROD,AX
XOR AH,AH
MOV AL,OPR1
DIV BL
MOV WORD PTR DIVS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT: Thus the MASM programme is executed successfully and output is verified.

8086/Masm Program To Multiply Two Matrices .


DATA SEGMENT
AR1 DB 1H,2H,-3H
AR2 DB 4H,5H,6H
AR3 DB 2H,-1H,3H
BC1 DB 2H,4H,-4H
BC2 DB 3H,-2H,5H
BC3 DB 1H,5H,2H
C DB 9 DUP (?)
L2 DB (?)
L1 DB (?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV BP,0H
MOV L2,3H
LEA SI,AR1
REPEAT2: LEA DI,BC1
MOV L1,3H
REPEAT1: MOV CX,3H
MOV BX,0H
MOV DL,0H
AGAIN: MOV AL,[SI][BX]
IMUL BYTE PTR[DI][BX]
ADD DL,AL
INC BX
LOOP AGAIN
MOV DS:C[BP],DL
INC BP
ADD DI,3H
DEC L1
JNE REPEAT1
ADD SI,3H
DEC L2

JNE REPEAT2
MOV AH,4CH
INT 21H
CODE ENDS
END START

2.f.i Binary to BCD conversion


.MODEL SMALL
.DATA
Binary DB 63h
Ans DB 00h, 00h, 00h
.CODE
MOV AX,@DATA
MOV DS, AX
MOV AX, 00h
MOV AL, Binary
MOV CL, 64h
DIV CL
MOV BCD, AL
MOV AL, AH
MOV AH, 00h
MOV CL, 0Ah
DIV CL
MOV Ans+ 1, AL
MOV Ans+2, AH
OR Ans, 30h
OR Ans+ l,30h
OR Ans+2,30h
MOV AH, 4Ch
INT 21h
END

BCD to Binary conversion


.MODEL SMALL
.DATA
BCD DB 15h
Ans DB 00h
.CODE
MOV AX,@DATA
MOV DS, AX
MOV AL, BCD
AND AL, 0Fh
MOV BL, AL
MOV AL, BCD
AND AL, 0F0h
MOV CL, 04h
ROR AL, CL
MOV CL, 0Ah

MUL CL
ADD AL, BL
MOV Ans, AL
MOV AH, 4Ch
INT 21h
END

Bit manupilation to check if the data is


positive or negative
.MODEL SMALL
.DATA
Msg1 DB ENTERED NUMBER IS POSITIVE. $
Msg2 DB ENTERED NUMBER IS NEGATIVE. $
Input DB ?
.STACK
.CODE
MOV AX, @Data
MOV DS, AX
MOV AL, Input
ROL AL, 01h
JC NEXT
LEA DX, Msg1
MOV AH, 09h
INT 21h
JMP LAST
NEXT: LEA DX, Msg2
MOV AH, 09h
INT 21h
LAST: MOV AH, 4Ch
INT 21h
END

Bit manupilation to check if the data is


odd or even
.MODEL SMALL
.DATA
Msg1 DB ENTERED NUMBER IS ODD. $
Msg2 DB ENTERED NUMBER IS EVEN. $
Input DB ?

.STACK
.CODE
MOV AX, @Data
MOV DS, AX
MOV AL, Input
SAR AL, 01h
JC NEXT
LEA DX, Msg2
MOV AH, 09h
INT 21h
JMP LAST
NEXT: LEA DX, Msg1
MOV AH, 09h
INT 21h
LAST: MOV AH, 4Ch
INT 21h
END

Bit manupilation to count the number of


1s and 0s in given data
.MODEL SMALL
.CODE
MOV CX, 0008h
MOV AL, 24h
MOV BL, 00h
MOV DL, BL
NEXT: SAR AL, 01h
JC DOWN
INC BL
LOOP NEXT
JMP LAST
DOWN: INC DL
LOOP NEXT
LAST: MOV AH, 4Ch
INT 21h
END

7(b) .CUBE OF NUMBER


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE CUBE OF
THE GIVEN NUMBER.

SOFTWARE REQUIRED: MASM 611


ASSEMBLY LANGUAGE PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
NO1 DB 06H
AD1 DW 5000H
DATA ENDS
CODE SEGMENT
START:
ORG 600H
MOV AX, DATA
MOV DS, AX
XOR AX, AX
MOV SI, AD1
MOV CL, NO1
ABC: MOV AL, [SI]
MOV BL, AL
MUL BL
MUL BL
MOV [SI], AL,
INC SI
DEC CL
JNZ ABC
INT 21H
CODE ENDS
END START
RESULT: CUBE OPERATION IS PERFORMED USING MASM SOFTWARE.

7(c).AVERAGE OF NUMBER
AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE CUBE OF
THE GIVEN NUMBER.
SOFTWARE REQUIRED: MASM 611
ASSEMBLY LANGUAGE PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
NO1 DW 7000H
DATA ENDS
CODE SEGMENT
START:
ORG 600H
MOV AX, DATA
MOV DS, AX
XOR CX, CX
MOV AX,[BX]
MOV CL, 06H
DEC CX
ABC: INC SI

ADD AX,[BX]
DEC CX
JNZ ABC
DIV BX
INT 21H
CODE ENDS
END START
RESULT: AVERAGE OF NUMBERS OPERATION IS PERFORMED USING MASM
SOFTWARE.

7(a) SQUARE OF NUMBER


AIM: WRITE AN ASSEMBLY LANGUAGE PROGRAM TO FIND THE SQUARE OF
THE GIVEN NUMBER.
SOFTWARE REQUIRED: MASM 611
ASSEMBLY LANGUAGE PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
NO1 DB 06H
AD1 DW 5000H
DATA ENDS
CODE SEGMENT
START:
ORG 600H
MOV AX, DATA
MOV DS, AX
XOV AX, AX
MOV SI, AD1
MOV CL, NO1
ABC: MOV AL, [SI]
MOV BL, AL
MUL BL
MOV [SI], AL,
INC SI
DEC CL
JNZ ABC
INT 21H
CODE ENDS
END START
RESULT: SQUARING OPERATION IS PERFORMED USING MASM SOFTWARE.

1.b.i Block transfer without overlap


.MODEL SMALL .DATA
Array1 DW 1111h,2222h,3333h,4444h,5555h
Array2 DW 5 DUP (0)
Count DW 0005H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,Array1
LEA DI,Array2
MOV CX,Count
NEXT: MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH,4Ch
INT 21h
END

1.b.ii Block transfer with overlap


.MODEL SMALL .DATA
Array DB 11h,22h,33h,44h,55h
Count DW 0005h
.CODE

MOV AX,@DATA
MOV ES,AX
MOV DS,AX
LEA SI,Array
ADD SI,Count
MOV CX,Count
DEC SI
MOV DI,SI
ADD DI,2h
STD
REP MOVSB
MOV AH,4Ch
INT 21h
END

5.i String transfer


.MODEL SMALL
.DATA
String1 DB 'BMSCE DEPT OF ECE$'
Length EQU ($-String1)
String2 DB LEN DUP (0)
.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CX, Length
CLD
LEA SI, String1
LEA DI, String2
REP MOVSB
MOV AH, 4Ch
INT 21h
END

String reverse
.MODEL SMALL
.DATA
String DB 'BMSCE$'
Length EQU ($-String)
Rvrs DB Length DUP (0)
.CODE
MOV AX,@DATA
MOV DS, AX
MOV ES, AX
MOV CX, Length
LEA SI, String+Length-1
LEA DI, Rvrs
REPEAT: MOV AL, [SI]
MOV [DI], AL
DEC SI
INC DI
LOOP REPEAT
MOV AH, 4Ch
INT 21h
END

Character search in a string


.MODEL SMALL
.DATA
String DB 'BMS COLLEGE'
Length EQU ($-String)
Key DB 'X'
Dis1 DB '-IS PRESENT IN GIVEN STRING$'
Dis2 DB '-IS NOT PRESENT IN GIVEN STRING$'
.CODE
MOV AX,@DATA
MOV DS, AX
MOV ES, AX
MOV DL, Key
MOV AH, 02h
INT 21h
LEA DI, String
MOV AL, Key
MOV CX, Length
REPNE SCASB
JE PRESENT
LEA DX, Dis2
CALL Display
JMP OVER
PRESENT: LEA DX, Dis1
CALL Display
OVER: MOV AH, 4Ch
INT 21h
Display PROC NEAR
MOV AH, 09h
INT 21h
RET
Display ENDP
END

Matrix Keyboard Interfacing


CODE SEGMENT
ASSUME CS:code,DS:code,ES:code,SS:code
CWR EQU 46h
PORTA EQU 40h
PORTB EQU 42h

PORTC EQU 44h


ORG 0400h
MOV AL, 88h ; port a and port c high as output
OUT CWR,AL ; port b and port c low as output
READKEY:
MOV DL,0 ; clear e/dl register
MOV AL,0F0h ; output all one's to pc high
OUT PORTC,AL
LP:
IN AL,PORTC
AND AL,0F0h
CMP AL,0F0h
JNZ LP
CALL FAR PTR ONEMS
KEYCHK:
IN AL,PORTC
AND AL,0F0h
CMP AL,0F0h
JZ KEYCHK ;wait for key press
CALL FAR PTR ONEMS
MOV AL,7Fh
MOV BH,04h
NXTCOLM:
ROL AL, 01h ; scan each column
MOV DH,AL ; and wait for the data
OUT PORTC,AL ; in any of the four
IN AL,PORTC ; rows
AND AL,0F0h
MOV CL,04h
NXTROW:
ROL AL,01h ; scan each column
JNC CODEN ; scan each column
INC DL ; in any of the four
DEC CL ; rows
JNZ NXTROW
MOV AL,DH
DEC BH
JNZ NXTCOLM
JMP KEYCHK

CODEN:
MOV AL,DL
MOV DH,0h
MOV BX,OFFSET LOOKUP+8000h
ADD BX,DX
MOV AL,BYTE PTR[BX]

OUT PORTB,AL
JMP READKEY
ONEMS: ; delay routine
PUSH AX
MOV AL,0FFh
LOP:
DEC AL
JNZ LOP
POP AX
RETF
LOOKUP:
DB 00h,04h,08h,0Ch,01h,05h,09h,0Dh
DB 02h,06h,0Ah,0Eh,03h,07h,0Bh,0Fh
CODE ENDS
END

1. ADDITION OF TWO 8-BIT BCD


DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL

ADD AL,DL
DAA
JNC NEXT
INC CL
NEXT:MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H

INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 97
ENTER SECOND NUMBER : 56
SUM OF TWO 8-BIT NUMBER IS : 153

ENTER FIRST NUMBER : 82


ENTER SECOND NUMBER : 19
SUM OF TWO 8-BIT NUMBER IS : 101

2. SUBTRACTION OF TWO 8-BIT BCD NUMBERS

DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'

MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'


MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
SUB AL,DL
DAS
JNC NEXT
MOV CH,99H
SUB CH,AL
MOV AL,CH
ADD AL,01H
DAA
MOV CL,'-'
NEXT:
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H

INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH

JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START

OUTPUT:
ENTER FIRST NUMBER : 98
ENTER SECOND NUMBER : 54
SUBTRACTION OF TWO 8-BIT NUMBER IS : 044

ENTER FIRST NUMBER : 87


ENTER SECOND NUMBER : 98
SUBTRACTION OF TWO 8-BIT NUMBER IS : -11

23.TRANSPOSE OF THE MATRIX


DATA SEGMENT
M1 DB 'ENTER THE ORDER OF THE MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'TRANSPOSE MATRIX:',0AH,0DH,'$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H

ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
LEA SI,MAT1
CALL READ1
LEA DI,MAT1
LEA SI,MAT2
MOV DH,00H
MOV DL,COL
MOV AH,COL
L3:MOV AL,ROW
MOV BX,DI
L1:MOV CL,[BX]
MOV [SI],CL
ADD BX,DX
INC SI
DEC AL
JNZ L1
INC DI
DEC AH
JNZ L3
LEA SI,MAT2
CALL DISP
MOV AH,4CH
INT 21H

READO PROC NEAR


PUBLIC READO
MOV AH,01H
INT 21H

MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP

READ1 PROC NEAR


BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP

READ PROC NEAR


PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
AND DL,0FH
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H

CMP AL, 0AH


JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MESSAGE M3
BSPCE 0AH
MOV DH,COL
D4:MOV BH,ROW
LOP:MOV CL,04H
MOV DL,[SI]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[SI]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC SI
BSPCE ' '
DEC BH
JNZ LOP
DEC DH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START

OUTPUT :

ENTER THE ORDER OF THE MATRIX : 2 3


ENTER THE ELEMENTS OF THE MATRIX:
11 55 99
22 74 51
TRANSPOSE MATRIX :
11 22
55 74
99 51

3. SUBTRACTION OF TWO 16-BIT BCD NUMBERS


DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 16-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX

MOV CL,' '


MOV AL,BL
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,DH
DAS
MOV BH,AL
JNC NEXT
MOV AX,0000H
SUB AL,BL
ADD DL,01H
DAS
MOV BL,AL
MOV AL,AH
SBB AL,BH
DAS
MOV BH,AL
MOV CL,'-'
NEXT: CALL DISP
MOV AH,4CH
INT 21H

READ PROC NEAR


PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH

JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL

JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START

OUTPUT:
ENTER FIRST NUMBER : 9873
ENTER SECOND NUMBER : 8642
SUBTRACTION OF TWO 8-BIT NUMBER IS : 01231
ENTER FIRST NUMBER : 2431
ENTER SECOND NUMBER : 9247
SUBTRACTION OF TWO 8-BIT NUMBER IS : -6816

40.TO DISPLAY CURRENT TIME.


DATA SEGMENT
MESS1 DB 0AH,0DH,'TIME IS:'0AH,0DH,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
L1:MOV AH,2CH
INT 21H
MOV AL,CH
CALL CONV

CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV AL,CL
CALL CONV
CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV DL,0DH
MOV AH,06H
INT 21H
JMP L1
MOV AH,4CH
INT 21H
DISP PROC NEAR
PUBLIC DISP
MOV BL,AH
MOV DL,AL
ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,BL
ADD DL,30H
MOV AH,06H
INT 21H
RET
DISP ENDP
CONV PROC NEAR
PUBLIC CONV
MOV AH,00H
MOV BH,0AH
DIV BH
RET

CONV ENDP
CODE ENDS
END START

OUTPUT:
THE CURRENT TIME IS: 23:37:23.85

41.TO DISPLAY CURRENT DATE.


DATA SEGMENT
MESS1 DB 0AH,0DH,'THE CURRENT DATE IS:'$'
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV AH,2AH
INT 21H
MOV SI,CX
MOV BL,DH
MOV BH,DL
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
MOV BL,BH
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
XOR DX,DX
MOV AX,SI
MOV CX,0064H
DIV CX
MOV DH,DL
MOV BL,AL
CALL DISP
MOV BL,DH
MOV AH,4CH
INT 21H
CONV PROC NEAR
PUBLIC CONV
MOV CL,04H
XOR AH,AH

MOV AL,BL
MOV BL,0AH
DIV BL
SHL AL,CL
ADD AL,AH
DAA
MOV BL,AL
RET
CONV ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
CALL CONV
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START

OUTPUT:
THE CURRENT DATE IS: MON 07/11/2011

14. AVERAGE OF 8-BIT NUMBERS (BCD)

DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$'
MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$'
MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV DH,CH
MOV BH,00H
N1:MOV AL,CH
SUB AL,01H
DAS
MOV CH,AL
JZ N2
MOV DL,','
MOV AH,06H
INT 21H
CALL READ
MOV AL,BL
ADD AL,DL
DAA
MOV BL,AL

JNC N3
MOV AL,BH
ADD AL,01H
DAA
MOV BH,AL
N3:JMP N1
N2:MOV CH,02H
MOV DL,DH
MOV DH,00H
MOV CL,00H
N4: MOV AX,BX
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,00H
DAS
MOV BH,AL
MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
CMP BX,DX
JAE N4
DEC CH
JZ N5
MOV QUO,CL
MOV CL,00H
MOV BH,BL
JMP N4
N5: MOV BL,QUO
MOV BH,CL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H

MOV CL,04H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LOP:MOV CL,04H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ RT
CMP CH,01H
JNZ L3
MOV DL,'.'
MOV AH,06H
INT 21H
L3:MOV BL,BH
JMP LOP
RT:RET

DISP ENDP
CODE ENDS
END START
OUPTUT:
ENTER THE LIMIT: 05
ENTER THE NUMBERS: 34,45,56,67,78
THE AVERAGE IS : 56

19.ADDITION OF TWO MATRICES (HEXADECIMAL)


DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$' M4 DB
0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$' M5 DB
0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H

INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,00H
MOV DL,[SI]
ADD DL,[DI]
JNC L5
INC DH
L5:MOV [BX],DH
INC BX
MOV [BX],DL
INC DI

INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H

READO PROC NEAR


PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
PUBLIC READ1
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH

BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
MOV CL,04H
MOV DL,[BX]

SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START

OUTPUT 1:

ENTER THE ORDER OF FIRST MATRIX : 2 2


ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
11 11
11 11
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
SUM OF TWO MATRICES:
013 013
014 014

OUTPUT 2:
ENTER THE ORDER OF FIRST MATRIX : 2 3
ENTER THE ORDER OF SECOND MATRIX : 2 2
MATRICES CANNOT BE ADDED

4.(A)TRAFFIC SIGNAL CONTROLLER USING 8255 PPI

AIM: To Implement Traffic signal controller using 8255 PPI

Apparatus:
1.8086 trainer kit
2. Traffic signal controller board

3.power connection
Procedure:
Step 1: Start the process
Step 2: Connect the traffic controller interface kit along with the system using SMPS
Step 3: Program the operation in system by program-> Assessories-> Communication->
Hyper Terminals-> Enter ok
Step 4: Enter the GND 1 serial in 8086 kit
Step 5:Enter the 1205 for setup motor
Step 6: Stop the program

PROGRAMME:
MEMORY

LABEL

MNEMONIC

OPCODE

0100

STRT:JMP SKIP DATA

EB,01,90

0103

SKIP DATA:MOV AX,11FF

B8,FF

STRT1:MOV SP,AX

8B,E0

PUSH CS

BE

POP DS

1F

NOP

90

NOP

90

NOP

90

MOV AL,80

B0,80

MOV DX,8006

BA,80,06

OUT DX,AL

EE

START:MOV AL,61H

B0,61

ADDRESS

COMMENTS

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,68H

B0,68

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,86H

B0,86

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,60H

B0,60

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,48H

B0,48

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,64H

B0,64

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,58H

B0,58

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

CALL DELAY1

E8,01,27

MOV AL,60H

B0,60

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,48H

B0,48

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,62H

B0,62

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

CALL DELAY2

E8,01,0B

MOV AL,60H

B0,60

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,61H

B0,61

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,68H

B0,68

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

CALL DELAY3

E8,00,F6

MOV AL,41H

B0,41

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,06H

B0,06

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,49H

B0,49

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,26H

B0,26

MOV DX,8004

BA,80,04

OUT DX,AL

EE

CALL DELAY1

E8,00,E2

MOV AL,41H

B0,41

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,06H

B0,06

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,51H

B0,51

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,46H

B0,46

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY2

E8,00,C0

MOV AL,41H

B0,41

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,06H

B0,06

MOV DX,8004

BA,80,04

OUT DX,AL

EE

MOV AL,61H

B0,61

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,86

B0,86

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY2

E8,00,AS

MOV AL,60H

B0,60

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,82H

B0,82

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,62H

B0,62

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,92H

B0,92

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY1

E8,00,91

MOV AL,60H

B0,60

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,82H

B0,82

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,64H

B0,64

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,8AH

B0,8A

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY2

E8,00,6F

MOV AL,60H

B0,60

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,82H

B0,82

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,68H

B0,68

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,86H

B0,86

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY2

E8,00,54

MOV AL,21H

B0,21

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,28H

B0,28

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,29H

B0,29

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,87H

B0,87

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

CALL DELAY1

E8,00,40

MOV AL,21H

B0,21

MOV DX,8002H

BA,80,02

OUT DX,AL

EE

MOV AL,86H

B0,86

MOV DX,8004H

BA,80,04

OUT DX,AL

EE

MOV AL,0A1

B0,A1

MOV DX,8000

BA,80,00

OUT DX,AL

EE

MOV AL,0A8

B0,A8

MOV DX,8002

BA,80,02

OUT DX,AL

EE

CALL DELAY2

E8,00,1E

MOV AL,21H

B0,21

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,28H

B0,28

MOV DX,8002

BA,80,02

OUT DX,AL

EE

MOV AL,61H

B0,61

MOV DX,8000H

BA,80,00

OUT DX,AL

EE

MOV AL,68H

B0,68

MOV DX,8002

BA,80,02

OUT DX,AL

EE

JMP START

E9,FE,B3

CALL DELAY2

CD,AA

INT 0AA

CD,AA

INT OAA

CD,AA

RET

C3

DELAY1:CALL DELAY2

E8,FF,F6

CALL DELAY2

E8,FF,F3

CALL DELAY2

E8,FF,F0

CALL DELAY2

E8,FF,ED

CALL DELAY2

E8,FF,EA

RET

C3

RESULT : Thus the interface was successfully executed and the output has been verified

4(B). STEPPER MOTOR SPEED CONTROLLER USING8255 PPI

AIM: To Implement the programme for Stepper motor controller using 8255 PPI to interface 8086

Apparatus:
1.8086 trainer kit
2. Stepper motor

PROCEDURE:

Step1: Start the programme


Step2: Connect the kit to the system.The kit connects one separate keyboard
Step3: After connecting the kit ,in kit press R then enter,it shows the kit name in monitor
Step4: Press I write then E038 start & ending address given
Step5: Then menu has transfer->send data
Step6: See the output in kit through the monitor
Step7: Stop the programme

PROGRAMME:
MEMORY

LABEL

MNEMONIC

OPCODE

0100

MOV AX,0000

B8,00,00

0103

MOV ES,AX

8E,C0

0105

MOV SS,AX

8E,D0

0107

MOV AX,11F0

B8,11,F0

010A

MOV SP,AX

89,C4

010C

PUSH CS

BE

010D

POP DS

1F

010E

MOV AL,80

B0,80

0110

MOV DX,CR 55

BA,80,06

0113

OUT DX,AL

EE

0114

MOV AL,00

B0,00

ADDRESS

COMMENTS

0116

MOV DX,OFFSET CODE

BA,01,C0

0119

OUT DX,AL

EE

011A

MOV DX,OFFSET CODE

BA,01,C0

011D

MOV CL,40

B1,40

011F

MOV CH,80

B5,80

0121

MOV BH,10

B7,10

0123

SPEED: MOV BL,08

B3,08

0125

BACK: CALL STPR

E8,00,58

0128

INT 0A AH

CD,AA

012A

DEC BL

FE,CB

012C

JNZ BACK

75,F7

012E

DEC CH

FE,CD

0130

DEC BH

FE,CF

0132

JNZ SPEED

75,EF

0134

MOV BL,11

B3,11

0136

BACK1: CALL STPR

E8,00,47

0139

INT 0A AH

CD,AA

013B

DEC BL

FE,CB

013D

JNZ BACK1

75,F7

013F

MOV BH,10

B7,10

0141

MOV BL,08

B3,08

0143

CALL STPR

E8,00,3A,BACK2

0146

INT OS 5H

FD,55

0148

DEC BL

FE,CB

014A

JNZ BACK2

75,E7

014C

INC CH

FE,C5

014E

DEC BH

FE,CF

0150

JNZ SPDCONT

75,EF

0152

MOV AL,00H

B0,00

0154

MOV DX,PORTA

BA,80,00

0157

OUT DX,AL

EE

0158

MOV AH,08

B4,08

015A

INT OA 1H

CD,A1

015C

CMP AL,1B

3C,1B

015E

JNZ STRT

75,A0

0160

INT OA 3H

CD,A3

0180

ORG 01 80

----

0180

STPR:PUSH BX

53

0181

NOP

90

0182

MOV BX,BX

89,D3

0184

MOV AL,[BX]

8A,07

0186

MOV DX,PORTA

BA,80,00

0189

OUT DX,AL

EE

018A

NOP

90

018B

MOV AL,[0175]

A0,01,75

018E

CMP AL,01

3C,01

0190

JNZ ANTICK

0F

0192

INC BX

43

0193

MOV AL,[BX]

8A,07

0195

CMP AL,00

3C,00

0197

JNZ NEXT

75,03

0199

SUB BX,08

EB,08

019C

NEXT: MOV DX,BX

89,DA

019E

NOP

90

019F

POP BX

5B

01A0

RET

C3

01A1

ANTICK:DEC BX

4B

01A2

MOV AL,[BX]

8A,07

01A4

CMP AL,00

BC,00

01A6

JNZ NEXT

75,FH

01A8

ADD BX,08

83,C3,08

01AB

JMP NEXT

EB,FF

01BF

DUM: DB 00

00

01C0

CODE:DB 00H 02H 06H


04H 0CH

00,02,06,04,0C

01C5

DB08H 09H 01H 03H 00H

08,09,01,03,00

RESULT : Thus the interface was successfully executed and the output has been verified

4.(C)1. ADC INTERFACE

AIM: To interface an ADC to 8086

Apparatus:
8086 trainer kit
ADC kit

PROCEDURE:

Step1: Start the process


Step2: Connect 8086 with ADC connection
Step3: Give the required opcode for the programme in the memory address 1000
Step4: Give the input voltage and press reset key in the converters
Step5: compile the Programme
Step6: Execute the programme and view the result is the output memory
Step7: Stop the process

PROGRAMME:

MEMORY

LABEL

MNEMONIC

OPCODE

1000

MOV AL,03

B0,03

1002

OUT C8,AL

E6,C8

1004

MOV AL,23

B0,23

1006

OUT C8,AL

E6,C8

1008

MOV AL,03

B0,03

100A

OUT C8,AL

E6,C8

100C

MOV AL,01

B0,01

100E

OUT 00,AL

E6,00

1010

MOV AL,00

B0,00

1012

OUT D0,AL

E6,00

1014

IN AL,E6

E4,E6

ADDRESS

COMMENTS

1016

AND AL,01

3C,01

1018

CMP AL,01

3C,01

101A

JNZ LOOP

75,F8

101C

IN AL,C0

E4,C0

101E

MOV BX,1100

BB,00,11

1021

MOV [BX],AL

88,07,F4

1023

INT

CD,A5

RESULT: Thus the above program has been successfully executed and the output is verified.

4(C) 2.DAC INTERFACE(TRIANGULAR WAVEFORM)

AIM: To Perform DAC using 8086 and verify the output waveform

Apparatus:
8086 trainer kit
DAC kit

PROCEDURE:
Step1: Start the process
Step2: Connect 8086 with DAC connection
Step3: Give the required opcode for the programme in the memory address 1000
Step4: Give the input voltage and press reset key in the converters
Step5: compile the Programme
Step6: Execute the programme and view the result is the output memory
Step7: Stop the process

Program:
MEMORY

LABEL

MNEMONIC

OPCODE

L1

MOV BL,0D

B3,0D

1002

MOV AL,BL

88,DB

1004

OUT DAC AL

E6,C0

1006

INC BL

FE,C3

1008

JNZ L1

75,FA

MOV AL,BL

88,DB

100C

OUT DAC,AL

E6,C0

100E

DEC BL

FE,CB

1010

JNZ L2

75,F8

1012

JMP START

EB,FA

ADDRESS
1000

100A

L2

COMMENTS

RESULT: Thus the above program has been successfully executed and the output is verified.

4(C) 3.DAC INTERFACE(SAWTOOTH WAVEFORM)

AIM: To Perform DAC using 8086 and verify the output waveform

Apparatus:
8086 trainer kit
DAC kit

PROCEDURE:
Step1: Start the process
Step2: Connect 8086 with DAC connection
Step3: Give the required opcode for the programme in the memory address 1000
Step4: Give the input voltage and press reset key in the converters
Step5: compile the Programme
Step6: Execute the programme and view the result is the output memory
Step7: Stop the process

Program:
MEMORY
ADDRESS

LABEL

MNEMONIC

OPCODE

1000

L1

MOV AL,00

B0,00

1002

OUT DAC AL

E6,C0

1004

INC AL

FE,C0

1006

JNZ L1

75,FA

1008

JMP START

EB,F6

COMMENTS

RESULT: Thus the above program has been successfully executed and the output is verified.

4.(D) WAVEFORM GENERATION USING 8253 TIMERS

AIM: To implement programme for Waveform Generation using 8253 Timer.

Apparatus :
8086 trainer kit
8253 counter
Power supply

Procedure:
Step 1: Start the program
Step 2: Connect the 8086 trainer kit and generate the waveform
Step 3: Enter OPCODE in the memory address 0100
Step 4: Memory segment for this 12 DC
Step 5: Compile the program
Step 6: Check out the add and even counter
Step 7: Stop the program

THEORY: The programmable timer device 8253 contains 3 independent 16 bit counters, each with a
maximum count rate of 2.6mhz

It is thus possible to generate three totally independent delays or maximum three independent
counters simultaneously all the 3 counters may be independently controlled by programming the 3
word registers
PROGRAM:

MEMORY

LABEL

MNEMONIC

OPCODE

0100

START

EB,01,90

0103

MOV AX,10FF

B8,FF,10

0106

MOV SP,AX

8B,E0

0108

PUSH CS

0E

0109

POP DS

1F

010A

NOP

90

010B

NOP

90

ADDRESS

COMMENTS

010C

NOP

90

010D

MOV AL,96

B0,96

010F

MOV DX,01E6

BA,E6,01

0112

OUT DX,AL

EE

0113

MOV AL,08

B0,08

0115

MOV DX,01E4

BA,E4,01

0118

OUT DX,AL

EF

0119

MOV DX,01E6

BA,E6,01

011C

IN AL,DX

EC

011D

IN AL,DX

EC

011E

UP: MOV DX,01E4

BA,E4,01

0121

IN AL,DX

EC

0122

JMP UP

EB,FA

OUTPUT: ODD COUNT

STEPS

DATA

OUT2

OUT1

OUT0

A1

A0

RD

WR

CS

STEP1

96

----

-----

-----

-----

STEP2

05

-----

----

----

STEP3

FF

----

-----

---

STEP4

FF

----

----

---

STEP5

05

----

----

---

STEP6

04

----

----

---

STEP7

02

----

----

---

STEP8

05

----

----

---

STEP9

02

----

----

---

STEP10

05

----

----

---

CONNECTIONS: Make a connection to pin D to out2, then make a connection from clk/src to clk2

Memory segment -------- 12DC


Memory segment -------- 0100

FOR EVEN COUNT:

STEPS

DATA
BUS

OUT2

OUT1

OUT0

A1

A0

WR

RD

CS

START

96

---

---

---

---

STEP1

08

---

---

---

STEP2

FF

---

---

---

STEP3

FF

---

---

---

STEP4

08

---

---

---

STEP5

06

---

---

---

RESULT: Thus the above program has been successfully executed and the output is verified.

4.(E) DC MOTOR SPEED CONTROLLER

AIM: To Implement the program for DC motor speed controller using 8253

Apparatus:
1.8086 trainer kit
2. DC motor

PROCEDURE:

Step1: Start the program


Step2: Connect the kit to the system.The kit connects one separate keyboard
Step3: After connecting the kit ,in kit press R then enter,it shows the kit name in monitor
Step4: Press I write then E038 start & ending address given
Step5: Then menu has transfer->send data
Step6: See the output in kit through the monitor
Step7: Stop the program

PROGRAMME:

MEMORY

LABEL

MNEMONIC

OPCODE

STRT:JMP SKIP-DATA

EB,01,90

SKIP-DATA:MOV AX,11FF

EB,11,FF

STRT1:MOV SP,AX

3B,E0

PUSH CS

BE

POP DS

1F

NOP

90

NOP

90

NOP

90

MOV AL,80

B0,80

MOV DX,8006

BA,80,06

OUT DX,AL

EE

ADDRESS
0100

COMMENTS

START:INT 0AC

CD,AC

MOV BX,OFFSET DIR

BB,01,C9,R

INT 0AF

CD,AF

MOV AH,08

B4,08

INT 0A1

CD,A1

MOV BL,AL

8A,D8

MOV CL,46

B1,46

CMP AL,CL

3A,C1

JNE RVD

75,0A

MOV AL,01

B0,01

MOV DI,OFFSET DIRFR

BF,02,30,R

MOV [DI[,AL

88,05

JMP DISPLAY

EB,1C,90

RVD:MOV AL,BL

8A,C3

MOV CL,52

B1,52

CMP AL,CL

3A,C1

JE L1

74,0C

CMP AL,1B

3C,1B

JNE START

75,D7

MOV AL,80

B0,80

MOV DX,8006

BA,80,06

OUT DX,AL

EF

INT 0A3

CD,A3

L1:MOV AL,02

B0,02

MOV DI,OFFSET DIRFR

BF,02,30,R

MOV [DI],AL

88,05

DISPLAY: INT 0AC

CD,AC

MOV BX,OFFSET SPEED

BB,01,D1,R

INT 0AF

CD,AF

MOV AL,02

B0,02

MOV AH,0A

B4,0A

INT 0AD

CD,AD

AND AX,4000

25,40,00

CMP AX,4000

3D,40,00

JNE DISPLAY

75,EB

PUSH DX

52

MOV AL,DL

8A,C2

MOV CL,50

B1,50

CMP AL,CL

3A,C1

JC INVERT

72,11

MOV DI,OFFSET DIRFR

BF,02,30,R

MOV BX,[DI]

8B,1D

OR BL,08

80,CB,08

MOV AL,BL

8A,C3

MOV DX,8004

BA,80,04

OUT DX,AL

EE

JMP WAVE

E8,0C,90

INVERT:MOV DI,OFFSET DIRFR

BF,02,30,R

MOV BX,[DI]

8B,1D

MOV AL,BL

8A,C3

MOV DX,8004

BA,80,04

OUT DX,AL

EE

WAVE:MOV AL,36

B0,3

MOV DX,8C07

BA,8C,07

OUT DX,AL

EE

POP DX

5A

MOV AL,00

B0,00

CMP AL,DL

3A,C2

JNE 0D2

75,05

MOV AL,90

B0,90

JMP MOD1

EB,03,90

MOD2:MOV AL,94

B0,94

MOD1:PUSH DX

52

MOV DX,8C07

BA,8C,07

OUT DX,AL

EE

MOV BX,OFFSET TABLE

BB,01,D8,R

POP DX

5A

BACK:MOV AL,CS[BX]

2E,8A,07

CMP AL,DL

3A,C2

JC NEXT

72,08

JZ NEXT

74,06

INC BX

43

INC BX

43

INC BX

43

INC BX

43

JMP BACK

EB,F1

NEXT:INC BX

43

MOV AL,CS[BX]

2E,8A,07

MOV DX,8C01

BA,8C,01

OUT DX,AL

EE

INC BX

43

MOV AL,CS[BX]

2E,8A,07

OUT DX,AL

EE

INC BX

43

MOV AL.CS[BX]

2E,8A,07

MOV DX,8C05

BA,8C,05

OUT DX,AL

EE

JMP START

E9,01,13,R

DIR: DB
44H,49H,52H,20H,46H,2FH,52
H,03H

44H,49H,52H,20H,46H,2FH,5
2H,03H

SPEED:DB
53H,50H,45H,45H,44H,20H,03
H

53H,50H,45H,45H,44H,20H,0
3H

TABLE:DB
98H,9BH,00H,30H,96H

98H,9BH,00H,30H,96H

DB
0FAH,00H,1CH,94H,77H,01H

0FAH,00H,1CH,94H,77H,01H

DB:13H,92H,0F4H,01H,0EH,89

13H,92H,0F4H,01H,0EH,89H,

H,80H,02H,0BH

80H,02H,0BH

DB
86H,0E8H,03H,07H,83H,65H,
86H,0E8H,03H,07H,83H,65H,04 04H,06H,80H
H,06H,80H
DB
0E2H,04H,05H,75H,0D0H,06H,
04H,66H,0D0H

0E2H,04H,05H,75H,0D0H,06
H,04H,66H,0D0H

DB
08H,03H,50H,0B8H,0BH,02H,3
4H,0D0H,08H,03H

08H,03H,50H,0B8H,0BH,02H
,34H,0D0H,08H,03H

DB
25H,0D0H,06H,04H,20H,0E2H,
04H,05H,17H,65H,04H

25H,0D0H,06H,04H,20H,0E2
H,04H,05H,17H,65H,04H

DB
06H,14H,0E8H,03H,07H,11H,
06H,14H,0E8H,03H,07H,11H,80 80H,02H,0BH,08H
H,02H,0BH,08H
DB
0F4H,01H,0EH,06H,77H,01H,13
H,04H,0FAH,00H,1CH

0F4H,01H,0EH,06H,77H,01H,
13H,04H,0FAH,00H,1CH

DB
02H,9BH,00H,30H,00H,9BH,00
H,50H

02H,9BH,00H,30H,00H,9BH,
00H,50H

RESULT : Thus the interface was successfully executed and the output has been verified

4.(F) KEYBOARD DISPLAY INTERFACE

AIM: To perform the program for keyboard display interfaces and drives the output

Apparatus required:
1.8086 microprocessor trainer kit
2.8279 keyboard display interface

Procedure:

Step1: Connect the microprocessor 8086 trainer kit with SMPS


Step2: First reset and press S (substitute) to type the starting address
Step3: Then type the opcode and press ESC
Step4: Then press S followed by the loading address
Step5: Then press enter and get the input data
Step6: Then press ESC and then GO and execute restore and finally
Substitute
Step7: Store it in the output address and get the output data

Theory:
1. The INTEL 8279 is a general purpose keyboard/display controller that simultaneously drives the
display of a system and interfaces a keyboard with the CPU leaving it free for its routine task
2. The keyboard display interface scans the keyboard to identify if any key has been pressed and
serves the code of the pressed key to the CPU
3. It also transmits the data received from the CPU to the display device. Both of these functions are
performed by the controller bin respective fashion without involving the CPU
4. The keyboard is interfaced either in the interrupt or parallel mode. In Interrupt mode the processor
is requested service only if any key is pressed, otherwise the CPU periodically reads an internal flag of
8279 to check for a key press

Procedure:
Step1: Connect the microprocessor 8086 trainer kit with SMPS
Step2: First reset and press S (substitute) to type the starting address
Step3: Then type the opcode and press ESC
Step4: Then press S followed by the loading address
Step5: Then press enter and get the input data
Step6: Then press ESC and then GO and execute restore and finally

Substitute
Step7: Store it in the output address and get the output data

PROGRAMME:

MEMORY

LABEL

MNEMONICS

OPCODE

0100

START

EB,01,90

0103

MOV AX,10FF

B8,10,FF

0106

MOV SP,AX

8B,E0

0108

PUSH CS

0E

0109

POP AX

58

010A

MOV DS,AX

8E,D8

010C

NOP

90

010D

NOP

90

010E

NOP

90

010F

START:

010F

MOV AL,18H

B0,18

0111

MOV DX,01E2H

BA,01,E2

0114

OUT DX,AL

EE

0115

MOV AL,DF

B0,DF

0117

OUT DX,AL

EE

0118

MOV AL,8F

B0,8F

011A

OUT DX,AL

EE

011B

MOV CL,0F

B1,0F

ADDRESS

COMMENTS

011D

CALL DISPLAY

E8,02,00

SUBPROGRAMME:

0120

JMP START

EB,ED

0122

DISPLAY PROC NEAR

FB,ED

0122

MOV BX,OFFSET DATA

BB,01,31 R

0125

NEXT

0125

MOV AL,[BX]

8A,07

0127

MOV DX,01E0

BA,O1,E0

012A

OUT DX,AL

EE

012B

INC BX

43

012C

DEC CL

FE,C9

012E

JNS NEXT

79,F5

0130

RET

C3

0131

DISPLAY ENDP

0C0,0F9,0A4,0B0,

DATA:DB
99,92,82,0F8,80,90
0C0,0F9,0A4,0B0,99,92,82,0F8,80,90
013B

DB 88,83,0C6,0A1,86,8E

88,83,0C6,0A1,86,8E

OUTPUT:

STEP

DATA
BUS

DISPLAY

WR

RD

CS

A0

INT

START

18

------

---

---

STEP 1

DF

------

---

---

STEP 2

8F

BLOCK

---

---

STEP 3

C0

BLOCK

---

---

---

STEP 4

F9

---

---

---

STEP 5

A4

---

---

---

STEP 6

B0

---

---

---

---

---

STEP 7

99

---

---

---

STEP 8

92

---

---

---

STEP 9

82

---

---

---

STEP 10

E2

---

---

---

STEP 11

80

---

---

---

STEP 12

90

---

---

---

STEP 13

88

---

---

---

STEP 14

83

---

---

---

STEP 15

C6

---

---

---

STEP 16

A1

---

---

---

STEP 17

86

---

---

---

STEP 18

8E

---

---

---

STEP 19

18

---

---

---

RESULT : The keyboard interface was successfully executed and the output has been verified

EXP.NO: 7

DATE:

(a)Interfacing Programmable Keyboard and Display Controller- 8279


( With 8086)
AIM: To display the rolling message in the display.

APPARATUS REQUIRED:

(i)8086 Microprocessor kit (ii)Power supply (iii) interfacing board.

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.

INTERFACE - BLOCK DIAGRAM:

MICROPROCESSOR

K/DISPLAY 8279

KIT 8086

INTERFACE BOARD
CABLE

ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b) USINGH 8051


ADDRESS

MNEMONICS

OP-CODE

4000

MOV
DPTR,#FFC2

90 FF C2

4003

MOV R0,#00

78 00

4005

MOV R1,#44

79 44

4007

MOV A,#10

74 10

4009

MOVX@DPTR,A F0

400A

MOV A,#CC

400C

MOVX@DPTR,A F0

400D

MOV A,#90

401F

MOVX@DPTR,A F0

4010

LABEL

LOOP

74 CC

74 90

MOV DPH,R1

89 83

4012

MOV DPL,R0

88 82

4014

MOVX@DPTR

E0

4015

MOV
DPTR,FFC0

90 FF C0

COMMANDS

4018

MOVX@DPTR,A F0

4019

LCALL DELAY

12 45 00

401C

INC R0

08

401D

CJNE
R0,#0F,LOOP

B8 0F F0

401A

LJMP START

02 81 00

MNEMONICS

OP-CODE

COMMANDS

MOV R4,#A0

7C A0

4500

ORG 4500
ADDRESS

LABEL

4500
4502

LOOP2

MOV R5,#FF

7D FF

4502

4504

LOOP1

NOP

00

4504

4505

DJNZ
R5,LOOP1

DD FD

4505

4507

DJNZ
R4,LOOP2

DC F9

4507

4509

RET

22

4509

LOOK-UP TABLE
ADDRESS

DATA

4400

FF,FF,FF,FF

4404

FF,FF,FF,FF

4408

68,6C,68,FF

440C

FF,38,FF,FF

The above program initializes 8279 in scanned keyboard 2 key lock-out. Press two
keys simultaneously and verify that only one key is accepted by 8279

RESULT: Thus the rolling message is displayed using 8279 interface kit.

EXP. NO: 8

DATE:

SERIAL COMMUNICATION INTERFACING USART 8251

AIM: To study interfacing technique of 8251 (USART) with microprocessor 8086


and write an 8086 ALP to transmit and receive data between two serial ports
with RS-232 cable.

APPARATUS REQUIRED:
(i)8086 kit with keyboard (2 Nos),
(ii) RS232 cable.

THEORY:

The 8251 is used as a peripheral device for serial communication and


isprogrammed by the CPU to operate using virtually any serial data transmission
technique.The USART accepts data characters from the CPU in parallel format and
then converts theminto a continuous serial data stream for transmission.
Simultaneously, it can receive serialdata streams and convert them into parallel
data characters for the CPU. The CPU canreadthe status of the USART at any time.
These include data transmission errors and controlsignals. The control signals
define the complete functional definition of the 8251. Control
words should be written into the control register of 8251.

These control words are split intotwo formats:


1) Mode instruction word &
2) Command instruction word.
Status word formats used to examine the error during functional operation.

Command instruction:

TRANSMITTER PROGRAM
ADDRESS

MNEMONICS

OP-CODE

COMMANDS

1000

MOV AL,36

BO 36

MOVE THE VALUE


TO
ACCUMULATOR

1002

OUT CE,AL

E6 CE

SEND DATA TO
OUTPUT PORT

1004

MOV AL,10

B0 10

MOVE THE VALUE


TO
ACCUMULATOR

1006

OUT C8,AL

E6 C8

SEND DATA TO
OUTPUT PORT

1008

MOV AL,00

B0 00

MOVE THE VALUE

TO
ACCUMULATOR
100A

OUT C8,AL

E6 C8

SEND DATA TO
OUTPUT PORT

100C

MOV AL,4E

B0 4E

MOVE THE VALUE


TO
ACCUMULATOR

100E

OUT C2,AL

E6 C2

SEND DATA TO
OUTPUT PORT

1010

MOV AL,37

B0 37

MOVE THE VALUE


TO
ACCUMULATOR

1012

OUT C2,AL

E6 C2

SEND DATA TO
OUTPUT PORT

1014

MOV AL,AA

BO AA

MOVE THE VALUE


TO
ACCUMULATOR

1016

OUT CO,AL

E6 CO

SEND DATA TO
OUTPUT PORT

1018

INT 02

CD 02

INTERUPT

RECEIVER PROGRAM
ADDRESS

MNEMONICS

OP-CODE

COMMANDS

1200

IN AL,C0

E4 C0

INTERUPT

1202

MOV BX[1250]

BB 50 12

MOVE THE VALUE


TO ADDRESS

1205

MOV BX,AL

88 07

MOVE
ACCUMULATOR
DATA TO BX

1207

INT 02

CD 02

INTERUPT

RESULT: Thus ALP for serial data communication using USART 8251 is
written and the equivalent ASCII 41 for character A is been tx&rx ed

EXP.NO:9

DATE:

(a) STEPPER MOTOR INTERFACING

AIM: To write an assembly language program in 8086 to rotate the motor at


different speeds in clock wise and anti-clock directions .

APPARATUS REQUIRED:
1. Microprocessor kit 8086

1No

2. Power Supply +5 V, dc,+12 V dc

1No

3. Stepper Motor Interface board

1No

4. Stepper Motor

1No

PROBLEM STATEMENT:

Write a code for achieving a specific angle of rotation in a given time and
particular number of rotations in a specific time.

THEORY:
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a stepwise
manner from one equilibrium position to the next. Two-phase scheme: Any two
adjacent stator windings are energized. There are two magnetic fields active in
quadrature and none of the rotor pole faces can be in direct alignment with the

stator poles. A partial but symmetric alignment of the rotor poles is of course
possible.

ALGORITHM:
For running stepper motor clockwise and anticlockwise directions
(i) Get the first data from the lookup table.
(ii) Initialize the counter and move data into accumulator.
(iii) Drive the stepper motor circuitry and introduce delay
(iv) Decrement the counter is not zero repeat from step(iii)
(v) Repeat the above procedure both for backward and forward directions.

SWITCHING SEQUENCE OF STEPPER MOTOR:


MEMORY LOCATION A1 A2 B1 B2

HEX CODE

4500

1 0 0 0

09 H

4501

0 1 0 1

05 H

4502

0 1 1 0

06 H

4503

1 0 1 0

0A H

INTERFACE - BLOCK DIAGRAM:


MICROPROCESSOR
KIT 8086

STEPPER
CABLE

MOTOR
INTERFACE BOARD

PROGRAM:

A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED

MEMORY
ADDRESS

LABEL

MNEMONICS OPCODE

1000

START

MOV
D1 BF,14,10
offset table
(1014)

1003

1005

MOV CL, 04

LOOP1

B1,04

MOV AL,[D1] 8A,05

1007

OUT
PORT1,AL

E6,C0

1009

MOV
DX,1010

BA,10,10

DEC DX

4A

100C

DELAY

COMMENTS

100D

JNZ DELAY

75,FD

100F

INC D1

47

1010

LOOP LOOP1 E2,F3

1012

JMP START

EB,EC

DB

09,05,06,0A

1014

TABLE

note: for anti-clock direction only change the order of the input data.

RESULT: Thus the assembly language program for rotating stepper motor in
Clockwise and anti-clock directions were written and verified.
(b)INTERFACING AND PROGRAMMING OF DC MOTOR SPEED
CONTROL

AIM: To interface and control the speed of a DC motor using 8253 and 8086
microprocessor kit.

APPARATUS REQUIRED:
Apparatus

Specification/model

Quantity

Microcontroller kit

LAB tech LED

DCmotor
board

interface

Power cable

DMM

ALGORITHM:
1. Initialize 8253 counter 0 in mode 3 (square wave PWM). It gives
frequency input toF to V Converter for the desired speed.
2. Load counter 0 with count proportional to the speed required.
3. Give input frequency for the speed required at 8200H in hexadecimal.
4. Execute the program.
INTERFACE - BLOCK DIAGRAM:
DC MOTOR
INTERFACE BOARD

MICROPROCESSOR
KIT 8086

CABLE

FLOW CHART:

PROGRAM:

Memory
Address
8100
8101
8102

8110

Opcode

Label

Mnemonics

Operand

MOV

AL,00/FF

OUT

PORT

HLT

Comment

stop

RESULT: The ALP is written to interface and control the speed of a DC motor
using 8086 Successfully.

INTERFACING OF TRAFFIC LIGHT CONTROL


AIM: - write a program to interface a traffic light control with 8086.
APPARATUS REQUIRED:1. 8086 microprocessor kit.
2. Traffic light interfacing cord.
3. Rs-232.
4. Power supply.
5. 26-pin bus.
6. Talk software.
7. Connecting wires.
THEORY:Traffic light controller interface module is designed to simulate the function of four way
Traffic light controller. Combinations of red, amber and green LEDs are provided to
indicate
halt, wait and go signals for vehicles. Combinations of red, amber and green LEDs are
provided
for pedestrian crossing. 36 LEDs are arranged in the from of an intersection. A typical
junction
is represented on the PCB with comprehensive legend printing.
At the left corner of each road, a group of five LEDs (red, amber and 3 green) are
arranged in the from of a T- section to control the traffic of that road. Each road is
named north
(N), south(S), east (E) and west (w). To minimize the hardware pedestrians indicator
LEDs both
red and green are connected to same port lines (pc4 to pc7) with red inverted. Red
LEDs L10 to
L28 are connected to port lines PC2 & PC3 while L1 & L19are connected to lines PC0 &
PC1
after inversion. All other LEDs (amber and green) are connected to port A & B.
OPERATION:-

The basic operation of the interface is explained with the help of the enclosed program.
The user can write program to simulate the traffic in any desired fashion. The enclosed
program
assumes no entry of vehicles from roar north to west, from road east to south. At the
beginning of
the program all red LEDs are switched ON & other LEDs are switched OFF. Amber
LED is
switched on before switching over to precede state from halt state.
Power supply connection:-

CIRCUIT DIAGRAMs:

PRROGRAM:
; Program to test TRAFFIC LIGHT SIMULATOR interface using
OUTPUT 2500AD
CWR: EQU FFC6H
PORTA: EQU FFC0H
PORTB: EQU FFC2H
PORTC: EQU FFC4H
DSEG SEGMENT
DSEG ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DSEG
ORG 0000:4000H
STR:
MOV AL, 80H
MOV DX, CWR
OUT DX, AL
MOV AL, F3H
MOV DX, PORTC
OUT DX, AL
MOV AL, FFH
MOV DX, PORTA
OUT DX, AL
MOV DX, PORTB
OUT DX, AL
MOV CL, 03H
CALL DELAY
TOP:
MOV AL, EEH
MOV DX, PORTA
OUT DX, AL
MOV AL, EEH
MOV DX, PORTB
OUT DX, AL
MOV CL, 02H
CALL DELAY
MOV AL, FCH
MOV DX, PORTC
OUT DX, AL
MOV AL, 7DH
MOV DX, PORTA
OUT DX, AL
MOV AL, 57H
MOV DX, PORTB
OUT DX, AL
MOV CL, 15H
CALL DELAY

MOV AL, E7H


MOV DX, PORTB
OUT DX, AL
MOV AL, FDH
MOV DX, PORTA
OUT DX, AL
MOV AL, EDH
MOV DX, PORTA
OUT DX, AL
MOV CL, 02H
CALL DELAY
MOV AL, F7H
MOV DX, PORTB
OUT DX, AL
MOV AL, F0H
MOV DX, PORTC
OUT DX, AL
MOV AL, F1H
MOV DX, PORTA
OUT DX, AL
MOV CL, 15H
CALL DELAY
MOV AL, FBH
MOV DX, PORTA
OUT DX, AL
MOV DX, PORTB
OUT DX, AL
MOV AL, 50H
MOV DX, PORTC
OUT DX, AL
MOV CL, 15H
CALL DELAY
MOV AL, FEH
MOV DX, PORTA
OUT DX, AL
MOV DX, PORTB
OUT DX, AL
MOV CL, 03
CALL DELAY
MOV AL, FFH
MOV DX, PORTA
OUT DX, AL
MOV AL, AFH
MOV DX, PORTC
OUT DX, AL
MOV AL, EEH

MOV DX, PORTA


OUT DX, AL
MOV DX, PORTB
OUT DX, AL
MOV CL, 02
CALL DELAY
MOV AL, BFH
MOV DX, PORTA
OUT DX, AL
MOV DX, PORTB
OUT DX, AL
MOV CL, 15H
CALL DELAY
JMP TOP
DELAY:
MOV BX, 10H
D1:
MOV CX, 0FFFFH
D2:
LOOP D2
DEC BX
JNZ D1
RET
CODE ENDS
END
PROCEDURE:1. Connect power supply 5V & GND to both microprocessor trainer kit and traffic light
controller interfacing kit.
2. Make the connections in talk window.
3. Connect data bus between microprocessor trainer kit and traffic light controller
interfacing
kit.
4. Dump the program in to processor kit using RS-232 cable.
5. Execute the program by typing code segment starting address.
6. Observe the LEDs on traffic light controller PCB.
RESULT: - Thus the interfacing of traffic light controller with 8086 is done using Talk
software

STEPPER MOTOR
AIM:- Write a program to interface a stepper motor with 8086.
APPARATUS REQUIRED:1. 8086 microprocessor kit

2. Stepper motor
3. Rs-232
4. Power supply
5. 26-pin bus
6. Talk software
7. Connecting wires.
THEORY:Stepper motor is a device used to obtain an accurate position control of rotating shafts.
A stepper
motor employs rotation of its shaft in terms of steps, rather than continuous rotation as
in cause of AC or
DC motor. To rotate the shaft of the stepper motor, a sequence of pulses is needed to
be applied to the
windings of the stepper motor, in proper sequence. The no. of pulses required for
complete rotation of
the shaft of the stepper motor are equal to the no. of internal teeth on its rotor. The
stator teeth and the
rotor teeth lock with each other to fix a position of the shaft. With a pulse applied to the
winding input,
the rotor rotates by one teeth position or an angle x. the angle X may be calculated as.
X=3600/no. of rotor teeth
After the rotation of the shaft through angle x, the rotor locks itself with the next tooth in
the sequence
on the internal surface of the stator. The typical schematic of a typical stepper motor
with 4 windings is
as shown below.
OPERATION:The stepper motors have been designed to work with digital circuits. Binary level pulses
of 0-5v
are required at its winding inputs to obtain the rotation of the shafts. The sequence of
the pulses can be
decided, depending upon the required motion of the shaft. By suitable sequence of the
pulses of the
motor can be used in 3 modes of operation.
1. one phase ON (medium torque)
2. two phase ON (high torque)
3. half stepping (low torque)
Power supply connection:-

CIRCUIT DIAGRAM:

PROGRAM:
Two-phase on scheme (clockwise) half step
.OUTPUT 2500AD
; EQUATES
PORTA EQU FFC0H; PORT A ADDRESS
PORTB EQU FFC2H; PORT B ADDRESS
PORTC EQU FFC4H; PORT C ADDRESS
CTL EQU FFC6H; CONTROL PORT ADDRESS
CSEG SEGMENT
ASSUME CS: CSEG
ORG 0000:4000H
MOV AL, 80H
MOV DX, CTL
OUT DX, AL
MOV DX, PORTC
MOV AL, 0DH
OUT DX, AL
CALL DELAY
MOV AL, 0DH
MOV DX, PORTC
OUT DX, AL

CALL DELAY
MOV AL, 0EH
MOV DX, PORTC
OUT DX, AL
CALL DELAY
MOV AL, 06H
MOV DX, PORTC
OUT DX, AL
CALL DELAY
MOV AL, 07H
MOV DX, PORTC
OUT DX, AL
CALL DELAY
MOV AL, 03H
MOV DX, PORTC
OUT DX, AL
CALL DELAY
MOV AL, 0BH
MOV DX, PORTC
OUT DX, AL
CALL DELAY
MOV AL, 09H
OUT DX, AL
CALL DELAY
HERE: JMP HERE
DELAY:
MOV DI, 02H
L00:
MOV CX, 0FFFFH
L1: LOOP L1
DEC DI
JNZ L00
RET
CSEG ENDS
.END
PROCEDURE:1. Connect power supply 5v & GND to both microprocessor trainer kit and stepper
motor
Interfacing kit.
2. Make the connections in talk window.
3. Connect data bus between microprocessor trainer kit and stepper motor interfacing
Kit.
4. Dump the program in to processor kit using RS-232 cable.
5. Execute the program by typing code segment starting address.
6. Observe the rotation of stepper motor.
RESULT:- Thus the interfacing of stepper motor with 8086 is done using Talk software

KEY BOARD / DISPLAY INTERFACE


AIM: - write a program to interface stepper motor with 8086.
APPARATUS REQUIRED:1. 8086 microprocessor kit.
2. Key board / display interfacing card..
3. Rs-232.
4. Power supply.
5. 26-pin bus.
6. Talk software.
7. Connecting wires.
THEORY:The 8279 is designed specially to connect to any 8- bit microprocessor bus directivity
and
thus allows the cpu to do some other work other than scanning the key board and
refreshing the display .
Getting meaningful data from a keyboard, it required the following 3 major tasks:
1. Detect a key press.
2. De- bounces the key press.
3. Encode the key press.
DESCRIPTION:KEY BOARD:The key board consists of 20 keys arranged in a fashion similar to a calculator key
board. It
consists of numerals 0 to 9, the special characters +, -, *, %,--., etc and two blank keys.
The keys have
been organized as 4 rows of 5 keys each in a sense matrix of 3 rows & 8 columns. The
8 columns are
connected to bits 0 to 7 of port A of 8255 while the rows are connected to bits 0 to 2 of
port C.
DISPLAY:A non multiplexed approach to display interfacing is provided by a set of shift registers &
their
corresponding seven segment displays. All shift registers are serially connected. This
approach
provides a software intensive solution with minimum hardware & providing the capability
of
displaying any segment combination.

The Intel 8279 is responsible for de- bouncing of the keys, coding of the keypad matrix
and
refreshing of the display elements in a microprocessor based development system. Its
main features
are:
1. Simultaneous keyboard and display operation.
1. Three input modes such as scanned keyboard mode , scanned sensor mode & strobe
entry
input mode .
2. Two input modes such as 8 or 16 bit character multiplexed displays and right entry or
left
entry display formats.
3. Programmable scan timing.
4. Two key lock out or N- key roll over with contact de- bounce.
5. Auto increment facility for easy programming.
Seven Segment Code

PROCEDURE:1. Connect power supply to microprocessor trainer kit and Key board / display
Interfacing kit.
2. Make the connections in talk window.
3. Connect data bus between microprocessor trainer kit and Key board / display
Interfacing
Kit.
4. Dump the program in to processor kit using RS-232 cable.
5. Execute the program by typing code segment starting address.
6. Observe the output by pressing keys on interfacing card.

RESULT: - Thus the interfacing of Key board/ Display with 8086 is done using Talk
software

Experiments using Microcontroller 8051


EXPT NO:10

DATE:

8051 PROGRAMMING
(a) Arithmetic operations using 8051

AIM: To write a program to (i) add two 8-bit numbers (ii) subtract two 8-bit
number(iii)multiply two 8-bit number (iv)division of two 8-bit number
using 8051 microcontroller.

SAMPLE ALGORITHM FOR ADDITION:


1. Clear Program Status Word.
2. Select Register bank by giving proper values to RS1 & RS0 of PSW.
3. Load accumulator A with any desired 8-bit data.
4. Load the register R 0 with the second 8- bit data.
5. Add these two 8-bit numbers.
6. Store the result.
7. Stop the program.

RESULT: Thus the arithmetic operations to (i) add two 8-bit numbers (ii) subtract

two 8-bit number (iii)multiply two 8-bit number (iv)division of two 8bit number using 8051 Microcontroller was written and executed
successfully.

1) 8051 - SUM OF ELEMENTS IN AN ARRAY


AIM: To find the sum of elements in an array.
APPARATUS REQUIRED:
(i) 8051 microcontroller kit and (ii) keyboard

ALGORITHM:
1.

Load the array in the consecutive memory location and initialize


the memory pointer with the starting address.

2.

Load the total number of elements in a separate register as a


counter.

3.

Clear the accumulator.

4.

Load the other register with the value of the memory pointer.

5.

Add the register with the accumulator.

6.

Check for carry, if exist, increment the carry register by 1.


otherwise, continue

7.

Decrement the counter and if it reaches 0, stop. Otherwise


increment the memory pointer by 1 and go to step 4.

PROGRAM:

ADDRESS LABEL
1100

MNEMONICS
MOV DPTR, #4200
MOVX A, @DPTR
MOV R0, A
MOV B, #00
MOV R1, B
INC DPTR

LOOP2

CLR C
MOVX A, @DPTR
ADD A, B
MOV B, A
JNC LOOP
INC R1

LOOP

INC DPTR
DJNZ R0, LOOP2
MOV DPTR, #4500
MOV A, R1
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A

OP CODE

COMMENT

HLT

INPUT

SJMP HLT

OUTPUT:

4200

04

4500 0F

4201

05

4501 00

4201

06

4202

03

4203

02

RESULT: The ALP for sum of elements in an array was written ,executed and
verified the result.

EX NO: 4a

DATE:

ONES AND TWOS COMPLEMENT USING 8051


AIM
To write an assembly language program to find the 1s and 2s complement
of an 8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Complement the accumulator.
3. Move the ones complement output to the memory 6500H.
4. Add 01H with accumulator.
5. Move the twos complement output to the memory 6501H.
PROGRAM
MEMORY

LABEL

MNEMONICS

OP CODE

COMMENTS

ADDRESS
6100

MOV A, #data

74, CC

6101

CPL A

F4

6103

MOV DPTR, #6500H

90, 65, 00

6106

MOVX @DPTR, A

F0

6107

INC A

04

610A

INC DPTR

A3

610B

MOVX @DPTR, A

F0

SJMP LOOP

80, FE

610C

LOOP

OBSERVATION
INPUT
Address

OUTPUT
Data

Address

Data

6500
6101
6501

RESULT
Thus the assembly language program to find the 1s and 2s complement of
an 8-bit number using 8051 instruction set was written and executed successfully.

EX NO: 4b.
DATE:
SETTING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESS

MNEMONICS

OP CODE

6100

MOV A, #data1

74, 2F

6102

ORL A, #data2

44, 7E

6104

MOV DPTR, #6500H

90, 65, 00

6107

MOVX @DPTR, A

F0

SJMP LOOP

80, FE

6108

LABEL

LOOP

COMMENTS

OBSERVATION

INPUT
Address

OUTPUT
Data

Address

Data

6101
6500
6103

RESULT
Thus the assembly language program to Setting bits an
8-bit number using microcontroller instruction set was written and executed
successfully.

BEYOND THE SYLLABUS

EX NO: 4b.
DATE:
SETTING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
3. 8051 Microcontroller kit
4. Power chord.
ALGORITHM
4. Move the data to Accumulator.
5. Perform OR operation with accumulator.
6. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESS

LABEL

MNEMONICS

OP CODE

6100

MOV A, #data1

74, 2F

6102

ORL A, #data2

44, 7E

6104

MOV DPTR, #6500H

90, 65, 00

6107

MOVX @DPTR, A

F0

COMMENTS

6108

LOOP

SJMP LOOP

80, FE

OBSERVATION

INPUT
Address

OUTPUT
Data

Address

Data

6101
6500
6103

RESULT
Thus the assembly language program to Setting bits an
8-bit number using microcontroller instruction set was written and executed
successfully.

EX NO: 4c
DATE:
MASKING BITS IN AN 8 BIT NUMBERS USING 8051
AIM

To write an assembly language program to find the Masking bits an


8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform AND operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESS

MNEMONICS

OP CODE

6100

MOV A, #data1

74, 2F

6102

ANL A, #data2

54, 7E

6104

MOV DPTR, #6500H

90, 65, 00

6107

MOVX @DPTR, A

F0

SJMP LOOP

80, FE

6108

LABEL

LOOP

OBSERVATION

INPUT

OUTPUT

COMMENTS

Address

Data

Address

Data

6101
6500
6103

RESULT
Thus the assembly language program to masking bits an
8-bit number using microcontroller instruction set was written and executed
successfully.

EX NO: 4d

DATE:

ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER


AIM
To write an assembly language program to sort an array of data in
ascending order using 8051 simulator tool.
APPARATUS REQUIRED
8051 Microcontroller simulator tool
ALGORITHM
1. Load the count value from memory to A-register and store it in Bregister.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address pointer.

6. Increment the HL pair (data address pointer).


7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than memory)
then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise, go to
next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise, go to
next step.

PROGRAM
MEMORY
ADDRESS

MNEMONICS

OP CODE

6100

MOV R3, #04H

7B, 04

6102

MOV R4, #04H

7C, 04

6104

MOV DPTR, #6500H

90, 65, 00

MOV R5, DPL

AD, 82,

6109

MOV R6, DPH

AE, 83

610B

MOVX A, @DPTR

E0

610C

MOV B,A

F5, F0

INC DPTR

A3

610F

MOVX A, @DPTR

E0

6110

MOV R0, A

F8

6107

610E

LABEL

LOOP1

LOOP

6111

CLR C

C3

6112

SUBB A, B

95, F0

6114

JNC LOOP2

50,13

PUSH DPL

C0, 82

6118

PUSH DPH

C0, 83

611A

MOV DPL, R5

8D, 82

611C

MOV DPH, R6

8E, 83

611E

MOV A, R0

E8

611F

MOVX A, @DPTR

E0

6120

POP DPH

D0, 83

6122

POP DPL

D0, 82

6124

MOV A, B

E5, F0

6126

MOVX @DPTR, A

F0

6127

MOV B, R0

88, FO

DJNZ R3, REPT

DB, E3

612B

DEC R4

1C

612C

MOV A, R4

EC

612D

MOV R3, A

FB

612E

INC R4

0C

612F

MOV DPL, R5

8D, 82

6131

MOV DPH, R6

8E, 83

6116

6129

EXCH

LOOP2

6133

INC DPTR

A3

6134

DJNZ R4, LOOP1

DC, D1

SJMP HLT

80, FE

6136

HLT

OBSERVATION
INPUT

OUTPUT

(Before sorting)

(After sorting)

Address

Data

Address

Data

6500

05H

6500

05H

6501

0AH

6501

03H

6502

0CH

6502

06H

6503

06H

6503

08H

6504

03H

6504

0AH

6505

08H

6505

0CH

RESULT
Thus, the assembly language program to sort an array of data in ascending
order using 8051 simulator tools was written and executed successfully.

EX NO: 4e

DATE:

ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER


AIM
To write an assembly language program to sort an array of data in
descending order using 8051 simulator tool.
APPARATUS REQUIRED
8051 Microcontroller simulator tool
ALGORITHM
1. Load the count value from memory to A-register and store it in Bregister.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address pointer.

6. Increment the HL pair (data address pointer).


7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than memory)
then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise, go to
next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise, go to
next step.

PROGRAM
MEMORY
ADDRESS

MNEMONICS

OP CODE

6100

MOV R3, #04H

7B, 04

6102

MOV R4, #04H

7C, 04

6104

MOV DPTR, #6500H

90, 65, 00

MOV R5, DPL

AD, 82,

6109

MOV R6, DPH

AE, 83

610B

MOVX A, @DPTR

E0

610C

MOV B,A

F5, F0

INC DPTR

A3

610F

MOVX A, @DPTR

E0

6110

MOV R0, A

F8

6107

610E

LABEL

LOOP1

LOOP

6111

CLR C

C3

6112

SUBB A, B

95, F0

6114

JNC LOOP2

40,13

PUSH DPL

C0, 82

6118

PUSH DPH

C0, 83

611A

MOV DPL, R5

8D, 82

611C

MOV DPH, R6

8E, 83

611E

MOV A, R0

E8

611F

MOVX A, @DPTR

E0

6120

POP DPH

D0, 83

6122

POP DPL

D0, 82

6124

MOV A, B

E5, F0

6126

MOVX @DPTR, A

F0

6127

MOV B, R0

88, F0

DJNZ R3, REPT

DB, E3

612B

DEC R4

1C

612C

MOV A, R4

EC

612D

MOV R3, A

FB

612E

INC R4

0C

612F

MOV DPL, R5

8D, 82

6131

MOV DPH, R6

8E, 83

6116

6129

EXCH

LOOP2

6133

INC DPTR

A3

6134

DJNZ R4, LOOP1

DC, D1

SJMP HLT

80, FE

6136

HLT

OBSERVATION
INPUT

OUTPUT

(Before sorting)

(After sorting)

Address

Data

Address

Data

6500

05H

6500

05H

6501

0AH

6501

0CH

6502

0CH

6502

0AH

6503

06H

6503

08H

6504

03H

6504

06H

6505

08H

6505

03H

RESULT
Thus the assembly language program to sort an array of data in descending
order using 8051 simulator tools was written and executed successfully.

EX NO: 4f

DATE:

LARGEST ELEMENT IN AN ARRAY


AIM
To write an assembly language program to find the largest number in an
array using 8051 simulator tools.
APPARATUS REQUIRED
8051 Microcontroller kit, Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data from memory to accumulator and move it to Bregister.
3. Move the second data from memory to accumulator.
4. Add the content of B-register with Accumulator.

5.
6.
7.
8.

Check for carry. If carry=1 then go to step 6 else go to step 7.


Increment the C-register
Store the sum in memory.
Move the carry to accumulator and store in memory.

10(A).8051 - HEXADECIMAL TO DECIMAL CONVERSION


AIM:
To perform hexadecimal to decimal conversion.

ALGORITHM:
1. Load the number to be converted into the accumulator.
2. If the number is less than 100 (64H), go to next step; otherwise, subtract 100 (64H)
repeatedly until the remainder is less than 100 (64H). Have the count(100s value) in
separate register which is the carry.
3. If the number is less than 10 (0AH), go to next step; otherwise, subtract 10 (0AH)
repeatedly until the remainder is less than 10 (0AH). Have the count(tens value) in
separate register.
4. The accumulator now has the units.
5. Multiply the tens value by 10 and add it with the units.
6. Store the result and carry in the specified memory location.

RESULT
The given hexadecimal number is converted into decimal number.

PROGRAM:

MOV DPTR, #4500


MOVX A, @DPTR
MOV B, #64
DIV A, B
MOV DPTR, #4501
MOVX @DPTR, A
MOV A, B

MOV B, #0A
DIV A, B
INC DPTR
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A
HLT:

SJMP HLT

INPUT
4500

OUTPUT:
D7

4501

15

4502

02

10(B).8051 - DECIMAL TO HEXADECIMAL CONVERSION


AIM:
To perform decimal to hexadecimal conversion

ALGORITHM:
1.

Load the number to be converted in the accumulator.

2.

Separate the higher order digit from lower order.

3.

Multiply the higher order digit by 10 and add it with the lower order
digit.

4.

Store the result in the specified memory location.

RESULT:
The given decimal number is converted to hexadecimal number.
PROGRAM:
MOV DPTR, #4500
MOVX A, @DPTR
MOV B, #0A
MUL A, B
MOV B, A
INC DPTR
MOVX A, @DPTR
ADD A, B
INC DPTR

MOVX @DPTR, A
HLT:

SJMP HLT

INPUT
4500

OUTPUT
23

4501

17

13. STEPPER MOTOR INTERFACING WITH 8051

AIM:
To interface a stepper motor with 8051 microcontroller and operate it.

THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the
next. Stepper Motors are used very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles
has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets
induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a
permanent magnet with one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to run the
motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise stepping
can be obtained.

2-PHASE SWITCHING SCHEME:


In this scheme, any two adjacent stator windings are energized. The switching scheme is shown
in the table given below. This scheme produces more torque.

ANTICLOCKWISE
STEP
A1
A2
B1

B2

DATA

CLOCKWISE
STEP
A1 A2

B1

B2

DATA

9h

Ah

5h

6h

6h

5h

Ah

9h

ADDRESS DECODING LOGIC:


The 74138 chip is used for generating the address decoding logic to generate the device select
pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor driving
circuitry.

Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry
that generates the driving pulses use silicon darlington pair transistors. The inputs for the interface
circuit are TTL pulses generated under software control using the Microcontroller Kit. The TTL levels of
pulse sequence from the data bus is translated to high voltage output pulses using a buffer 7407 with
open collector.

PROGRAM :
Address

OPCODES

Label

Comments
ORG

4100h

MOV

DPTR, #TABLE

Load the start address


of switching scheme
data TABLE into Data
Pointer (DPTR)

MOV

R0, #04

Load the count in R0

MOVX

A, @DPTR

Load the number in


TABLE into A

4106

PUSH

DPH

4108

PUSH

DPL

Push DPTR value to


Stack

410A

MOV

DPTR, #0FFC0h

Load the Motor port


address into DPTR

410D

MOVX

@DPTR, A

Send the value in A to


stepper Motor port
address

410E

MOV

R4, #0FFh

Delay loop to cause a


specific amount of
time delay before next
data item is sent to
the Motor

4100

START:

4103
4105

LOOP:

4110

DELAY:

MOV

R5, #0FFh

4112

DELAY1:

DJNZ

R5, DELAY1

4114

DJNZ

R4, DELAY

4116

POP

DPL

4118

POP

DPH

411A

INC

DPTR

POP back DPTR value


from Stack
Increment DPTR to
point to next item in
the table

411B

DJNZ

R0, LOOP

Decrement R0, if not


zero repeat the loop

411D

SJMP

START

Short jump to Start of


the program to make
the motor rotate
continuously

DB

09 05 06 0Ah

Values as per twophase switching


scheme

411F

TABLE:

PROCEDURE:
Enter the above program starting from location 4100.and execute the same. The stepper motor
rotates. Varying the count at R4 and R5 can vary the speed. Entering the data in the look-up TABLE in the
reverse order can vary direction of rotation.

RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at
various speeds.

PROGRAM
MEMORY
ADDRESS

MNEMONICS

OP CODE

6100

MOV DPTR,#6500

90, 65, 00

6103

MOV 40,#00

75, 40, 00

6106

MOV R5,#05

7D, 05

MOVX A,@DPTR

E0

CJNE A,40H,LOOP1

B5, 40, 08

INC DPTR

A3

610D

DJNZ R5, LOOP2

DD, F9

610F

MOV A, 40H

E5, 40

6111

MOVX @DPTR,A

F0

6108

LABEL

LOOP2

6109
610C

LOOP3

6112

HLT

SJMP HLT

80, FE

6114

LOOP1

JC LOOP3

40, F6

6116

MOV 40H,A

F5, 40

6118

SJMP LOOP3

80, F2

OBSERVATION

INPUT

OUTPUT

Address

Data

6500

04H

6501

08H

6502

02H

6503

0AH

6504

06H

Address

Data

6500

0AH

RESULT
Thus the assembly language program to find the largest number in an array
using 8051 simulator tools was written and executed successfully.

PACKED BCD TO UNPACKED & BCD TO ASCII


Aim: To perform conversion operations, convert packed BCD to UNPACKED BCD
Apparatus: PC loaded with TASM software.
Converting Packed BCD to unpacked BCD:

DATA SEGMENT
NUM DB 45H
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM
MOV AH, AL
MOV CL, 4
SHR AH, CL
AND AX, 0F0FH
INT 3H
CODE ENDS
END START
END
Converting BCD to ASCII:
DATA SEGMENT
NUM DB 45H
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM

MOV AH, AL
MOV CL, 4
SHR AH, CL
AND AX, 0F0FH
OR AX, 3030H
INT 3H
CODE ENDS
END START
END

LAB VIVA QUESTIONS


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.

Mention the general purpose registers in 8085 microprocessor.


What is the function of accumulator?
What are the flag registers available in 8085?
What is buffer?
Mention the groups of 8085 pin signals.
Explain the function of program counter.
What is the function of SP?
What is memory?
What are the types of memory?
What is memory word?
What are the programming registers in 8085?
Mention the types of 8085 instruction set.
Write any two data transfer instructions of 8085.
What is memory address?
What is Opcode?
What is Operand?
What is stack?
How many memory locations can be addressed by a microprocessor with 14 address lines?
How many address lines are necessary to address two megabytes (2048K) of memory?
How many address lines are necessary to address two megabytes(2048K) of memory?
What is the purpose of branch instructions in 8085 microprocessor?
What is the use of programming technique
How many memory locations are available in 8086 microprocessor?
What are the flags available in 8086 microprocessor?
What are the general purpose registers in 8086?
What are the functional units in 8086?
What is the purpose of BIU?
What is the purpose of EU?

29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.

What is the purpose of segment register?


What are the segment registers in 8086?
What is the function of IP?
What is the function of control unit?
What is the use of base pointer register?
Mention the index registers of 8086.
What is effective address?
What are the assembly language program development steps?
What are the instructions types of 8086 mp?
Write any two data transfer instructions?
Write any two arithmetic instructions.
Write any two bit manipulation instructions.
Write any two string manipulation instructions.
Define CALL and RET.
Write any two processor control instructions.
Mention any four initialization list in the 8086 program.
What are the assembly language program development tools?
What is an assembler directive?
Define SEGEMNT and ENDS.
Define EQU and DB directive.
What is editor?
Define assembler.
Define Linker.

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.

What is locator?
What is debugger?
What is emulator?
What are the advantages of segment registers?
Define the trap flag.
What is effective address?
What is physical address?
What is operand?
What are the types of addressing modes?
Define register addressing mode.
What is the purpose of register addressing mode?
What is immediate addressing mode?
Define direct addressing mode.
Define register indirect addressing mode.
What is index addressing mode?
What is base index addressing mode?
What is the use of CMP instruction?
Mention the two operation modes of 8086 processor.
What is minimum mode?
What is maximum mode?
What is machine cycle?
What is instructions cycle?
What are the minimum mode signals?
What are the maximum mode signals?
What is the purpose of INTR pin?
What is the function of BHE/S7 pin?
How minimum mode or maximum mode is is selected?
What are the two modes of 8086 and how do you configure 8086 to work in these modes?
How do you classify the programmed I/O data transfer scheme?

30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.

Give the function of the following pins-Ready, ALE.


What is a machine cycle initiated? How many T states does each machine cycle contain in 8086?
What do you understand by handshaking?
Explain real mode and protected mode of operations?
Which signals are used by 8086 microprocessor to specify the current segment portion of the
address referred?
Can the 8086 microprocessor operate on more than one instruction at a time? If so, explain how
it is done.
Why word type of data has to be stored starting from an even address in 8086?
Mention the function of RQ/GT.
What are the display modes supported by the 8279 chip?
Name any two coprocessors and their use.
Give the format of program clock word of 8279 and mention its purpose.
Mention any two coprocessors and their use.
What is 2 key lockout and n key roolover?
Name the two types of CRT display systems.
What do you mean by leading edge and trailing edge problems in hexadecimal keyboards?
State any two main functions of a CRT controller

You might also like