0% found this document useful (0 votes)
46 views16 pages

Quantity: Date

The document describes Assembly Language Programs (ALPs) for performing arithmetic operations using an 8086 microprocessor. It provides algorithms and flowcharts for addition, subtraction, multiplication and division of 16-bit numbers. It also includes sample programs for addition, subtraction and multiplication that get values from memory locations, perform the arithmetic operations, check for carry/borrow and store the results back to memory locations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views16 pages

Quantity: Date

The document describes Assembly Language Programs (ALPs) for performing arithmetic operations using an 8086 microprocessor. It provides algorithms and flowcharts for addition, subtraction, multiplication and division of 16-bit numbers. It also includes sample programs for addition, subtraction and multiplication that get values from memory locations, perform the arithmetic operations, check for carry/borrow and store the results back to memory locations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

DEPT OF ECE/PEC

ECS681 MCrOPROCESSOR & MICROCONTROLLER LAB

EXP NO: 1.1 8086 PROGRAMMING ADDITION & SUBTRACTION

DATE:
AIM:
To wrile an Assembly Language Program (ALP) for performing the addition and

subtraction operation oftwo2- byte(16) numbers.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATIONN QUANTITY


. Microprocessor kit 8086 kit

Power Supply +5 V dc

PROBLEM STATEMENT:

Write an ALP in 8086 to add and subtract two byte numbers stored in the memory
location 10001H to 1003H and store the result in the memory location 1004H to 1005H.AIso
provide an instruction in the above program to consider the carry also and store the carry in the
memory location 1006H.

ALGORITHM:

)16-bit addition
h) Initialize the MSBs of sum to 0
i) Get the first nunmber.
j)Add the second number to the first number.
k) Ifthere is any carry, increment MSBs of sum by I.
) Store LSBs of sum.
m) Store MSBs of sum.

(i)16-bitsubtraction
Initialize the MSBs of difference to 0
g) Get the first number
h) Subtract the second number from the first number.
1
i) f there is any borrow, increment MSBs of difference by
j) Store LSBs of difference
k) Store MSBs of difference.
EC8681 MICROPROCESSOR& MICROCONTROLLER LAB DEPT OF ECE/PEC

FLOWCIART:

ADDITION SUBTRACTION

START START

SET UP COUNTER (CY) SET UP COUNTER (CARRY)

GET FIRST OPERAND GET FIRST


OPERAND TO A

SUBTRACT SECOND
GET SECOND OPERAND TO
OPERAND FROM
A
MEMORYA= A-B

A-A+B

YES

IS THERE
YES ANY CY
IS THERE
ANY CARRY
NO COUNTER
COUNTER = COUNTER
NO COUNTER +1

STORE THE
DIFFERENCE
STORE THE SUM

STORE THE CARRRY


STORE THE CARRY

STOP

STOP
EC8681
MICROPR0CESSOR & MICROCONTROLLER LAB DEPT OF ECE/PEC

ADDITIOON

PROGRAM
COMMENTS
Start: MOV CX. 000011
Initialize counter CX
MOV AX.|1200]
Get the first data in AX
reg
MOV BX. [ |202]
Get the second data in BX
reg
ADD AX.BX
Add the contents of both the
regs AX & BX
JNC Loopl
Check for carry
INC CX
If carry exists, increment the CX
Loopl: MOV [|206].CX Store the carry
MOV [1204]. AX
Store the sum
Stop: HLT
Stop the program

SUBTRACTION
PROGRAM
COMMENTS
Start: MOV CX, 0000H
initialize counter CX
MOV AX.[1 200] Get the first data in AX
reg
MOV BX,. [1202]
Get the second data in BX
reg
SUB AX.BX
Subtract the contents of BX from AX
JNC Loop1
Check for borrow
INC CX If borrow exists,
increment the CX
10opl: MOV [1206],CX Store the borrow
MOV [1204], AX Store the difference

Stop: HLT
Stop the program
EC8681 MICROPROCESSOR & MICROCONTROLLER LAB DEPT O ECE/PEC

TEST DATA:

ADDITION

MEMORY

DATA

SUBTRACTION

MEMORY

DATA

MANUAL CALCULATION:

RESULT:

Thus an addition & subtraction of two 2-byte numbers are performed and the results are
verified.

4
DEPT OF ECE/PEc
EC8681 MICROPROCESSOR & MICROCONTROLLER LAB

EXP NO: 1.2 8086 PROGRAMMING

DATE MULTIPLICATION & DIVISION

AIM:

To wrile an Assembly Language Program (ALP) for performing the multiplicalion and

division operation of 16-bit numbers.

APPARATTUS REQUIRED:

Sl..NO ITEM SPECIFICATION QUANTTTY

Microprocessor kit 8086

2. Power Supply +5 V de 1

PROBLEM STATEMENT:

Write an ALP in 8086 MP to multiply two 16-bit binary numbers and store the result in
the memory location. Write instructions for dividing the data and store the result.

ALGORITIM:

Multiplication of 16-bit numbers:


a) Get the multiplier.
b) Get the multiplicand
c) Initialize the product to 0.
d) Product = product + multiplicand
e) Decrement the multiplier by1
I f multiplicand is not equal to O,repeat from step (d) otherwise store the product.

Division of 16-bit numbers.


a) Get the dividend
b) Get the divisor
c)Initialize the quotient to 0.
d) Dividend dividend divisor
e) If the divisor is grealer, store the quotient. Go to step g.
I f dividend is greater, quotient quotient +1. Repeat from step (d)
g) Store the dividend value as remainder.
MICROPROCESSOR & MICROCONTROLLER LAB 1DEPT OF ECEPEC
ECSG8I

FLOWCIART

MULTPLICATION
DIVISIOON

Start
Start

Load Divisor & Dividend

Get Multiplier & Multiplicand

Quotient = 0

REGISTER=00

DIVIDEND DIVIDEND-DIVISOR
REGISTER = REGISTER+

MULTIPLICAND

QuOTIENT = QUOTIENT+1

M u l t i p l i e r = M U L T I P L I E R -

Is Dividend
<Devisor?

NO
Is Yes
Multiplier =

0?

STORE QUOTIENT

STORE REMAINDER
YES

STORE THE RESULTS

Stop

STOP
ECS681 MICROPROCESSOR DEPT OF ECE/PEC
& MICROCONTROLLER LAB

MULTIPILICATION
PROGRAM COMMENTS

Start: MOV AX,[1200] Get the first data

MOV BX. [1202] Get the second data

MUL BX Multiply both

MOV [1206].AX Store the lower order product

MOV AX,.DX Copy the higher order product to AX

MOV [1208].AX Store the higher order product

Stop: HLT Stop the program

DIVISION

PROGRAM COMMENTS

Start: MOV AX,[|200] Get the first data

MOV DX, [|202] Get the second data

MOV BX. [1204] Divide the dividend by divisor

DIV BX Store the lower order product

MOV [1206].AX Copy the higher order product to AX

MOV AX,DX Store the higher order product

MOV [1208],AX Stop the program

Stop: HLT Get the first data


EC8681 MICROPROCESSOR &
MICROCONTROLLER LAB DEPT OF ECE/PEC

TEST DATA:

MULTIPLICATION

MEMORY

DATA

DIVISON

MEMORY

DATA

MANUAL CALCULATION

RESULT':.

Thus the multiplication & division oftwo (16 bit) byte numbers are performed
and the results are verified
Expt. No. 03 Page No. o7

8086 PROGRAMMMING SEARCHING OE LARGEST AND


28lobhg
SMALLEST BYZE IN AN ARRA

AIM
To A i t an Akembly Language Paccqram(ALP)o
nd he Langet and smallestDumbe aqIen

APPARATUS REQUIRED
S.No Item Specifecatrcn uantity
Mioopocesor kit
Toue uppl +5_dc

ALGORITHM
Fnduzg langest numle
Stant tfa MicLepatnce>son kit.
Laad the aaycowtn_a 2tagsle c
Cet he nst trus umbe
Lcnupaxaa number and _ecchaange Zha numler
small
Get tf hudL humbe com ieauay ad zpeat
he p2M0ces unlulC o
Stop.
Findung+ sn2allest numlscr
Staxt Hha Micuspudceso
kit.
Lmd aay caunt ina egstx C
Gek tfe nunlse
CommpMe fhe Munileens and ecchange the nuume
A

aet
lage
the afiud numen m lle
1epea he pLncess
cayALd
Stop
EC8681 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE/PEC

FLOWClIART

LARGEST NUMBER IN AN ARRAY


SMALLEST NUMBER IN AN ARRAY
START
START

INITIALIZE COUNT

INITIALIZE COUNT

PONITER

PONITER =

YES

IS MAX> YES
pnINTER ?

NO IS MIN
POINTER ?
MAX POINTER
NO

MIN = POINTER
COUNT = COUNT-1

NO
COUNT= COUNT-1
IS COUNT =0

NO
YES
IS COUNT =0
STORE MAXIMUM

STOP YES

STORE MINIIMUM

STOP

13
EC8681
MICROPROCESSOR &
MICROcONTROLLER LAB DEPT OF ECE/PEC
LARGEST

PROGRAM
Start: MOV SI, 1200H
COMMENTS
MOV CL.SI] Initialize array size
INC SI Initialize the count
Go to next
MOV AL.[SI] memory location
DEC CL
Move the first data
in AL
L2: INC SI Reduce the count
Move the SI
CMP AL.[SI pointer to next data
JNB LI Compare two data's
MOV AL.[SI] If AL> [SI] then
Else move the go toLI (no swap)
LI:DEC CL
JNZ L2
large number to AL
Decrement the count
MOV DI,I300H If count is not zero
go to L2
MOV [DIJ.AL Initialize DI with
1300H
Stop: HLT Else store the biggest
Stop number in 1300
location
SMALLEST
PROGRAM
Start: MOV SI, 12001H COMMEN'TS
MOV CL.[SI Initialize array size
INC SI Initialize the count
MOV AL,[SI] Go to next memory
DEC CL Move the first data inlocation
AL
L2 INC SI Reduce the count
CMP AL.[SI) Move the SI pointer to
JB LI Compare two data's next data
MOV AL,[SI IfAL <[SI) then go
LI: DEC CL to LI (no swap)
Else move the large number
to AL
JNZ L2 Decrement the count
MOV DI,1 300H If count is not
zero go to L2
MOV [DI),AL Initialize DI with 130OH
Stop: HLT Else store the biggest
Stop number in 1300
location

4
EC8681 MICROPROCESSOR & MICROCONTROLILER LAB DEPT OF ECE/PEC

TEST DATA:

LARGEST

MEMORY

DATA

SMALLEST

MEMORY

DATA

RESULT:.

Thus largest and smallest number is found in a given array.

15
ECS681
MICROPROCESSOR &
MICROCONTROLLER LAB DEPT OF ECE/PEC
EXP NO: 1.5 8086
PROGRAMMING ASCENDING &
DATE DESCENDING
AIM:

To write an
Assembly Language Program (ALP) to
descending order. sort a
given array in ascending and

APPARATUS REQUIRED:
SL.NO ITEM
SPECIFICATION QUANTITY
Microprocessor kit 8086
2. Power Supply +5 V dc

PROBLEM STATEMENT:
An array of
length 10 is given from the location. Sort it into
order and store the result. descending and ascending
ALGORITUM:
i) Sorting in ascending order:
a. Load the array count in
two registers C and C2.
b. Get the first two numbers.
C.
Compare the numbers and exchange if necessary so that the two numbers are
order. in
d. Decrement C2. ascending
e. Get the third number from the
and repeat the
f. Decrement Ci and repeat the array process until C; is 0.
process until Ci is 0.
(ii) Sorting in descending order:
a. Load the array count in two
b. Get the first two numbers. registers Ci and C2
C.
Compare the numbers and exchange if necessary so that the two numbers
order. are in
d. Decrement C2.
descending
e. Get the third number fronm
the array and
. Decrement Ci and repeat the repeat the process until C2 is 0.
process until Ci is 0.

16
DEPT OF ECE/PEC
LAB
EC8681 MICROPROCESSOR & MICROCONTROLLER

FLOWCIIART

DESCENDING ORDER
ASCENDING ORDER
START
START

INITIALIZE POINTER
INITIALIZE POINTER
COUNT-COUNT I
COUNT COUNT 1
YES

IS POINTER 2
YES
POINTER+I
IS POINTER
POINTER NO

NO TEMP POINTER

POINTER =POINTER +I
TEMP POINTER

POINTER POINTER 1
POINTER =POINTER 1

POINTER - POINTER +1

NO
IS COUNT = 0

IS COUNT

YES
NO

IS FLAG =0
YES

NO YES
I S FLAG = 0

STOP

YES

STOP
17
MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE/PE
EC&681

ASCENDING ORDER:

COMMENTS
PROGRAM

Start: MOV SI. 12001 Initialize memory location for array size

Number of comparisons in CL
MOVCL|SI]
MOV SI. 12001H Initialize memory location for array size
L4
MOV DLISI] Get the count in DL

INC SI Go to next memory location

MOV AL.|SI] Get the first data in AL

L3 INC ST Go to next memory location

MOV BL.|SI] Get the second data in BL

CMP AL.BL Compare two data's

JNB LI I fAL < BL go to LI

DEC SI Else. Decrement the memory location

MOV [SI].AL Store the smallest data

MOV AL.BL Get the next data AL

JMP L2 Jump to L2

LI DECSI Decrement the memory location


MOV ISI].BIL Store the greatest data in memory location

1.2 INC SI Go to next memory location


DEC DL Decrement the count
JNZ L3 Jump to L3, if the count is not reached zero
MOV [SI]|.AL Store data in memory location
DEC CL Decrement the count
JNZ L4 Jump to L4, if the count is not reached zero
Stop: HLT Stop
Test data:

MEMORY

DATA

18
EC8681
MICROPROCESSOR &MICROCONTROLLER LAB DEPT OF ECEPEC

DESCENDING ORDER:
PROGRANM
COMMENTS
Start: MOV SI.1 2001H
Initialize memory location for
MOV CLSI array size
Number of
L4: MOV SI.I20011 comparisons in CIL
Initialize memory location for
MOV DL[SI] array size
Get the count in DL
INC SI
Go to next
memory location
MOV AL.|SI]
Get the first data in AL
L3 INC SI
Go to next
memory location
MOV BLJSI]
Get the second data in
BL
CMP AL.BL
Compare two data's
JBLI
If AL> BL go to LI
DEC SI
Else. Decrement the
MOV ISI].AL memory location
Store the
MOV AL.BL
largest data
Get the next data AL
JMP L2
Jump to L2
1.1 DEC SI
Decrement the memory location
MOV ISIJ.BL
Store the smallest data in
1.2 INC SI memory location
Go to next
DEC DL memory location
Decrement the count
JNZ L3
Jump toL3, if the count is
MOV ISI).AL not reached zero
Store data in
DEC CL memory location
Decrement the count
JNZ L4
Jump to L4, if the count is
Stop: HLT not reached zero
Stop
MEMORY

DATA

Result: Thus given array of numbers are sorted in ascending &


descending order
19

You might also like