You are on page 1of 92

S.

No

Experiment

Page no
Programs for 16 bit arithmetic operations (using 8086)
Addition of two 16-bit numbers
Subtraction of two 16-bit numbers
Multiplication of two 16-bit numbers
Division of two 16-bit numbers
Double precision addition
Double precision subtraction
16 bit logical operations using 8086
Ones complement of a 16-bit numbers
Masking off bits selectively in 16-bit number
Setting off bits selectively in 16-bit number
Programs for string manipulation operations (using 8086)
Program for string primitive (using 8086)
String manipulation using 8086
Calculating the length of string
Code conversion
Programs for bcd number to binary number
Programs for binary number to bcd number
Programs for 8-bit binary number to gray code
Arithmetic operations using masm software
Programs for matrix addtion (3*3 matrix) using masm
software
Programs for matrix multiplication (3*3 matrix) using
masm software
String manipulation
Descending order of an array
Ascending order of an array
Largest number in an array
Smallest number in an array
Search a number in an array
Counters and delay program
Program for setting system date
Traffic light controller using 8086
Interfacing and programming of stepper motor
To run stepper motor at different speeds
To run stepper motor in both directions
Programs for digital clock and stop watch
Clock display
Stop watch display

Interfacing and programming of 8279 using 8086


Read a key
Rolling display (display message is cse- a)
Interfacing and programming of printer interface using
8086
Serial communication between two mp kits using 8251
Interfacing 8255 with 8086
Programs for interfacing ADC and DAC
Analog to digital converter
Digital to analog converter
Generation of saw tooth wave
Generation of square wave
Generation of triangular wave
Programming of 8051 microcontroller
Programming using arithmetic, logical and bit manipulation
Addition of two 8-bit numbers using 8051
Subtraction of two 8-bit numbers using 8051
Multiplication of two 8-bit numbers using 8051
Division of two 8-bit numbers using 8051
Ones and twos complement using 8051
Setting bits in an 8 bit numbers using 8051
Masking bits in an 8 bit numbers using 8051
Programs for sorting and searching (using 8051)
Arrange the given number in ascending order
Arrange the given number in descending order
Largest element in an array
Programming using arithmetic, logical and bit manipulation
Unmasked bcd number to ascii code using 8051
Square of a 8-bit number using 8051
Cube of a 8-bit number using 8051

EXPT NO:

16 BIT ARITHMETIC OPERATIONS

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) for 16 bit Arithmetic operations using 8086.

APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

Power chord

ALGORITHM:

(i)16-bit addition:
a) Start the program.
b) Load the augend to the accumulator.
c) Load the addend to any other general purpose register.
d) Add these two register contents.
e) Store the result in required memory location.
f) Stop the program.

(ii) 16-bit subtraction:


a)
b)
c)
d)
e)
f)

Start the program.


Load the minuend to the accumulator.
Load the subtrahend to any other general purpose register.
Subtract these two register contents.
Store the result in required memory locations.
Stop the program.

(iii)Multiplication of 16-bit numbers:


a)
b)
c)
d)
e)
f)

Start the program.


Load the multiplicand to the accumulator.
Load the multiplier to any other general purpose register.
Add the multiplicand, multiplier times.
Store the result in required memory location.
Stop the program.

(iv)Division of 16-bit numbers:


a)
b)
c)
d)
e)
f)

Start the program.


Load the dividend to the accumulator.
Load the divisor to any other general purpose register.
Subtract the dividend, divisor times.
Store the result in required memory location.
Stop the program.

(v)Double precision Addition:

a) Start the program.


b) Load the 16 bit augend to the accumulator.
c) Load the 16 bit addend to any other general purpose register.
d) Add these two register contents with carry.
e) Store the result in required memory location.
f) Stop the program

(vi)Double precision subtraction:


a)
b)
c)
d)
e)
f)

Start the program.


Load the 16 bit minuend to the accumulator.
Load the 16 bit subtrahend to any other general purpose register.
Subtract these two register contents with borrow.
Store the result in required memory locations.
Stop the program.

. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


A-ADDITION OF TWO 16-BIT NUMBERS
ADDRESS

MNEMONICS

OP-CODE

1000

MOV AX,[1100]

A1,00,11

1003

ADD AX,[1102]

03,06,02,11

1007

MOV [1200],AX

A3,00,12

100A

HLT

F4

OUT PUT:

COMMANDS
MOVE THE DATA TO
ACCUMULATOR
ADD MEMORY
CONTENT
WITH
ACCUMULATOR
MOVE
ACCUMULATOR
CONTENT TO
MEMORY
STOP

IN PUT
ADDRESS

DATA
OUT PUT

DATA

ADDRESS

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


B-SUBTRACTION OF TWO 16-BIT NUMBERS
ADDRESS

MNEMONICS

1000

OP-CODE

MOV AX[1100]

A1,00,11

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR

1003

SUB AX[1102]

2B,06,02,11

1007

MOV [1200],AX

A3,00,12

100A

HLT

F4

OUT PUT:

IN PUT

DATA
OUT PUT

DATA

SUBTRACT
MEMORY CONTENT
WITH
ACCUMULATOR
MOVE
ACCUMULATOR
CONTENT TO
MEMORY

STOP

ADDRESS
ADDRESS

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


C-MULTIPLICATION OF TWO 16-BIT NUMBERS
ADDRESS

MNEMONICS

OP-CODE

1000

MOV AX[1100]

A1,00,11

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR

1003

MUL[1102]

F7,26,02,11

1007

MOV [1200],DX

87,16,00,12

100B

MOV[1202],AX

A3,02,12

100E

HLT

F4

MULTIPLY
MEMORY
CONTENT
WITH
ACCUMULATOR
MOVE
ACCUMULATOR
CONTENT TO AX
REGISTER

MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER
STOP

OUT PUT:

IN PUT

DATA
OUT PUT

DATA

ADDRESS
ADDRESS

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


D-DIVISION OF TWO 16-BIT NUMBERS
ADDRESS
1000

MNEMONICS
MOV AX[1100]

1003

DIV[1102]

1007

OP-CODE
A1,00,11

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR

F7,36,02,11

DIVIDE MEMORY
CONTENT
WITH
ACCUMULATOR

MOV [1200],DX

87,16,00,12

MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER

MOV[1200],AX

A3,00,12

MOVE CONTENT
OF AX
REGISTER TO
MEMORY

HLT

F4

100B

100E

OUT PUT:

STOP

IN PUT

DATA
OUT PUT

DATA

ADDRESS
ADDRESS

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


E-DOUBLE PRECISION ADDITION
ADDRESS

MNEMONICS

OP-CODE

1000

MOV AX,[1100]

A1,00,11

1003

ADD AX,[1104]

03,06,04,11

1007

MOV [1200],AX

A3,00,12

100A

MOV AX,[1102]

A1,02,11

100D

ADC AX,[1106]

13,06,06,11

1011
1014

MOV[1202],AH
LAHF

A3,02,12
9F

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR
ADD MEMORY
CONTENT WITH
ACCUMULATOR

MOVE DATA IN
MEMORY
TO ACCUMULATOR
MOVE
ACCUMULATOR
VALUE TO
MEMORY
ADD
ACCUMULATOR
VALUE WITH
CARRY
MOVE
ACCUMULATOR
VALUE TO
MEMORY
MOVE HIGHER
VALUE TO

MOV[1204],AH
HLT

1015
1019

88,2,04,12
F4

OUT PUT:

IN PUT

DATA
OUT PUT

ADDRESS
ADDRESS

DATA

MEMORY
MOVE
ACCUMULATOR
VALUE TO
MEMORY
STOP

1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


F-DOUBLE PRECISION SUBTRACTION
ADDRESS
1000
1003

MNEMONICS
MOV AX,[1100]
SUB AX,[1104]

1007

MOV [1200],AX

100A

MOV AX,[1102]

100D

SBB AX,[1106]

OP-CODE
A1,00,11
2B,06,04,11

A3,00,12
A1,02,11
2B,06,06,11

1011

MOV[1202],AX

A3,02,12

1014

HLT

F4

OUT PUT:

IN PUT

DATA

COMMANDS
MOVE THE DATA TO
ACCUMULATOR
SUBTRACT
MEMORY
CONTENT WITH
WITH
ACCUMULATOR
MOVE DATA IN
MEMORY TO
ACCUMULATOR
MOVE
ACCUMULATOR
VALUE TO MEMORY
SUBTRACT MEMORY
CONTENT WITH
ACCUMULATOR
MOVE ACCUMULATOR
VALUE TO MEMORY
STOP

OUT PUT

DATA

ADDRESS
ADDRESS

Result:
Thus, the programs for Arithmetic operations have been executed using 8086 Microprocessor
EXPT NO:

16 BIT LOGICAL OPERATIONS

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) for 16 bit logical operations using 8086

APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION

1.

Microprocessor kit

2.

Keyboard

Power chord

ALGORITHM:

8086 kit

QUANTITY
1

(i)

ONES COMPLEMENT OF A 16 BIT NUMBERS:


a) Start the program.
b) Load the input data to the Accumulator.
c) Perform negation on Accumulator.
d) Store the result in required memory location.
e) Stop the program.

(ii)

MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER:


a) Start the program.
b) Load the first input data to the Accumulator.
c) Perform AND operation with AX and second data
d) Store the result in required memory location.
e) Stop the program.
SETTING OF BITS SELECTIVELY:
a) Start the program.
b) Load the first input data to the Accumulator.
c) Perform OR operation with AX and second data
d) Store the result in required memory location.
e) Stop the program.

(iii)

PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)


A-ONES COMPLEMENT OF A 16-BIT NUMBERS
ADDRESS
1000

MNEMONICS
MOV AX 1234

OP-CODE
B8,34,12

1003

NOT AX

1007

MOV [1400],AX

A3,00,14

1009

HLT

F4

F7,D0

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR
NOT OPERATION
WITH
ACCUMULATOR
MOVE DATA IN
MEMORY
TO
ACCUMULATOR
STOP

OUT PUT:
IN PUT:
DATA:

OUT PUT
ADDRESS

DATA

2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)


B-MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESS
1000

MNEMONICS
MOV AX, [1200]

OP-CODE
A1,00,12

1003

AND AX, 0F0F

25,0F,0F

1007

MOV [1400],AX

A3,00,14

1009

HLT

F4

COMMANDS
MOVE THE DATA
TO
ACCUMULATOR
AND OPERATION
WITH
ACCUMULATOR
MOVE DATA IN
MEMORY
TO
ACCUMULATOR
STOP

OUT PUT:
IN PUT:
IN PUT
ADDRESS

DATA

OUT PUT
ADDRESS

DATA

2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)


C- SETTING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESS
1000

MNEMONICS
MOV AX ,0000

OP-CODE
B8,00,00

COMMANDS
CLEAR
ACCUMULATOR

1003

OR AX, 0F0F

0D,0F,0F

OR OPERATION
WITH
ACCUMULATOR

1007

MOV [1400],AX

A3,00,14

1009

HLT

F4

MOVE DATA IN
MEMORY
TO
ACCUMULATOR
STOP

OUT PUT:
IN PUT:
IN PUT
ADDRESS

DATA

OUT PUT
ADDRESS

DATA

Result:
Thus, the programs for Logical operations have been executed using
8086 Microprocessor
EXPT NO:
DATE:

SORTING AND SEARCHING


(USING 8086)

AIM:
To write an Assembly Language Program (ALP) for sorting and searching operations using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

Power chord

ALGORITHM:

(i)

(ii)

(iii)

PROGRAM FOR STRING PRIMITIVE:


a) Start the program.
b) Get the number of count to be made.
c) Load the output address in the destination index.
d) Load the input value to the accumulator.
e) Store the result in required memory locations using STO.
f) Stop the program.
STRING MANIPULATION:
a) Start the program.
b) Load the input address in the source index.
c) Load the output address in the destination index.
d) Get the number of count to be made.
e) Store the result in required memory location.
f) Stop the program.
CALCULATING THE LENGTH OF THE STRING:

a)
b)
c)
d)
e)
f)
g)

Start the program.


Load the input address to the source index.
Load the data to any other general purpose register.
Load the data to accumulator.
Compare the accumulator higher and lower bit.
Store the result in required memory location.
Stop the program.

3. PROGRAMS FOR STRING MANIPULATION OPERATIONS (USING 8086)


A-PROGRAM FOR STRING PRIMITIVE (USING 8086)

ADDRESS

LOOP

MNEMONICS

OPCODE

COMMENTS

1000

MOV CX, 0010

B9 10 00

1003

MOV DI,[1100]

BF 00 11

1006

MOV AX, 0034

B8 34 00

1009

CLD

FC

STO SB

AA

100B

LOOP L1

E2 FD

Store byte till


assigned address
Move to loop L1

100D

HLT

F4

Stop

100A

L1

Count the value of


array
Declare destination
index
Move the data to
accumulator
Clear direction

3. PROGRAMS FOR SORTING AND SEARCHING (USING 8086)


B-STRING MANIPULATION USING 8086

ADDRESS
1000

1003

1006

LABEL

MNEMONICS
MOV SI [1100]
OFFSET
S_ARRAY
MOV DI [1200]
OFFSET
D_ARRAY

OP-CODE
BE 00 11

MOV CX 0005

B9 05 00

BF 00 12

COMMAND
MOVE ADDRESS
TO SOURCE
INDEX
MOVE ADDRESS
TO DESTINATION
INDEX
DECLARE THE

SIZE OF ARRAY
ELEMENT
1009
100A
100B

L1

100D

CLD

FC

MOVE SB
LOOP L1

A4
E2 FD

HLT

F4

CLEAR
DIRECTION
MOVE DATA
MOVE TO LOOP
L1
STOP THE
PROGRAM

OUT PUT:
IN PUT:
IN PUT
ADDRESS

OUT PUT
ADDRESS

DATA

DATA

3. PROGRAMS FOR SORTING AND SEARCHING (USING 8086)


C-CALCULATING THE LENGTH OF STRING
ADDRESS
1000

LABEL

1003
1006

1008

L1

MNEMONICS
MOV SI [1100]

OP-CODE
BE 00 11

MOV DX
FFFF
MOV AH FF

BA FF FF

INC DX

42

B4 FF

COMMAND
MOVE ADDRESS
TO SOURCE
INDEX
MOVE DATA TO
REGISTER
MOVE DATA TO
ACCUMULATOR
HIGHER BIT
INCREMENT ON

1009

MOV [AL] SI

100B

INC SI

100C

CMP AH AL

100E

JNZ L1

1010

MOV [1200]
DX

1014

HLT

IN PUT:
IN PUT
ADDRESS

DX
8A 04
MOVE SOURCE
INDEX TO ACC.
LOWER
48
INCREMENT ON
SI
38 C4
COMPARE ACC.
HIGHER AND
LOWER
75 F8
JUMP NO ZERO
MOVE TO L1
89 16 00 12
MOVE
REGISTER TO
1200
F4
STOP THE
PROGRAM
OUT PUT:
OUT PUT
ADDRESS

DATA

DATA

Result:
Thus, the programs for Sorting and searching operations have been executed using 8086
Microprocessor
4. EXPT NO:

CODE CONVERSION

DATE:

(USING 8086)
PROGRAMS FOR BCD NUMBER TO BINARY NUMBER

AIM:
To write an assembly language program (alp) for BCD number to binary number using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

PROGRAM
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
BCD_NUM EQU 4576H
BIN_NUM DW (?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BX, BCD_NUM
MOV CX,0
CONT: CMP BX,0
JZ EPRG
MOV AL,BL
SUB AL,01
DAS
MOV AL,BH
SBB AL,00
DAS
MOV BH,AL
INC CX
JMP CONT
EPRG: MOV BIN_NUM,CX
MOV AH.4CH
INT 21H
CODE ENDS
END START

Result:
Thus, the programs for BCD NUMBER TO BINARY NUMBER
have been executed using 8086 Microprocessor

PROGRAMS FOR BINARY NUMBER TO BCD NUMBER


AIM:
To write an assembly language program (alp) for binary number to BCD number using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

PROGRAM

ASSUME CS: CODE, DS: DATA

DATA SEGMENT
BIN EQU 4576H
RES DW (?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BX, BIN
MOV AX,0
MOV CX,0
CONT: CMP BX,0
JZ EPRG
DEC BX
MOV AL,CL
ADD AL,01
DAA
MOV CL,AL
MOV AL,CH
ADC AL,00
DAA
MOV CH,AL
JMP CONT
EPRG: MOV RES,CX
MOV AH.4CH
INT 21H
CODE ENDS
END START

Result:
Thus, the programs for BINARY NUMBER TO BCD NUMBER have been executed using 8086
Microprocessor
PROGRAMS FOR 8-BIT BINARY NUMBER TO GRAY CODE
AIM:
To write an assembly language program (ALP) for binary number to gray code using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
NUM EQU 45H
RES DB (?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL, NUM
MOV BL,AL
CLC
RCR AL,1
XOR BL,AL
MOV RES,BL
MOV AH.4CH
INT 21H
CODE ENDS
END START

PROGRAM

Result:
Thus, the programs for BCD NUMBER TO ASCII NUMBER have been executed using 8086
Microprocessor
ARITHMETIC OPERATIONS USING MASM SOFTWARE
AIM:
To perform arithmetic operations such as addition,subtraction, multiplication division
operations using MASM software.
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
0PR1 EQU 98H
0PR2 EQU 49H
SUM DW 01 DUP(00)
SUBT DW 01 DUP(00)

PROD DW 01 DUP(00)
DWS DW 01 DUP(00)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV BL,0PR2
XOR AL,AL
MOV AL,0PR1
ADD AL,BL
DAA
MOV BYTE PTR SUM,AL
JNC MSB0
INC [SUM+1]
MSB0:XOR AL,AL
MOV AL,0PR1
SUB AL,BL
DAS
MOV BYTE PTR SUBT,AL
JNB MSB1
INC [SUBT+1]
MSB1:XOR AL,AL
MOV AL,0PR1
MUL BL
MOV WORD PTR PROD,AX
XOR AH,AH
MOV AL,0PR1
DIV BL
MOV WORD PTR DWS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START

Result:
Thus, the programs for decimal arithmetic operations have been executed using MASM

PROGRAMS FOR MATRIX ADDTION (3*3 MATRIX) USING MASM SOFTWARE


AIM:
To perform matrix addition (3*3 matrix) using MASM software.
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

PROGRAM
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
DIM EQU 09H
MAT1 DB 01, 01, 01, 01, 01, 01, 01, 01, 01
MAT2 DB 01, 01, 01, 01, 01, 01, 01, 01, 01
MAT3 DW 09H DUP (?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,DIM
MOV SI,OFFSET MAT1
MOV DI,OFFSET MAT2
MOV BX, OFFSET MAT3
NEXT: XOR AX,AX
MOV AL,[SI]

ADD AL,[DI]
MOV WORD PTR [BX],AX
INC SI
INC DI
ADD BX,02
LOOP NEXT
MOV AH.4CH
INT 21H
CODE ENDS
END START

Result:

Thus, the programs for matrix addition have been executed using MASM

PROGRAMS FOR MATRIX MULTIPLICATION (3*3 MATRIX) USING MASM SOFTWARE


AIM:
To perform matrix addition (3*3 matrix) using MASM software.
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE
PROGRAM

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ROCOL EQU 03H
MAT1 DB 01, 01, 01, 01, 01, 01, 01, 01, 01
MAT2 DB 01, 01, 01, 01, 01, 01, 01, 01, 01
MAT3 DW 09H DUP (?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CH,ROCOL
MOV SI,OFFSET MAT1
MOV BX, OFFSET MAT3
NEXTROW: MOV DI,OFFSET MAT2
MOV CL,ROCOL

NEXTCOL: MOV DL,ROCOL


MOV BP,0000H
MOV AX,0000H
SAHF
NEXT_ELE: MOV AL,[SI]
MUL BYTE PTR [DI]
ADD BP,AX
INC SI
ADD DI,03
DEC DL
JNZ NEXT_ELE
SUB DI,08
SUB SI,03
MOV [BX],BP
ADD BX,02
DEC CL
JNZ NEXTCOL
ADD SI, 03
DEC CH
JNZ NEXTROW
MOV AH.4CH
INT 21H
CODE ENDS
END START

RESULT:
Thus, the programs for matrix addition have been executed using MASM

EXPT NO:

STRING MANIPULATION

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) for string manipulation operations using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

Power chord

ALGORITHM:
(i)

DESCENDING ORDER OF AN ARRAY:


a) Start the program.
b) Store the total number of elements in c register.
c) Store the data in accumulator.
d) Compare the first element with the second element, which is placed after two bytes.
e) If second elements are lesser, continue comparison with next data else exchange both
the elements.
f) Decrement the count value.
g) Continue until count value becomes zero.
h) Store the contents in memory location.
i) Stop the program.

(ii)

ASCENDING ORDER OF AN ARRAY:


a) Start the program.
b) Get the numbers to be stored from the memory locations.
c) Compare the first two numbers and if the first number is larger than second then
interchange the number.
d) If the first number is smaller, go to step d.
e) Repeat steps b and c until the numbers are in required order.
f) Stop the program.

(iii)

LARGEST NUMBER IN AN ARRAY:

a)
b)
c)
d)
e)
f)
g)
h)

Start the program.


Place all the elements of an array in the consecutive memory locations.
Fetch the first element from the memory location and load it in the accumulator.
Initialize a counter (register) with the total number of elements in an array.
Decrement the counter by 1.
Increment the memory pointer to point to the next element.
Compare the accumulator content with the memory content (next element).
If the accumulator content is larger, then move the memory content (largest element)
to the accumulator. Else continue.
i) Decrement the counter by 1.
j) Repeat steps e to h until the counter reaches zero.
k) Store the result (accumulator content) in the specified memory location.
l) Stop the program.
(iv)

SMALLEST NUMBER IN AN ARRAY:


a) Start the program.
b) Place all the elements of an array in the consecutive memory locations.
c) Fetch the first element from the memory location and load it in the accumulator.
d) Initialize a counter (register) with the total number of elements in an array.
e) Decrement the counter by 1.
f) Increment the memory pointer to point to the next element.
g) Compare the accumulator content with the memory content (next element).
h) If the accumulator content is smaller, then move the memory content (largest
element) to the accumulator. Else continue.
i) Decrement the counter by 1.
j) Repeat steps e to h until the counter reaches zero.
k) Store the result (accumulator content) in the specified memory location.
l) Stop the program.

(v)

SEARCH A NUMBER IN AN ARRAY:


a) Start the program.
b) Load the input address in the source index.
c) Load the output address in the destination index.
d) Store the count value.
e) Increment source index.
f) Load the source index to the accumulator.
g) Increment source index.
h) Compare the present value stored in the accumulator and next value stored in the
source index.
i) If zero, then end else repeat from step e to g.
j) Store the result in the specified memory location.
k) Stop the program.

PROGRAM:
DESCENDING ORDER OF AN ARRAY
ADDRES
S
1000
1002
1005

LABE
L
START

MNEMONIC
S
MOV BL,00
MOV SI,1200
MOV CL,[SI]

OPCODE
B3 00
BE 00 12
8A 0C

1007
1009
100A

DEC CL
INC SI
MOV AL,[SI]

FE C9
46
8A 04

100C
100D

INC SI
CMP AL,[SI]

46
3A 04

100F
1011

JC LOOP L1
MOV DL,[SI]

72 0A
8A 14

1013

MOV [SI],AL

88 04

1015
1016

DEC SI
MOV [SI],DL

4E
88 14

1018
1019
101B
101D
101F
1021
1023

INC SI
MOV BL,01
DEC CL
JNZ LOOP
DEC BL
JZ START
HLT

46
B3 01
FE C9
75 EB
FE CB
74 DD
F4

L1

COMMAND
COUNT THE VALUE OF ARRAY
MOVE THE DATA TO SOURCE INDEX
MOVE THE MEMORY CONTENT TO
COUNT REGISTER
DECREMENT COUNT REGISTER
INCREMENT SOURCE INDEX
MOVE THE MEMORY CONTENT SOURCE
INDEX TO ACCUMULATOR
INCREMENT SOUREC INDEX
COMPARE THE MEMORY CONTENT OF
SOURCE INDEX WITH ACCUMULATOR
JUMP ON CARRY
MOVE THE MEMORY CONTENT OF
SOURCE INDEX TO DATA REGISTER
MOVE THE CONTENT OF ACCUMULATOR
TO ADDRESS OF SOURCE INDEX
DECREMENT SOURCE INDEX
MOVE THE CONTENT OF DATA REGISTER
TO ADDRESS OF SOURCE INDEX
INCREMENT SOURCE INDEX
MOVE THE DATA TO BASE REGISTER
DECREMENT COUNT REGISTER
JUMP ON NO ZERO
DECREMENT BASE REGISTER
JUMP ON ZERO
STOP

ASCENDING ORDER OF AN ARRAY

ADDRES
S
1000
1002
1005

LABE
L
START

MNEMONIC
S
MOV BL,00
MOV SI,1200
MOV CL,[SI]

OPCODE
B3 00
BE 00 12
8A 0C

1007
1009
100A

DEC CL
INC SI
MOV AL,[SI]

FE C9
46
8A 04

100C
100D

INC SI
CMP AL,[SI]

46
3A 04

100F
1011

JNC LOOP L1
MOV DL,[SI]

72 0A
8A 14

1013

MOV [SI],AL

88 04

1015
1016

DEC SI
MOV [SI],DL

4E
88 14

1018
1019
101B
101D
101F
1021
1023

INC SI
MOV BL,01
DEC CL
JNZ LOOP
DEC BL
JZ START
HLT

46
B3 01
FE C9
75 EB
FE CB
74 DD
F4

L1

COMMAND
COUNT THE VALUE OF ARRAY
MOVE THE DATA TO SOURCE INDEX
MOVE THE MEMORY CONTENT TO
COUNT REGISTER
DECREMENT COUNT REGISTER
INCREMENT SOURCE INDEX
MOVE THE MEMORY CONTENT SOURCE
INDEX TO ACCUMULATOR
INCREMENT SOUREC INDEX
COMPARE THE MEMORY CONTENT OF
SOURCE INDEX WITH ACCUMULATOR
JUMP ON NO CARRY
MOVE THE MEMORY CONTENT OF
SOURCE INDEX TO DATA REGISTER
MOVE THE CONTENT OF ACCUMULATOR
TO ADDRESS OF SOURCE INDEX
DECREMENT SOURCE INDEX
MOVE THE CONTENT OF DATA REGISTER
TO ADDRESS OF SOURCE INDEX
INCREMENT SOURCE INDEX
MOVE THE DATA TO BASE REGISTER
DECREMENT COUNT REGISTER
JUMP ON NO ZERO
DECREMENT BASE REGISTER
JUMP ON ZERO
STOP

LARGEST NUMBER IN AN ARRAY

ADDRES
S
1000
1003
1004

L1

MOV BX,0005
DEC BX
MOV CX,BX

OPCODE
BB 05 00
4B
8B CB

L2

MOV SI,1100
MOV AL,[SI]

BE 00 11
8A 04

100B
100C

INC SI
CMP AL,[SI]

46
3A 04

100E
1010

JNC L3
XCHG AL,[SI]

73 05
86 04

MOV[SI-1],AL
LOOP L2
DEC BX
JNZ L1
MOV[1200],A
L
HLT

88 44 FF
E2 F2
4B
75 EA
A2 00 12

1006
1009

1012
1015
1017
1018
101A

LABEL MNEMONICS

L3

101D

F4

COMMANDS
COUNT THE VALUE OF ARRAY
DECREMENT BX REGISTER
MOVE THE CONTENT OF BX TO CX
REGISTER
MOVE THE DATA TO SI
MOVE THE MEMORY CONTENT OF SI TO
AL
COMPARE AL AND MEMORY CONTENT OF
SI
JUMP NO CARRY TO LOOP L3
EXCHANGE AL WITH MEMORY CONTENT
OF SI
MOVE THE CONTENT OF AL TO SI
MOVE TO LOOP L2
DECREMENT BX REGISTER
JUMP ON NO ZERO TO LOOP L1
MOVE THE CONTENT OF AL TO OUTPUT
MEMORY
STOP THE PROGRAM

