View Single Post
Join Date: Apr 2008
Posts: 34
Reputation: Seamus McCarthy is an unknown quantity at this point 
Solved Threads: 0
Seamus McCarthy Seamus McCarthy is offline Offline
Light Poster

descending bucket sort in 68000

 
0
  #1
Apr 26th, 2008
  1. ORG $8000
  2. NUMBERS DS.B 5 ;room for 5 input values
  3. BUCKETS DS.B 11 ;room for 11 buckets
  4.  
  5. ORG $8100
  6.  
  7. BKTSORT LEA BUCKETS,A0 ;init array pointer
  8. MOVE.W #10,D0 ;init loop counter
  9. CLRBKT CLR.B (A0)+ ;clear bucket
  10. DBRA D0,CLRBKT ;do this 11 times
  11. LEA NUMBERS,A1 ;init pointer to input data
  12. LEA BUCKETS,A0 ;init pointer to buckets
  13. MOVE.W #4,D0 ;init loop counter
  14. SETBKT MOVE.B (A1)+,D1 ;read input value
  15. MOVE.B #1,(A0,D1) ;set bucket to 1
  16. DBRA D0,SETBKT ;do this 5 times
  17. LEA NUMBERS,A1 ;init pointer to input array
  18. LEA BUCKETS,A0 ;init pointer to buckets
  19. CLR.L D1 ;clear index pointer
  20. MOVE.W #10,D0 ;init loop counter
  21. READBKT CMPI.B #1,(A0,D1) ;read bucket value
  22. BNE NOSAVE ;branch if bucket = 0
  23. MOVE.B D1,(A1)+ ;save index value
  24. NOSAVE ADDI.B #1,D1 ;advance index value
  25. DBRA D0,READBKT ;do this 11 times
  26. 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.
Reply With Quote