CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 116 users online: 12 members, 79 guests and 25 bots.
Members: ACagliano, hellninjas, JosJuice, LuxenD, worldspace.
Bots: Spinn3r (2), Magpie Crawler (3), Googlebot (19), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 Assembly
Author Message
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 13 Nov 2010 09:06:03 am    Post subject:

While doing some research for WikiTI I have found this: http://frank_y.scripts.mit.edu/pages/z80qsort/

Here is the code for quicksort:
;
; >>> Quicksort routine v1.1 <<<
; by Frank Yaul 7/14/04
;
; Usage: bc->first, de->last,
; call qsort
; Destroys: abcdefhl
;
qsort: ld hl,0
push hl
qsloop: ld h,b
ld l,c
or a
sbc hl,de
jp c,next1 ;loop until lo<hi
pop bc
ld a,b
or c
ret z ;bottom of stack
pop de
jp qsloop
next1: push de ;save hi,lo
push bc
ld a,(bc) ;pivot
ld h,a
dec bc
inc de
fleft: inc bc ;do i++ while cur<piv
ld a,(bc)
cp h
jp c,fleft
fright: dec de ;do i-- while cur>piv
ld a,(de)
ld l,a
ld a,h
cp l
jp c,fright
push hl ;save pivot
ld h,d ;exit if lo>hi
ld l,e
or a
sbc hl,bc
jp c,next2
ld a,(bc) ;swap (bc),(de)
ld h,a
ld a,(de)
ld (bc),a
ld a,h
ld (de),a
pop hl ;restore pivot
jp fleft
next2: pop hl ;restore pivot
pop hl ;pop lo
push bc ;stack=left-hi
ld b,h
ld c,l ;bc=lo,de=right
jp qsloop
;
; >>> end Quicksort <<<
;

I hope some z80 junkies enjoy. And discuss.


Last edited by Guest on 13 Nov 2010 09:30:33 am; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.018873 seconds.