SMALLEST NUMBER IN AN ARRAY


ADDRES
S
1000
1003
1004

L1

MOV BX,0005
DEC BX
MOV CX,BX

OPCODE
BB 05 00
4B
8B CB

L2

MOV SI,1100
MOV AL,[SI]

BE 00 11
8A 04

100B
100C

INC SI
CMP AL,[SI]

46
3A 04

100E
1010

JC L3
XCHG AL,[SI]

73 05
86 04

MOV[SI-1],AL
LOOP L2
DEC BX
JNZ L1
MOV[1200],A

88 44 FF
E2 F2
4B
75 EA
A2 00 12

1006
1009

1012
1015
1017
1018
101A

LABEL MNEMONICS

L3

COMMANDS
COUNT THE VALUE OF ARRAY
DECREMENT BX REGISTER
MOVE THE CONTENT OF BX TO CX
REGISTER
MOVE THE DATA TO SI
MOVE THE MEMORY CONTENT OF SI TO
AL
COMPARE AL AND MEMORY CONTENT OF
SI
JUMP ON CARRY TO LOOP L3
EXCHANGE AL WITH MEMORY CONTENT
OF SI
MOVE THE CONTENT OF AL TO SI
MOVE TO LOOP L2
DECREMENT BX REGISTER
JUMP ON NO ZERO TO LOOP L1
MOVE THE CONTENT OF AL TO OUTPUT

L
HLT

101D

MEMORY
STOP THE PROGRAM

F4

SEARCH A NUMBER IN AN ARRAY


ADDRES
S
1000
1003
1006

MOV SI,1200
MOV DI,1500
MOV CL,[SI]

OPCODE
BE 00 12
BF 00 15
8A 0C

1008
1009

INC SI
MOV AL,[SI]

46
8A 04

100B
100C

LOOP

INC SI
CMP AL,[SI]

46
3A 04

END

JZ END
INC SI
DEC CL
JNZ LOOP
MOV AL,0FFH
MOV [SI],AL
MOV BL,[SI]

74 09
46
FE C9
75 F7
B0 FF
88 04
8A 1C

MOV [DI],BL
INT 02H
HLT

88 1D
CD 02
F4

100E
1010
1011
1013
1015
1017
1019
101B
101D
101F

LABEL MNEMONICS

COMMAND
MOVE THE DATA TO SI
MOVE THE DATA TO DI
MOVE THE MEMORY CONTENTS OF
SI TO CL
INCREMENT SI
MOVE THE MEMORY CONTENTS OF
SI TO AL
INCREMENT SI
COMPARE THE MEMORY CONTENT
OF SI WITH AL
IF JUMP ON ZERO THEN END
INCREMENT SI
DECREMENT CL
JUMP ON NO ZERO
MOVE THE DATA TO AL
MOVE THE CONTENT OF AL TO SI
MOVE THE MEMORY CONTENT OF SI
TO BL
MOVE THE CONTENT OF BL TO DI
IN
STOP

Result:
Thus, the programs for sorting and searching have been executed using 8086 Microprocessor

EXPT NO:

COUNTERS AND DELAY PROGRAM

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) for string manipulation operations using 8086.
APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

Power chord

Write a program for delay of 8.96 ms if frequency of mp is 10 M Hz


Mov bx, 64h
Repe:Mov cx,32h
Back: Dec cx
Jnz back
Dec bx
Jnz repe
Result:
Thus, the programs for delay program have been executed using 8086 Microprocessor

EXPT NO:
DATE:

SYSTEM DATE
(USING 8086)

Program for Setting System Date


AIM:
To write an assembly language program (alp) Setting System Date using MASM software.
APPARATUS REQUIRED:
SL.NO

ITEM

1.

PC

2.

Keyboard

MASM SOFTWARE

PROGRAM
.model small
.stack 100
.data
MES DB 10,13,ENTER THE DATE WITH FORMAT: DD: MM :YY $
MES 1 DB 10,13,DATE :$
BUFF DB 10
DB 0
DB 10 DUP(0)
YY DB ?
MM DB ?
D DB ?
.CODE
START: MOV AX, @DATA
MOV DX,AX
CALL P_DATA
MOV AH,4CH
INT 21H
P_DATE PROC NEAR
MOV AH, 09H
LEA DX,MES
INT 21H
MOV AH, 09H
LEA DX,MES1
INT 21H
MOV AH, 0AH
LEA DX,BUFF
INT 21H

BACK;

TER:

BACK1:

TER1:

BACK2

MOV CL,4
MOV DL,00H
LEA SI,BUFF
ADD SI,2
MOV AL,[SI]
CMP AL,:
JZ TER
ROL DL.CL
SUB AL,30H
ADD DL,AL
INC SI
JMP BACK
MOV DH,DL
AND DL,-F0H
ROR DL,CL
MOV AL,10
MUL DL
AND DH,-0FH
ADD AL,DH
MOV D,AL
MOV DL,0
INC SI
MOV AL,[SI]
CMP AL,:
JZ TER1
ROL DL,CL
SUB AL,30H
ADD DL, AL
INC SI
JMP BACK1
MOV DH,DL
AND DL,0F0H
ROR DL,CL
MOV AL,10
MUL DL
AND DH,0FH
ADD AL,DH
MOV MM,AL
MOV DL,0
INC SI
MOV AL,[SI]
CMP AL,13
JZ TER2
ROD DL,CL

SUB AL,30H
ADD DL,AL
INC SI
JMP BACK2
TER2:
MOV DH,DL
AND DL,PFPH
ROR DL,CL
SUB AL,30H
ADD DL,AL
INC SI JMP BACK2
SKIP2: MOV AH,2BH
MOV CL,YY
MOV CH,00
ADD CX,2000
MOV DH,MM
MOV DL,D
INT 21H
RET
P_DATE ENDP
END
RESULT:
Thus, the programs for setting the system time have been executed using MASM

TRAFFIC LIGHT CONTROLLER USING 8086


AIM
To write an assembly language program to interface traffic light controller with 8086 using 8255.
APPARATUS REQUIRED
8086 Microprocessor kit,
Power chord,
Traffic light interface board

26 channel bus
ALGORITHM
1. Find the control word for 8255 and data corresponding to the given conditions and load this
data in to the memory location.
2. Get the number of conditions in the C-register.
3. Move the control word to accumulator and place in 8255.
4. Move the first data to accumulator and place in port-A.
5. Move the next data to accumulator and place in port-B.
6. Move the next data to accumulator and place in port-C.
7. Call the delay routine.
8. Decrement the C-register. If C=0 then go to next step else go to step 3.
9. Go to step 1 and Stop

PROGRAM

MEMOR
Y
ADDRES
S

LABEL

1000

START:

1003
1006
1008
100A
100B
100D
100F
1010
1012
1014
1017

NEXT:

MNEMONIC
S
MOV
BX,1100H
MOV
CX,000CH
MOV AL,
[BX]
OUT
CONTRL,AL
INC BX
MOV AL,
[BX]
OUT
PORTA,AL
INC BX
MOV AL,
[BX]
OUT
PORTB,AL
INC BX
MOV AL,
[BX]

OP CODE
BB 00 11
B9 00 0C
8A 07
E6 0F
43
8A 07
E6 0C
43
8A 07
E6 OD
43
8A 07

OUT
PORTC,AL
CALL
DELAY
INC BX
LOOP NEXT:
JMP START

1019
101B
101E
1021
1023
1024

DELAY:

1025
1028
103B
103C

REPEA
T:
LOOP2:

103E
103F
1040

1100
1104
1107

PUSH CX
MOV
CX,0005H
MOV
DX,0FFFFH
DEC DX
JNZ LOOP2
LOOP
REPEAT
POP CX
RET

E6 0E
E8 07 00
43
E2 ED
EB DF
51
B9 00 05
BA FF FF
4A
75 FD
E2 F8
59
C3

INPUT DATA
80, 84, 2E, 4C
84, 9D, 90, 93
2B, 10, 64, 27, 12

PORT A [ {D0 - D20}0 - OFF & 1 ON ]


D8

D7

D6

D5

D4

D3

D2

D1

POSITION 1

84H

POSITION 2

84H

POSITION 3

93H

POSITION 4

64H

PORT B [ {DL1 - DL8}0 - GREEN & 1 RED ]

POSITION
1

D20

D19

D18

D17

DL78

DL56

DL34

DL12

2EH

POSITION
2
POSITION
3
POSITION
4

9DH
2BH
27H

PORT C [ {D0 - D20}0 - OFF & 1 ON ]


D16

D15

D14

D13

D12

D11

D10

D9

POSITION 1

POSITION 2

POSITION 3

POSITION 4

4CH
90H
10H
12H

RESULT
Thus the assembly language program to interface traffic light controller with 8086 using 8255
was written and executed successfully.

EXPT NO:

INTERFACING AND PROGRAMMING OF STEPPER

DATE:

MOTOR
STEPPER MOTOR INTERFACING

AIM:

To write an assembly language program to interface stepper motor with 8086.

APPARATUS REQUIRED:

SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

3.

Power chord

4.

Stepper motor

5.

Interface board

6.

50 Channel Bus

Stepper motor

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

A2

CLOCKWISE

STE

B2

DATA

STE

9h

5h

6h

Ah

B2

DATA

Ah

6h

5h

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 uses 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 are translated to high voltage output pulses using a

buffer 7407 with open collector.

PROGRAM:
TO RUN STEPPER MOTOR AT DIFFERENT SPEEDS

ADDRES
S
1000

LABEL

MNEMONICS

START:

1002
1005
1008
100A
100C
100F

FORWD:

1011
1014
1017
1019
101B
101E

REVER:

MOV BL,20H
MOV DI,OFFSET
FORW
CALL ROTATE
DEC BL
JNZ FORWD
CALL DELAY
MOV BL,20H
MOV DI,OFFSET
REV
CALL ROTATE
DEC BL
JNZ REVER
CALL DELAY
JMP START

1020
1022
1024
1026
1029
102A
102C
102D
102F
1030
1033
1034

ROTATE
:
REPT:

LOOP1:

DELAY:
75 FD

MOV CL,04
MOV AL,[DI]
OUT PORT1,AL
MOV DX,1010H
DEC DX
JNZ LOOP1
INC DI
LOOP REPT
RET
MOV DX,0FFFFH
DEC DX
JNZ DELAY

OPCOD
E
B3 20
BF 37 10
E8 1800
FE CB
75 F6
E8 21 00
B3 20
BF 3B 10
E8 09 00
FE CB
75 F6
E8 12 00
EB E0
B1 04
8A 05
E6 C0
BA 1010
4A
75 FD
47
E2 F3
C3
BA FFFF
4A

1036

RET

1037

FORW:

9,5,6,0AH

103B

REV:

0AH,6,5,9

C3
09 05 06
0A
0A 06 05
09

A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED


MEMORY
ADDRESS
1000

LABEL

MNEMONICS

OPCODE

START

MOV D1 offset
table (1014)

BF,14,10

MOV CL, 04

B1,04

MOV AL,[D1]

8A,05

1007

OUT
PORT1,AL

E6,C0

1009

MOV DX,1010

BA,10,10

DEC DX

4A

100D

JNZ DELAY

75,FD

100F

INC D1

47

1010

LOOP LOOP1

E2,F3

1012

JMP START

EB,EC

DB

09,05,06,0A

1003
1005

100C

1014

LOOP1

DELAY

TABLE

EXPT NO:

PROGRAMS FOR DIGITAL CLOCK AND STOP WATCH

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) to display the Computers real-time clock on the
screen as in digital clock.

APPARATUS REQUIRED:
SL.NO

ITEM

1.

Macro assembler

2.

PC

SPECIFICATION
software

QUANTITY
1
1

THEORY:
CLOCK DISPLAY:
Every PC is equipped with a real-time clock operated by a small battery. Even when the computer is
switched off, this clock continues to function to maintain the clock in its CMOS registers. When the PC is
on, the Operating System software reads this clock and stores the value in memory. User programs can
access this data. The OS software provides facilities for the programmer to read this clock value using
Software Interrupts. The IBM PC system BIOS also provides interrupt services to access this real time
clock. The BIOS services provide the hours, minutes and seconds in CPU registers as BCD data. Hence
they can be converted easily into ASCII value for displaying on screen.

STOP WATCH DISPLAY:


Every PC is equipped with BIOS that contains software to initialize the built in Timer IC to produce ticks
with a periodicity of 18.2 ticks per every second. This does not rely on the real-time clock usually
incorporated in the PC. The BIOS maintains the number of ticks elapsed since midnight or power-on of
the machine. BIOS Interrupt 1Ah service provides the number of ticks elapsed at any time. One can use
this service repeatedly to check for completion of 18 ticks, which would mean an approximate 1-second
time gap. This can be used to update a memory variable to count seconds. After 60 seconds counting, the
minute variable can be updated. Thus a stopwatch can be made to operate at the press of a key.

ALGORITHM:
1. CLOCK DISPLAY PROGRAM:
a)
b)
c)
d)
e)
f)
g)

Initialize data segment to hold the clock data as hours, minutes and seconds.
Display a message on screen for the user.
Call the procedure to get the time from PCs real-time clock using BIOS interrupt.
Call the procedure to convert the clock data into ASCII and display it on the screen.
Check for user key press using BIOS interrupt service.
If no key is pressed continue updating the clock on screen.
If a key is pressed terminate the program.

Procedure Get Time:


a) Use Function 02 in Interrupt 1Ah service to read the PCs real-time clock. This function returns
hours in CH, minutes in CL and seconds in DH registers.
b) Divide each of these registers by 10h to separate the BCD digits.
c) Convert each separated digit into ASCII by adding 30h with it.
d) Store each digit in the appropriate location in the memory.
e) Return from the procedure.
Procedure ShowTime:
a) Use BIOS interrupt 10h function 02h to set video cursor at desired location on the screen.
b) Use DOS interrupt 21h function 09h to display the stored clock data from Data segment memory
as a string terminated by $.
c) Call a procedure to delay for few milliseconds doing nothing.
d) Return from the procedure.
Procedure Delay:
a)
b)
c)
d)
e)

Load a value in CX register.


Do nothing.
Decrement CX register by one.
Loop until CX register is zero.
Return from the procedure.

2. STOP WATCH DISPLAY:


a)
b)
c)
d)
e)
f)
g)

Initialize Data Segment Register


Display a friendly message using DOS Int 21h function 09h
Call the procedure to show the watch with zero values
Check for user key press using BIOS Int 16h function 01h
If no key is pressed go to step 4
On key press, call the procedure to start the watch.
On return from the procedure terminate the program

Procedure Show watch:


a) Position the video cursor at the desired location on screen using BIOS Int 10h function 02h
b) Display the watch data in memory using DOS Int 21h function 09h
c) Return from the procedure
Procedure Start Watch:
a)
b)
c)
d)
e)
f)
g)
h)
i)
j)
k)
l)
m)
n)
o)
p)
q)
r)

Get the current tick value using BIOS Int 1Ah function 00h
Store the last two digits of the returned value in DL into BL. This becomes the old value
Get the current tick value using BIOS Int 1Ah function 00h
Subtract the old value from the new value
Check whether it is 18 (which means 1 second)
If it is less than 18, goto step 3
If it is equal to 18, then increment LSD of seconds.
If LSD is greater than 9, proceed to increment MSD of seconds and make LSD of seconds equal
to 0
Upon incrementing MSD of seconds if it is equal to 6, then make MSD equal to 0 and proceed to
update minutes.
Increment LSD of minutes.
If LSD of minutes is greater than 9, increment MSD of minutes and make LSD equal to 0
If MSD of minutes is equal to 6, then make minutes and seconds equal to 0.
Call the procedure to Show the Watch.
Check for User key press using BIOS Int 16h function 01h.
If there is no key press proceed to step 1
If there is a key pressed, check whether that key is q.
If the key pressed is q, then return from the procedure.
Otherwise, go to step 1

PROGRAM:
CLOCK DISPLAY PROGRAM
.MODEL SMALL

.STACK
.DATA
MESSAGE DB 0AH,0DH
MESSAGE1 DB 0AH,0DH
PROMPT DB TIMER::
HOURS1 DB 0
HOURS2 DB 0
SEPERATOR1 DB :
MINUTES1 DB 0
MINUTES2 DB 0
SEPERATOR2 DB :
SECONDS1 DB 0
SECONDS2 DB 0
LAST DB $
DIVISOR DB 10H
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AH,09H
LEA DX,MESSAGE
INT 21H
AGAIN:CALL GETTIME
CALL SHOWTIME
MOV AH,01H
INT 16H
JZ AGAIN
MOV AH,04CH
INT 21H
GET TIME PROC
MOV AH,02H
INT 1AH
MOV AL,CH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV HOURS1,AL
MOV HOURS2,AH
XOR AX,AX
MOV AL,CL
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV MINUTES1,AL
MOV MINUTES2,AH

XOR AX,AX
MOV AL,DH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV SECONDS1,AL
MOV SECONDS2,AH
RET
GET TIME ENDP
SHOW TIME PROC
MOV AH,02H
MOV BH,0
MOV DH,20D
MOV DL,10D
INT 10H
MOV AH,09H
LEA DX,PROMPT
INT 21H
CALL DELAY
RET
SHOW TIME ENDP
DELAY PROC
PUSH CX
MOV CX,0FFFH
IDLE:NOP
NOP
NOP
NOP
LOOP IDLE OUT
POP CX
RET
DELAY ENP
END
STOP WATCH DISPLAY
.MODEL SMALL
.STACK
.DATA
MESSAGE DB 0AH,0DH
MESSAGE1 DB 0AH,0DH
PROMPT DB TIMER::
MINUTES1 DB 0
MINUTES2 DB 0
SEPARATOR1 DB :

SECONDS1 DB 0
SECONDS2 DB 0
SEPERATOR2 DB .
LAST DB $
DIVISOR DB 10H
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AH,09H
LEA DX,MESSAGE
INT 21H
CALL SHOW WATCH
AGAIN: MOV AH,01H
INT 16H
JZ AGAIN
CALL START WATCH
MOV AH,04CH
INT 21H
START WATCH PROC
DOITAGAIN:MOV AH,00H
INT 1AH
MOV BL,DL
CHECKAGAIN:MOV AH,00H
INT 1AH
SUB DL,BL
CMP DL,18
JB CHECKAGAIN
MOV AL,SECONDS2
INC AL
CMP AL,39H
JBE UPDATE_SECONDS2
MOV AL,30H
MOV SECONDS2,AL
MOV AL,SECONDS1
INC AL
CMP AL,36H
JB UPDATE_SECONDS1
MOV AL,30H
MOV MINUTES2,AL
MOV AL,MINUTES2
INC AL
CMP AL,39H
JBE UPDATE_MINUTES2
MOV AL,30H

