Sie sind auf Seite 1von 5

DR. B.R.

AMBEDKAR NATIONAL INSTITUTE OF


TECHNOLOGY, JALANDHAR

MICROPROCESSOR AND INTERFACING LAB


LAB ASSIGNMENT 7

SUBMITTED TO:
DR. SATHIYA S

SUBMITTED BY:
 PARTH SHINH
18106052
 PIYUSH GUPTA
18106053
 PRABHLEEN KAUR
18106054
ICE 3RD Year

Group: G3-C
QUESTION 1:
 AIM:
Write a program sequence to arrange given 10 numbers in ascending order.

 PLATFORM REQUIRED:
SIM 8085

 ALGORITHM OF THE PROGRAM:

1. Initialize two counters. As here are 10 numbers so set both counters to 09H.
2. Load H-L pair with address where series of given numbers is stored as here
0000H.
3. Move the content from memory to Accumulator.
4. Increment H-L pair and compare both the numbers (in memory and AC).
5. If the number in Accumulator is less or equal to next number (in H-L pair),
then don’t interchange otherwise swap the numbers.
6. Decrement counter 2.
7. Repeat these steps (from step 3) until counter 2 reaches to zero.
8. If counter 2 = 0, then decrement counter 1.
9. Repeats all these till counter 1 reaches to zero.
10. Terminate the program.

 PROGRAM SEQUENCE IN MNEMONICS:

MVI B,09H
L3:MVI C,09H
LXI H,0000H
L1:MOV A,M
INX H
CMP M
JC L2
JZ L2
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
L2:DCR C
JNZ L1
DCR B
JNZ L3
HLT
 FLOWCHART:

START

Initialize Counter 1

Initialize Counter 2 and H-L


pair

Move no. from memory to AC

Increment H-L pair

Compare number in memory


with number in accumulator
N
O

If N
A>M O
HLT

Y Y
E E
S S

Interchange the
numbers If
Counter
1 =0

NO Increment H-L pair

If
Decrement Counter 2 Counter2 Decrement
YES
=0 Counter 1
 PROGRAM OUTPUT:
 RESULT:
Given numbers are sorted in ascending order.

Das könnte Ihnen auch gefallen