Re: [stella] Bubble Sort

Subject: Re: [stella] Bubble Sort
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Mon, 25 Mar 2002 23:48:04 +0100
Manuel wrote:
>(Sorry 
>Thomas, I won't rely on any assumptions and *normally* 
>theories. I don't know what I'm doing with that routine 
>in the future, so it must do 100% always, no matter what 
>input I feed it :-))

I understand.


>So, is anybody here seeing a spot where to still speed-
>up the algorithm? (Without illegal opcodes... :-))

Ok, the challenge is taken: :-)

"BubbleSort": (optimized code, non working!)
    LDX #MAXOBJECTS-2
OuterSortLoop:
    STX tempVar1
InnerSortLoop:
    LDY indextbl+1,X
    LDA ypos,Y
    LDY indextbl,X
    CMP ypos,Y
    BPL NoSwap
    LDA indextbl+1,X
    STY indextbl+1,X
    STA indextbl,X
NoSwap:
    DEX
    BPL InnerSortLoop
    LDX tempVar1 
    DEX
    BPL OuterSortLoop
    RTS

BUT, both algorithms won't work, because inner and outer loop 
must go in *opposite* directions.

Have fun!	
Thomas


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread