Solved
Convert c code into assembly code
Posted on 2004-09-09
Hey. I hope you can help me with converting some c code into assembly code, i have tried much now, and i still don't get it. What would help me alot, would be some comments for each line in the assembly code, so i better can understand to convert process...
Here is the code:
/* Standard quicksort. */
void quicksort(int a[], int left, int right)
{
int lp = left - 1;
int rp = right;
int v = a[right]; /* the partioning element */
if (right <= left)
/* Array has one or null elements to sort */
return;
/* No elements to the left of lp are greater than the partioning elemnt. */
while (1) {
while (a[++lp] < v)
;
while (v < a[--rp])
/* In case the partioning element is the smallest in the array */
if (rp == left)
break;
if (lp >= rp)
break;
/* Deadlock, switch elements and continue */
swap(&a[lp], &a[rp]);
}
/* This completes the partioning */
swap(&a[lp], &a[right]);
/* Now every element to the left of a[lp] are smaller than a[lp],
* and every element to the right is larger. */
quicksort(a, left, lp - 1);
quicksort(a, lp + 1, right);
}
static void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}
Hope you can help.
Terje.