The goal of this assignment is to learn about x86-64 functions and calling conventions.
void quicksort (integer A[], integer p, integer r) begin integer q; if p < r then q := partition(A, p, r) quicksort(A, p, q) quicksort(A, q+1, r) end if end quicksort integer partition (integer A[], integer p, integer q) begin integer pivot := A[p] integer i := p-1 integer j := q+1 while (true) repeat j := j-1 until (A[j] <= pivot) repeat i := i+1 until (A[i] >= pivot) if i < j then swap(A, i, j) else return j end if end loop end partition void swap (integer A[], integer i, integer j) begin integer temp := A[i] A[i] := A[j] A[j] := temp end swapThe template calls Quicksort on an array of signed integers using the function signature in the pseudocode. We provide the swap function. Of course, you don't have to follow the pseudocode exactly so long as you implement Quicksort.
We will test your implementation on multiple arrays with interesting values. You may want to modify the array in the template to try other values. A component of your grade will also be based on your adherence to the Linux/Mac OSX AMD64 calling conventions, outlined in Week 2's section notes.
gcc -o hw3 hw3-template.s
./hw3