954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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.

Seamus McCarthy
Light Poster
35 posts since Apr 2008
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You