MOV MINUTES2,AL
MOV AL,MINUTES1
INC AL
CMP AL,36H
JB UPDATE_MINUTES1
MOV AL,0
UPDATE_MINUTES1:MOV MINUTES1,AL
JMP DONE
UPDATE_MINUTES2:MOV MINUTES2,AL
JMP DONE
UPDATE_SECONDS1:MOV SECONDS1,AL
JMP DONE
UPDATE_SECONDS2:MOV SECONDS2,AL
DONE:CALL SHOW_ WATCH
MOV AH,01H
INT 16H
JNZ CHECK_KEY
JMP DOITAGAIN
CHECK_KEY:MOV AH,00H
INT 16H
CMP AL,q
JNZ DOITAGAIN
RET
START_WATCH ENDP
SHOW_WATCH
PROC
MOV DH,10D
MOV DL,10D
MOV AH,02H
MOV BH,0
INT 10H
MOV AH,09H
LEA DX,PROMPT
INT 21H
RET
SHOW_WATCH
ENDP
END

EXPT NO:
DATE:

INTERFACING AND PROGRAMMING OF 8279 USING 8086

AIM:

To perform interfacing and programming using 8279, 8259 and 8253 using 8086.

APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

3.

Power chord

4.

50 channel bus

5.

8279 kit

ALGORITHM:
ROLLING DIAPLAY
a)
b)
c)
d)
e)
f)
g)
h)
i)
j)

Start the program.


Set 8279 for 8-bit character display right entry and a key lock out.
Clear the display.
Load the data to control register to write to the display.
Set the counter value.
Initialize the HL register pair and memory pointer.
Call the subroutine for delay procedure.
Increment H and decrement B register.
Repeat the steps e and h
Stop the program.
READ A KEY:

ADDRES
S
1000
1003
1005
1007
1009

LABE
L

LOOP:

MNEMONIC
S
MOV
BX,1100
IN AL,C2
TEST AL,07
JZ LOOP
MOV AL,40

OPCODE
BB 00 11
E4 C2
A8 07
74 FA
B0 40

100B
100D

OUT C2,AL
IN AL,C0
MOV
[BX],AL
HLT

100F
1011

E6 C2
E4 C0
88 07
F4

ROLLING DISPLAY (DISPLAY MESSAGE IS CSE- A)

ADDRES
S

LOOP

MNEMONIC
S

OPCODE

COMMANDS

1000

START

MOV SI,1200

BE 00 12

MOV
CX,000F
MOV AL,10
OUT C2,AL
MOV AL,CC
OUT C2,AL
MOV AL,90
OUT C2,AL

B9 0F 00

SET MODE COUNT AND


DISPLAY
MOVE 000F DATA IN CX

MOV AL,[SI]

8A 04

1014

OUT CO,AL

E6 C0

1016
1019

CALL DELAY E8 E7 04
INC SI
46

101A
101C

LOOP NEXT
JMP START

1003
1006
1008
100A
100C
100E
1010
1012

NEXT

B0 10
E6 C2
B0 CC
E6 C2
B0 90
E6,C2

E2 F6
EB E2

SET ACC DATA


CLEAR DISPLAY
MOVE CC DATA IN AL
SET PORT DATA
WRITE DISPLAY
CLEAR DISPLAY IN
RAM
LOP FOR THE
PRESSING OF KEY
SET TO READ FIFO
RAM
CALL DISPLAY DATA
GET THE
CORRESPONDING
CODE FORM LOOKUP
TABLE
GO TO NEXT
JUMP START

SUB PROGARM:
ADDRES
S
1500

LOOP

DELAY

MNEMONIC
S
MOV

OPCODE
BA FF

COMMANDS

MOVE THE

DX,A0FF

A0

1503

DEC DX

4A

VALUE TO
DX REGISTER
DECREMENT DX

1504

JNZ LOOP1

75 FD

JUMP NO ZERO

1506

RET

C3

RETURN

LOOK-UP TABLE
ADDRES

DATA

S
1200

FF,FF,FF,F

1204

F
FF,FF,FF,F

1208

F
68,6C,68,FF

120C

FF,38,FF,FF

EXPT NO:

INTERFACING AND PROGRAMMING OF PRINTER INTERFACE


USING 8086

DATE:
AIM:

To perform interfacing and programming Printer interface using 8086.

APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION
8086 kit

QUANTITY

1.

Microprocessor kit

2.

Keyboard

3.

Power chord

4.

50 channel bus

5.

Printer interface

6.

dot matrix Printer

PROGRAM
ADDRE
SS

LABE
L

1000
1002
1004
1006
1008
100A
100C
100E
1011
1013
1016
1017
1019

PRIN
T:

MNEMON
ICS
MOV
AL,05H
OUT
CONTL,AL
IN
AL,STUS
AND
AL,20H
CMP
AL,20H
JNZ ERR
MOV
AL,41H
CALL
PRINT
MOV
AL,0AH
CALL
PRINT
HLT
MOV
BL,AL
CALL
CHECK

OPCO
DE
B0 05
E6 D0
E4 C0
24 20
3C 20
75 44
B0 41
E8 06
00
B0 0A
E8 01
00
F4
8A D8
E8 10
00

101C

STAS:

101E
1020
1022
1024
1025
1026
1027
1029
102B
102C

CHEC
K:

102E
1030
1032
1034
1036
1038
103A
103C
1050
1052

ERR:

MOV
AL,BL
OUT
DATA,AL
MOV
AL,01H
OUT
CONTL,AL
NOP
NOP
NOP
MOV
AL,05H
OUT
CONTL,AL
RET
IN
AL,STUS
AND
AL,20H
JZ CHECK
IN
AL,STUS
AND
AL,80H
CMP
AL,80H
JNZ STAS
JMP
CHECK
HLT
INT 2
END

8A C3
E6 C8
B0 01
E6 D0
90
90
90
B0 05
E6 D0
C3
E4 C0
24 20
74 FA
E4 C0
24 80
3C 80
75 E2
EB F0
F4
CD 02

EXPT NO:

SERIAL COMMUNICATION BETWEEN TWO MP KITS

DATE:

USING 8251

AIM:
To perform serial communication between two microprocessor kits using 8251.
APPARATUS REQUIRED:

SL.NO

ITEM

SPECIFICATION

QUANTITY

1.

Microprocessor kit

8086 kit

2.

Keyboard

3.

Power chord

4.

VXT parallel bus

5.

Interface board

8251

6.

Serial connection cable

RS232

ALGORITHM:
a)
b)
c)
d)

Connect the two serial ports with RS232 cable.


First make the receiver end ready and then execute the program at transmitter end.
The transmitter transmits the data serially.
The receiver data is stored in the memory location given in the program.

TRANSMITTER PROGRAM
ADDRES
S
1000

MNEMONIC
S
MOV AL,36

OPCODE
BO 36

1002

OUT CE,AL

E6 CE

COMMANDS
MOVE THE VALUE TO
ACCUMULATOR
SEND DATA TO OUTPUT PORT

1004

MOV AL,10

B0 10

1006
1008

OUT C8,AL
MOV AL,00

E6 C8
B0 00

100A
100C

OUT C8,AL
MOV AL,4E

E6 C8
B0 4E

100E
1010

OUT C2,AL
MOV AL,37

E6 C2
B0 37

1012
1014

OUT C2,AL
MOV AL,AA

E6 C2
BO AA

1016
1018

OUT CO,AL
INT 02

E6 CO
CD 02

MOVE THE VALUE TO


ACCUMULATOR
SEND DATA TO OUTPUT PORT
MOVE THE VALUE TO
ACCUMULATOR
SEND DATA TO OUTPUT PORT
MOVE THE VALUE TO
ACCUMULATOR
SEND DATA TO OUTPUT PORT
MOVE THE VALUE TO
ACCUMULATOR
SEND DATA TO OUTPUT PORT
MOVE THE VALUE TO
ACCUMULATOR
SEND DATA TO OUTPUT PORT
INTERUPT

RECEIVER PROGRAM
ADDRES
S
1200
1202

OPCODE
E4 C0
BB 50 12

1205

MNEMONIC
S
IN AL,C0
MOV
BX[1250]
MOV BX,AL

1207

INT 02

CD 02

88 07

COMMANDS
INTERUPT
MOVE THE VALUE TO
ADDRESS
MOVE ACCUMULATOR
DATA TO BX
INTERUPT

INTERFACING 8255 WITH 8086


AIM:

To interface programmable peripheral interface 8255 with 8086 and study its characteristics in
mode0
APPARATUS REQUIRED:
1. 8086 p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
I/O MODES:
Control Word:

MODE 0 SIMPLE I/O MODE:


This mode provides simple I/O operations for each of the three ports and is suitable for
synchronous data transfer. In this mode, all the ports can be configured either as input or output port.
Let us initialize port A as input port

PROGRAM:
ADDRES
S
1000

LABE
L

1003
1005
1007
1009
100B

MNEMONIC
S
MOV SI ,
1500
MOV AL,90
OUT C6,AL
IN AL,C0
MOV [SI],
AL
HLT

OPCODE
S
BE 00 15
B0 90
E6 C6
E4 C0
88 04
F4

MODE 0 STROBED I/O MODE:


