Quantity: Date
Quantity: Date
DATE:
AIM:
To wrile an Assembly Language Program (ALP) for performing the addition and
APPARATUS REQUIRED:
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
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
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
AIM:
To wrile an Assembly Language Program (ALP) for performing the multiplicalion and
APPARATTUS REQUIRED:
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:
FLOWCIART
MULTPLICATION
DIVISIOON
Start
Start
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
Stop
STOP
ECS681 MICROPROCESSOR DEPT OF ECE/PEC
& MICROCONTROLLER LAB
MULTIPILICATION
PROGRAM COMMENTS
DIVISION
PROGRAM COMMENTS
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
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
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:.
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
JMP L2 Jump to L2
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