Hi there,

I think your original C code is flawed. I tested it and it didn't work for me. Usually QuickSort is implemented recursively but I see you have done it iteratively. While it is not impossible to do it that way you might have an easier time porting a recursive C function to assembly. Here is a basic recursive C implementation of quicksort for 10 decimals. You might try porting this to assembly.

I hope this helps. Good luck -Aaron

void sort(int array[], int begin, int end)

{

if (end > begin)

{

int pivot = array[begin];

int l = begin + 1;

int r = end;

while(l < r)

{

if (array[l] <= pivot)

{

l++;

}

else

{

r--;

int swap = array[l];

array[l] = array[r];

array[r] = swap;

}

}

l--;

int swap = array[begin];

array[begin] = array[l];

array[l] = swap;

sort(array, begin, l);

sort(array, r, end);

}

}

int _tmain(int argc, _TCHAR* argv[])

{

int a[10] = {0,9,6,7,8,1,2,3,5,4};

sort(a,0,10);

return 0;

}

I think your original C code is flawed. I tested it and it didn't work for me. Usually QuickSort is implemented recursively but I see you have done it iteratively. While it is not impossible to do it that way you might have an easier time porting a recursive C function to assembly. Here is a basic recursive C implementation of quicksort for 10 decimals. You might try porting this to assembly.

I hope this helps. Good luck -Aaron

void sort(int array[], int begin, int end)

{

if (end > begin)

{

int pivot = array[begin];

int l = begin + 1;

int r = end;

while(l < r)

{

if (array[l] <= pivot)

{

l++;

}

else

{

r--;

int swap = array[l];

array[l] = array[r];

array[r] = swap;

}

}

l--;

int swap = array[begin];

array[begin] = array[l];

array[l] = swap;

sort(array, begin, l);

sort(array, r, end);

}

}

int _tmain(int argc, _TCHAR* argv[])

{

int a[10] = {0,9,6,7,8,1,2,3,5,4};

sort(a,0,10);

return 0;

}