Let us initialize port A as input port and port B as output port
PROGRAM:
ADDRES
S

LABE
L

MNEMONIC
S

OPCODE
S

1000

MOV AL,90

B0 90

1002

OUT C6,AL

E6 C6

1004

IN AL,C0

E4 C0

1006

OUT C2 AL

E6 C2

1008

HLT

F4

RESULT:
Thus 8255 are interfaced and their characteristic in mode0 was studied.

EXPT NO:

PROGRAMS FOR INTERFACING ADC AND DAC

DATE:

(USING 8086)

AIM:
To write an Assembly Language Program (ALP) to interface ADC and DAC using 8086
microprocessor.

APPARATUS REQUIRED:
SL.NO

ITEM

SPECIFICATION

1.

Microprocessor kit

2.

Keyboard

Power chord

4.

ADC kit

5.

Multimeter

6.

DAC kit

7.

50 channel Bus

8.

CRO

9.

CRO probe

THEORY:

8086 kit

QUANTITY
1

ANALOG TO DIGITAL CONVERTER:


ADC-0809 A/D card is an 8bit analog to digital converter with 8 channel multiplexer and microprocessor
compatible control logic. The heart of the car is ADC-0809 monolithic C-MOS device. Its conversion
time is 100 micro sec. it eliminates the need for external zero and full scale adjustment. The card selects
one of the eight unipolar inputs by using the address decoder. ADC-0809 uses successive approximation
as conversion techniques. Input is latched to the decoder on the low to high transition of the address latch
enable signal. The conversion starts on the falling edge of the start of conversion signal. During the
process end of conversion signal goes low otherwise it remains high. Digital output can be read from
ADC making output enable signal high.
Circuit description:
The data line of ADC-0809 d0 to d7 is connected to port-A as input port. SOC is connected to PC0 as
output port; EOC is connected to PC4 as input port & ALE is connected to PC1 as output port. All eight
inputs of 0-5 volts ADC-0809 analog with external clock, external EOC, external SOC signals are brought
to 26 pin connector. A clock input of a specified frequency is required for the operation of ADC-0809. A
counter 74LS93 has been used for this purpose.
Hardware installation:

Connect ADC-0809 interfacing module to 8255-I of 8086 trainer kit through 26 pin FRC cable.
Be sure about the direction of the cable i.e. pin NO.1 of module should be connected to pin NO.1

of 8255 connector.
Connect +5v, GND from the trainer kit (+5v & GND signals are available in the 25 & 26 pin of
FRC 8255-I connector)

DIGITAL TO ANALOG CONVERTER:


A digital number can be converted to an analog voltage by selectively adding voltage which is
proportional to the weight of each binary digit. The module finds a great use in feedback system, like
output of a channel is fed to a control circuit to contain output in the form of signal is observed at an
oscilloscope or for a hard copy fed to an X-Y Recorder/X-T Recorder. Different wave forms can be
generated by using this DAC-0800 module.
Circuit description:
Port A & port B are connected to channel 1 and channel 2 respectively. A reference voltage of 8V is
generated using 723 and is given to verify points of the DAC 0800. The standard output voltage will be
7.98V when FF is outputted and will be 0v when 00 is outputted. The output of DAC-0800 is fed to the

operational amplifier to get the final output as X out and Y out. Several interesting waveforms can be
generated and observed on oscilloscope.
Hardware installation:

Connect DAC-0800 interfacing module to 8255-I of 8085/8051/80865 trainer kit through 26 pin

FRC cable.
Be sure about the direction of the cable i.e. pin No.1 of module should be connected to pin No.1

of 8255 connector.
Connect +12V, -12V & GND from the trainer kit.

ALGORITHM:
ANALOG TO DIGITAL CONVERTER:
a)
b)
c)
d)
e)
f)
g)
h)
i)
j)
k)
l)

Start the program.


Enter the control word.
Clear the register.
Move the register at AL=0.
Read EOC from Accumulator.
Read 16 bit ADC data.
Clear CALL display.
CALL display routine.
Load CX register as 0F0H.
Jump till CX=0.
Jump to start.
Stop the program.

DIGITAL TO ANALOG CONVERTER:


1) GENERATION OF SAWTOOTH WAVE
a) Start the program
b) Load the input value to the accumulator.
c) Move to C0.
d) Increment AL.
e) If jump on no carry then execute loop L1.
f) Jump on START.
g) Return.
h) Store the output in the required memory location.
i) Stop the program.
2) GENERATION OF SQUARE WAVE
a) Start the program
b) Load the input value to the accumulator.
c) Call the delay.
d) Jump on start.
e) Go to loop L1.

f) Return.
g) Store the output in the required memory location.
h) Stop the program.
3) GENERATION OF TRAINGULAR WAVE
a) Start the program.
b) Load the value in the accumulator.
c) Increment the BL register.
d) Jump on no zero.
e) Decrement the BL register.
f) Jump on no carry.
g) Return.
h) Store the output in the required memory location.
i) Stop the program.

PROGRAM:
ANALOG TO DIGITAL CONVERTER
ADDRESS
1000
1002

LABEL

MNEMONICS
MOV AL,03

OP-CODE
B0,03

COMMANDS
MOVE DATA TO

OUT C8,AL

E6,C8

ACCUMULATOR
MOVE THE
CONTENT OF
AL TO OUTPUT

1004

MOV AL,23

B0,23

PORT
MOVE DATA TO

1006

OUT C8,AL

E6,C8

ACCUMULATOR
MOVE THE
CONTENT OF
AL TO OUTPUT

1008

MOV AL,03

B0,03

PORT
MOVE DATA TO

100A

OUT C8,AL

E6,C8

ACCUMULATOR
MOVE THE
CONTENT OF
AL TO OUTPUT

100C

MOV AL,01

B0,01

PORT
MOVE DATA TO

100E

OUT D0,AL

E6,D0

ACCUMULATOR
MOVE THE
CONTENT OF
AL TO OUTPUT

1010

MOV AL,00

B0,00

PORT
MOVE DATA TO

1012

OUT D0,AL

E6,D0

ACCUMULATOR
MOVE THE
CONTENT OF
AL TO OUTPUT

1014

LOOP

IN AL,E0

E4,E0

PORT
MOVE THE
CONTENT OF
INPUT PORT TO

1016

AND AL,01

24,01

AL
PERFORM AND
OPERATION
WITH AL AND

1018

CMP AL,01

3C,01

DATA
COMPARE THE
VALUE OF AL

101A
101C

JNZ LOOP
IN AL,C0

75,F8

WITH DATA
JUMP ON NO

E4,C0

ZERO
MOVE THE
CONTENT OF
INPUT PORT TO

101E

MOV BX,1100

BB,00,11

AL
MOVE THE

1021

MOV[BX],AL

88,07

DATA TO BX
MOVE THE
CONTENT OF
AL TO BX

1023

HLT

F4

STOP

DIGITAL TO ANALOG CONVERTER


1. GENERATION OF SAWTOOTH WAVE
ADDRESS
1000

LABEL
START

MNEMONICS
MOV AL,00

OP-CODE
B0,00

COMMANDS
MOVE THE
DATA TO AL

1002

L1

OUT C0,AL

E6,C0

REGISTER
MOVE THE
CONTENT OF
AL TO OUTPUT

1004

INC AL

FE,C0

PORT C0
INCREMENT AL

1006

JNZ L1

75,FA

REGISTER
JUMP ON NO

EB,F6
C3

ZERO
JUMP TO START
RETURN

1008
100A

JMP START
RET

2. GENERATION OF SQUARE WAVE


ADDRESS
1000

LABEL
START

MNEMONICS
MOV AL,00

OPCODE
B0,00

COMMANDS
MOVE THE
DATA TO AL

1002

OUT C0,AL

E6,C0

REGISTER
MOVE THE
CONTENT OF
AL TO OUTPUT

1004

CALL DELAY

E8,09,00

PORT C8
CALL THE
DELAY

1007

MOV AL,FF

B0,FF

PROGRAM
MOVE THE
DATA TO AL

1009

OUT C0,AL

E6,C0

REGISTER
MOVE THE
CONTENT OF
AL TO OUTPUT

100B

CALL DELAY

E8,02,00

PORT C8
CALL THE
DELAY

100E

JMP START

EB,F0

PROGRAM
JUMP TO

1010

DELAY

MOV CX,05,FF

B9,FF,05

START
DECLARE THE

1013
1015

L1

LOOP L1
RET

E2,FE
C3

COUNT VALUE
GO TO LOOP L1
RETURN

3. GENERATION OF TRAINGULAR WAVE


ADDRESS
1000

LABEL
START

MNEMONICS
MOV BL,00

OP-CODE
B3,00

COMMANDS
MOVE THE
DATA TO BASE

1002

L1

MOV AL,BL

88,D8

REGISTER
MOVE THE
CONTENT BL
TO AL

1004

OUT C0,AL

E6,C0

REGISTER
MOVE THE
CONTENT OF
AL TO OUTPUT

1006

INC BL

FE,C3

PORT C8
INCREMENT
THE VALUE OF

1008

JNZ L1

100A

MOV BL,FF

75,F8

BL REGISTER
JUMP ON NO

B3,FF

ZERO
MOVE THE
DATA TO BL

100C

L2

MOV AL,BL

88,D8

REGISTER
MOVE THE
CONTENT BL
TO AL

100E

OUT C0,AL

E6,C0

REGISTER
MOVE THE
CONTENT OF
AL TO OUTPUT

1010

