943,961 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1416
  • Assembly RSS
Apr 26th, 2008
0

descending bucket sort in 68000

Expand Post »
Assembly Syntax (Toggle Plain Text)
  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.
Reputation Points: 11
Solved Threads: 0
Light Poster
Seamus McCarthy is offline Offline
34 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Belgian keyboard in SoftIce
Next Thread in Assembly Forum Timeline: Help Assembly matrix multiplication





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC