Re: [stella] Bubble Sort

Subject: Re: [stella] Bubble Sort
From: "Tim Boescke" <t.boescke@xxxxxxxxxxxxx>
Date: Mon, 25 Mar 2002 21:42:58 -0500
> >(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!)

How about this ? Sometimes it is a good idea
to optimize the algorithm. Sorry, untested
and unfinished but you get the idea..

    STX tempVar1
    LDY indextbl+1,x
    LDA ypos,y
    LDY indextbl,x
    CMP ypos,y
    BPL nochange
    LDA ypos,y
    STX tempVar2
    BPL innerloop  
    ... swap entries at tempvar1+1 and tempvar2, 
    decrease tempvar1, loop...

Archives (includes files) at
Unsub & more at

Current Thread