DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   descending bucket sort in 68000 (http://www.daniweb.com/forums/thread121103.html)

Seamus McCarthy Apr 26th, 2008 9:42 am
descending bucket sort in 68000
 
          ORG      $8000
NUMBERS  DS.B    5              ;room for 5 input values
BUCKETS  DS.B    11              ;room for 11 buckets

          ORG      $8100

BKTSORT  LEA        BUCKETS,A0        ;init array pointer
                MOVE.W  #10,D0          ;init loop counter
CLRBKT    CLR.B    (A0)+              ;clear bucket
                DBRA    D0,CLRBKT      ;do this 11 times
                LEA            NUMBERS,A1    ;init pointer to input data
                LEA            BUCKETS,A0    ;init pointer to buckets
                MOVE.W  #4,D0            ;init loop counter
SETBKT      MOVE.B  (A1)+,D1        ;read input value
                MOVE.B  #1,(A0,D1)      ;set bucket to 1
                DBRA    D0,SETBKT      ;do this 5 times
                LEA            NUMBERS,A1    ;init pointer to input array
                LEA            BUCKETS,A0    ;init pointer to buckets
                CLR.L    D1                  ;clear index pointer
                MOVE.W  #10,D0          ;init loop counter
READBKT  CMPI.B  #1,(A0,D1)      ;read bucket value
                BNE      NOSAVE            ;branch if bucket = 0
                MOVE.B  D1,(A1)+        ;save index value
NOSAVE    ADDI.B  #1,D1            ;advance index value
                DBRA    D0,READBKT    ;do this 11 times
                RTS

I understand and got the ascending bucket sort to work but how would i edit the ascending sort to give me the numbers in descending order instead.


All times are GMT -4. The time now is 6:04 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC