Subject: [stella] Bubble Sort (Rodnay Zaks Version) From: "Ronald A. Laski, Jr." <rlaski@xxxxxxxxxxx> Date: Tue, 26 Mar 2002 04:00:20 -0600 |
Ron TAB .WORD $600 * = $200 SORT LDX #0 ;Set 'Exchanged' to 0 (in other words, SwapFlag = FALSE) - Ron LDA (TAB,X) TAY ; Number of elements is in Y LOOP LDA (TAB),Y ; Read Element E(I) DEY ; Decrement number of elements to read. BEQ FINISH ; End if no more elements CMP (TAB), Y ; Compare to E'(I) BCS LOOP ; Get next element IF E(I) > E'(I) EXCH TAX ; Exchange elements LDA (TAB), Y INY STA (TAB), Y TXA DEY STA (TAB), Y LDX #1 ; Set 'Exchanged' to 1 (in other words, SwapFlag = TRUE) - Ron BNE LOOP ; Get next element FINISH TXA ; Shift 'Exchanged' to a reg. for compare... BNE SORT ; If some exchanges are made, do another pass. RTS .end
---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Aw: Re: [stella] Bubble Sort, cybergoth | Thread | [stella] Bubble Sort (ps), Ronald A. Laski, Jr. |
Re: [stella] Bubble Sort, Thomas Jentzsch | Date | [stella] Bubble Sort (ps), Ronald A. Laski, Jr. |
Month |