DEC BL

FE,CB

PORT C8
DECREMENT
THE VALUE OF

1012

JNC L2

75,F8

BL REGISTER
JUMP ON NO

1014

JMP START

EB,EA

CARRY
JUMP ON

1016

RET

C3

START
RETURN

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION


INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: a
DATE:
ADDITION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to add the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.

2. Move the first data to Accumulator.


3. Add the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6105
6108
6109

LABEL

LOOP

MNEMONICS

OP CODE

CLR C
MOV A,#data1
ADD A, #data2
MOV DPTR, #6500H
MOVX @DPTR, A
SJMP LOOP

C3
74, 3F
24, 29
90, 65, 00
F0
80, FE

OBSERVATION
INPUT
Address

RESULT

OUTPUT
Data
3F
29

Address

Data

6500

68

Thus, the assembly language program to add the two 8-bit numbers using 8051 instruction set
was written and executed successfully.
1. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: b
DATE:
SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to subtract the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Subtract the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6105
6108
6109

LABEL

LOOP

MNEMONICS
CLR C
MOV A,#data1
SUBB A, #data2
MOV DPTR, #6500H
MOVX @DPTR, A
SJMP LOOP

OP CODE
C3
74, 59
94, 28
90, 65, 00
F0
80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data
59
28

Address

Data

6500

31

COMMENTS

RESULT
Thus, the assembly language program to subtract the two 8-bit numbers was written and executed
successfully.

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION


INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: c
DATE:
MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to multiply the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.

7. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6106
6107
610A
610B

LABEL

MNEMONICS
CLR C
MOV A,#data1
MOV B,#data2
MUL AB
MOV DPTR, #6500H
MOVX @DPTR, A
INC DPTR

610C

MOV A, B

610E

MOVX @DPTR, A

610F

OP CODE

LOOP

C3
74, 04
75, F0, 02
A4
90, 65, 00
F0
A3
E5, F0
F0

SJMP LOOP

80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data
06

Address
6500

Data
18

04

6501

00

RESULT
Thus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction
set was written and executed

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION


INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: d
DATE:

DIVISION OF TWO 8-BIT NUMBERS USING 8051


AIM
To write an assembly language program to divide the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The remainder of the result is in B-register.
6. The quotient of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6106
6107
610A
610B

LABEL

MNEMONICS
CLR C
MOV A,#data1
MOV B,#data2
DIV AB
MOV DPTR, #6500H
MOVX @DPTR, A
INC DPTR

610C

MOV A, B

610E

MOVX @DPTR, A

610F

LOOP

OP CODE
C3
74, 08
75, F0, 02
84
90, 65, 00
F0
A3
E5, F0
F0

SJMP LOOP

80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data

Address

Data

3F

6500

02 (QU)

1E

6501

03(RE)

RESULT
Thus, the assembly language program to divide the two 8-bit numbers using 8051 instruction set
was written and executed successfully.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: e
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
ADDRESS
6100
6101
6103
6106
6107
610A
610B
610C

LABEL

MNEMONICS
MOV A, #data
CPL A
MOV DPTR, #6500H
MOVX @DPTR, A
INC A
INC DPTR
MOVX @DPTR, A

LOOP

SJMP LOOP

OP CODE
74, CC
F4
90, 65, 00
F0
04
A3
F0
80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data
CC

Address
6500
6501

Data
33
34

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.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: f
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
6100
6102
6104
6107
6108

LABEL

LOOP

MNEMONICS

OP CODE

MOV A, #data1
ORL A, #data2
MOV DPTR, #6500H
MOVX @DPTR, A
SJMP LOOP

74, 2F
44, 7E
90, 65, 00
F0
80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data
2F
7E

Address

Data

6500

7F

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

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION


INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: g
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
6100
6102
6104
6107
6108

LABEL

LOOP

MNEMONICS
MOV A, #data1
ANL A, #data2
MOV DPTR, #6500H
MOVX @DPTR, A
SJMP LOOP

OP CODE
74, 2F
54, 7E
90, 65, 00
F0
80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data

Address
6500

Data

RESULT
Thus the assembly language program to masking bits an
8-bit number using microcontroller instruction set was written and executed successfully.
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: a
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 Kit
ALGORITHM
1. Load the count value from memory to A-register and store it in B-register.
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
6100
6102
6104
6107
6109
610B

LABEL

LOOP1

610C

MNEMONICS
MOV R3, #04H
MOV R4, #04H
MOV DPTR, #6500H
MOV R5, DPL
MOV R6, DPH
MOVX A, @DPTR

OP CODE
7B, 04
7C, 04
90, 65, 00
AD, 82,
AE, 83
E0

MOV B,A

F5, F0

INC DPTR

A3

610F

MOVX A, @DPTR

E0

6110

MOV R0, A

F8

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 @DPTR,A

F0

6120

POP DPH

D0, 83

6122

POP DPL

D0, 82

6124

MOV A, B

E5, F0

6126

MOVX @DPTR, A

6127

MOV B, R0

88, FO

DJNZ R3, REPT

DB, E3

610E

6116

6129

LOOP

EXCH

LOOP2

F0

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

6133

INC DPTR

A3

6134
6136
OBSERVATION

HLT

DJNZ R4, LOOP1

DC, D1

SJMP HLT

80, FE

INPUT
(Before sorting)
Address
Data
6500
05H
6501
0AH
6502
06H
6503
03H
6504
08H

OUTPUT
Address
6500
6501
6502
6503
6504

(After sorting)
Data
05H
03H
06H
08H
0AH

RESULT
Thus, the assembly language program to sort an array of data in ascending order using 8051
simulator tools was written and executed successfully.
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: b
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 Kit
ALGORITHM
1. Load the count value from memory to A-register and store it in B-register.
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
6100
6102
6104
6107
6109
610B

LABEL

LOOP1

610C

MNEMONICS
MOV R3, #04H
MOV R4, #04H
MOV DPTR, #6500H
MOV R5, DPL
MOV R6, DPH
MOVX A, @DPTR

OP CODE
7B, 04
7C, 04
90, 65, 00
AD, 82,
AE, 83
E0

MOV B,A

F5, F0

INC DPTR

A3

610F

MOVX A, @DPTR

E0

6110

MOV R0, A

F8

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 @DPTR,A

F0

6120

POP DPH

D0, 83

6122

POP DPL

D0, 82

6124

MOV A, B

E5, F0

6126

MOVX @DPTR, A

6127

MOV B, R0

88, F0

DJNZ R3, REPT

DB, E3

610E

6116

6129

LOOP

EXCH

LOOP2

F0

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

6133

INC DPTR

6134

DJNZ R4, LOOP1

A3
DC, D1

6136

HLT

SJMP HLT

80, FE

OBSERVATION
INPUT

RESULT

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
08H
6504
06H
Thus the assembly language program to sort an array of data in descending order

using 8051 simulator tools was written and executed successfully.


PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: c
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 B-register.
3. Move the second data from memory to accumulator.
4. Add the content of B-register with Accumulator.
5. Check for carry. If carry=1 then go to step 6 else go to step 7.
6. Increment the C-register
7. Store the sum in memory.
8. Move the carry to accumulator and store in memory.

PROGRAM

MEMORY
ADDRESS

LABEL

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

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
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: g
DATE:
UNMASKED BCD NUMBER TO ASCII CODE 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 OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESS
6100
6102
6104
6107
6108

LABEL

LOOP

MNEMONICS
MOV A, #data1
ORL A, #30
MOV DPTR, #6500H
MOVX @DPTR, A
SJMP LOOP

OP CODE
74, 02
44, 30
90, 65, 00
F0
80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data

Address
6500

Data

RESULT
Thus the assembly language program to masking bits an
8-bit number using microcontroller instruction set was written and executed successfully.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: c
DATE:
SQUARE OF A 8-BIT NUMBER USING 8051
AIM
To write an assembly language program to multiply the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6105
6106

LABEL

MNEMONICS
CLR C
MOV A,#data1
MOV B,A
MUL AB
MOV DPTR, #6500H

OP CODE
C3
74, 04
F5, F0
A4
90, 65, 00

6109
610A

MOVX @DPTR, A
INC DPTR

610B

MOV A, B

610D

MOVX @DPTR, A

610E

LOOP

F0
A3
E5, F0
F0

SJMP LOOP

80, FE

OBSERVATION
INPUT
Address

OUTPUT
Data
06

Address
6500

Data
24

6501

00

RESULT
Thus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction
set was written and executed
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: c
DATE:
CUBE OF A 8-BIT NUMBER USING 8051
AIM
To write an assembly language program to multiply the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.

6. The lower order of the result is in Accumulator.


7. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
ADDRESS
6100
6101
6103
6105
6106
6107
6109
610A
610D
610E

LABEL

MNEMONICS
CLR C
MOV A,#data1
MOV B,A
MOV R0, A
MUL AB
MOV F0,R0
MUL AB
MOV DPTR, #6500H
MOVX @DPTR, A
INC DPTR

6110

MOV A, B

6112

MOVX @DPTR, A

6113

OP CODE

LOOP

C3
74, 04
F5, F0
F8
A4
A8, F0
A4
90, 65, 00
F0
A3
E5, F0
F0

SJMP LOOP

80, FE

OBSERVATION
INPUT
Address

RESULT

OUTPUT
Data
0F

Address
6500

Data
2F

6501

0D

Thus, the assembly language program to multiply the two 8-bit numbers using 8051

instruction set was written and executed

You might also like