EASy68K  
It is currently Tue Dec 11, 2018 11:04 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Quicksort?
PostPosted: Sun Dec 04, 2011 5:50 pm 
Offline

Joined: Sat Dec 03, 2011 10:57 am
Posts: 2
What's the easiest way to do quicksort on a list (linked or not linked) in the 68000 assembly? I don't really know how to do recursive stuff in assembler... I mean, I have some ideas, but they're somewhat complicated and that's why I'm asking about the simplest way to do it. I still haven't learnt how to use functions, would they help me a lot?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2011 6:10 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
push (MOVEM) the registers you need preserving as you call (BSR/JSR) back into the same subroutine from which you are calling. Then pop them off after it returns. Or have the subroutine push/pop the register it uses at it enters/leaves

For a quicksort you'd probably want to pass the location of the array, and the beginning and end point, the begin/end would be different as you bisect the array.

Code:
QuickSort MOVEM.L D0-D3,-(A7) ; Push working set
..
  BSR QuickSort ; Half
..
  BSR QuickSort ; Sort other Half
..
  MOVEM.L (A7)+,D0-D3 ; Pop
  RTS


Last edited by clive on Sun Dec 04, 2011 6:15 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2011 6:15 pm 
Offline

Joined: Sat Dec 03, 2011 10:57 am
Posts: 2
Thanks. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group