|Page 1 of 1|
|Author:||Noura [ Sun Apr 16, 2017 4:00 pm ]|
|Post subject:||PUSH/POP STACK|
I have a question in regards array pushing and popping. I am trying to write a code that will sort an array in ascending order, and the way I have went about it is to find the minimum from the initialized array (which I have completed and working) then after I would like to pop it out of array 1 and store it into array 2, then check for the minimum again and keep this cycle going until it's done.
Or I also thought instead of push and pop I could swap the maximum value found with the element in the first index and decrement size checking the rest of the elements because by the time I have run through all of the array it would be in ascending order.
Is my thought process illogical and is there a way where I could do this in 68000 or no? If it is possible how do I go about this issue?
|Author:||mr68k [ Thu Apr 20, 2017 4:25 am ]|
|Post subject:||Re: PUSH/POP STACK|
Your thought process is on the right track. What may help you is the coverage of the subject of "Sorting Algorithm" on Wikipedia. My favorite algorithm is the Insertion short, which I implemented in 6809 assembly language and can translate nicely to 68000. It was written to sort the filenames in a disk directory, then secondary sort them by date. The algorithm can be implemented in most any high level language which supports arrays. The 6809 and 68000 have indexed addressing modes which make easy work of indexing into arrays. Easy68k is a perfect platform to experiment on. Hope this helps.
|Page 1 of 1||All times are UTC|
|Powered by phpBB® Forum Software © phpBB Group