Basically the algorithm is as follows:

  1. Compare each pair of adjacent elements from the beginning of an array and, if they are in reversed order, swap them.
  2. If at least one swap has been done, repeat step 1.

But to spoon feed you:

for(int x=0; x<n; x++)

{

for(int y=0; y<n-1; y++)

{

if(array[y]>array[y+1])

{

int temp = array[y+1];

array[y+1] = array[y];

array[y] = temp;

}

}

}


Better yet...Google this!!!!





On Fri, Dec 10, 2010 at 10:44 PM, Kelvin <kjayanoris@gmail.com> wrote:

I'm trying to write a function that receives an array of (signed) long integers or a pointer to the array as a parameter, that will sort the array from lowest-to-highest. Using a bi-directional form of the bubble sort algorithm.

This is a "learning assmebly" excercise whose description is:


The sort itself must be written entirely in inline assembly. If there is need to include any other functionality then it must be in pure C. You must only write a single block of inline assembly, though it can be in a separate sub-function if you want. You must also try to make this assembly section as small and efficient as possible, and must correctly employ constraints. Your inline assembly code should use no named registers, and you should avoid specifying exact registers in your constraints as well.

It is intended for use this  in AT&T.


Anybody has an idea how I can approach this?

Kelvin
www.likechapaa.com
www.dukapress.org
--------------------------------------------------------------------------------------------
We help make your website a success.
--------------------------------------------------------------------------------------------


_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke