Please help me to write the following program in 8085 assembly language. Only guidelines required.
5 numbers are stored at consecutive memory location. Arrange them in ascending order and store them in another location.

Recommended Answers

All 8 Replies

Wow. I learnt the 8085 assembly language a long time ago while I was still in school. Unfortunately, I don't remember much :(

>Unfortunately, I don't remember much
While interesting (well, not really), your post has no meaningful content relevant to this thread. If you're incapable of helping, there's no point in posting to inform everyone of it.

Ya, well said. The reply isn't appropriate in any sense.

So it doesn't seem as if I'm just posting to complain, how have you tried to solve the problem so far? If there are always five numbers, you can brute force it without too much code, or you can write a more general sorting solution. Because you're moving the data to a different memory location, you would probably be best off using an insertion sort.

I have given a lot of thought to the problem. Actually the problem is arranging the numbers in ascending order. You see I can easily find the largest of the numbers by using loops or something sort of that.
I have an idea to solve this one too but the code is becoming too large. Another problem Iam facing is that the program has to be coded in 8085 Assembly Language. The program is easy to be made in other languages but not in 8085.

>The program is easy to be made in other languages but not in 8085.
How so? 8085 supports the necessary instructions to write a sorting algorithm.

Thatz it !!!!! Sorting 6 numbers in memory starting from 0060H hex address (Selection sort algo) -------------------------
LXI H, 0060H
MVI B, 05H
LOOP1: MOV C, B
MOV D, H
MOV E, L
INR E
LOOP2: LDAX D
CMP M
JNC NO_SWP
SWAP: MOV D, M
MOV M, A
MOV A, D
MOV D, H
STAX D
NO_SWP: INR E
DCR C
JNZ LOOP2
INX H
DCR B
JNZ LOOP1
HLT

lxi h, 0060h
mvi b, 05h
loop1: Mov c, b
mov d, h
mov e, l
inr e
loop2: Ldax d
cmp m
jnc no_swp
swap: Mov d, m
mov m, a
mov a, d
mov d, h
stax d
no_swp: Inr e
dcr c
jnz loop2
inx h
dcr b
jnz loop1
hlt
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.