User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Mar 2005
Posts: 2
Reputation: ilias is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ilias ilias is offline Offline
Newbie Poster

Help Help for quicksort in assembly 8085

  #1  
Aug 25th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Assembly Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 8:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC