•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 391,946 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,885 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser:
Views: 3796 | Replies: 0
![]() |
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
My homework is to write the quicksort algorithm in 8085 assembly. So I tried to write it and of course it has too many bugs but my main problem is that I don't know how to handle the recursive character of the algorithm and control the loops. For example, what kind of flag should i use to know if the 1st partition is sorted so to call quicksort for the second partition?
The dataset I used is 37 2 6 4 89 8 10 12 68 45 starting from memory position 3000H and regs bc: 1st element index/ de: last elem index
If u or anyone else could take a look, I would be thankful.
Here is my code:
;initialisation
LXI SP,FFF0H
LXI H,3009H
XCHG
MVI B,30H
MVI C,00H
QSORT:
MOV H,B
MOV L,C
MOV A,M
MOV L,E
SCANR:
CMP M
PUSH PSW
CNC SWAP
CPI 01H
JZ SCANL
DCX H
JMP SCANR
SCANL:
POP PSW
MOV C,L
LXI H,3000H
LOOP:
INX H
CMP M
PUSH PSW
PUSH B ;;;
CC SWAP
JZ RECURSIVE
CPI 01H
JNZ LOOP
POP H ;;;
POP PSW
JMP SCANR
SWAP:
PUSH B
PUSH D
PUSH H
MOV D,M
MOV L,C
MOV E,M
MOV M,D
POP H
MOV M,E
MVI A,01H
POP D
POP B
MOV C,L
RECURSIVE:
;BREAK
LXI B,3000H
DCX H
MOV E,L
JMP QSORT ; I<X
QS2:
LXI B,3009H
;BREAK
INX H
INX H
MOV E,L
JMP QSORT
HLT
The dataset I used is 37 2 6 4 89 8 10 12 68 45 starting from memory position 3000H and regs bc: 1st element index/ de: last elem index
If u or anyone else could take a look, I would be thankful.
Here is my code:
;initialisation
LXI SP,FFF0H
LXI H,3009H
XCHG
MVI B,30H
MVI C,00H
QSORT:
MOV H,B
MOV L,C
MOV A,M
MOV L,E
SCANR:
CMP M
PUSH PSW
CNC SWAP
CPI 01H
JZ SCANL
DCX H
JMP SCANR
SCANL:
POP PSW
MOV C,L
LXI H,3000H
LOOP:
INX H
CMP M
PUSH PSW
PUSH B ;;;
CC SWAP
JZ RECURSIVE
CPI 01H
JNZ LOOP
POP H ;;;
POP PSW
JMP SCANR
SWAP:
PUSH B
PUSH D
PUSH H
MOV D,M
MOV L,C
MOV E,M
MOV M,D
POP H
MOV M,E
MVI A,01H
POP D
POP B
MOV C,L
RECURSIVE:
;BREAK
LXI B,3000H
DCX H
MOV E,L
JMP QSORT ; I<X
QS2:
LXI B,3009H
;BREAK
INX H
INX H
MOV E,L
JMP QSORT
HLT
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
Similar Threads
- Alarm digital clock assembly language for 8085 microprocessor (Assembly)
- 8085 Assembly. (Assembly)
- Help bubblesort in 8085 assembly (Assembly)
- looking for quicksort in assembly 8085 (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: Doesnt really make sense
- Next Thread: Please AnyBody Can Help Me To Build Assembly Code Infix To Postfix It So Hard T_T


Linear Mode