Homework 7 - Computer Organization Due: 4/4/03 (F-noon)

Often a high-level language program spends 90% of its execution time in a single critical subprogram. To speed up the program that critical subprogram can be rewritten in assembly language in an attempt to speed the program. This is where the ARM calling conventions are important to follow since you don't want the subprogram to wipe out register values of its caller.

Below is a C main program and quickSort subprogram. You are to call your ARM assembly-language partition and swap subprograms from the C quickSort.

#include <stdio.h>

extern void quickSort (int a[], int low, int high);

int main () { int a[100], aCopy[100]; int i, n;

printf("Enter the number of elements to sort: "); scanf("%d",&n); printf("\n"); // should not be needed

for (i = 0; i < n; i++) { printf("Enter a[%d]: ", i); scanf("%d",&a[i]); printf("\n"); // should not be needed aCopy[i] = a[i]; } // end for

quickSort(a, 0, n-1); // Call the C quick sort

printf("The sorted elements are: "); for (i = 0; i < n; i++) { printf("%d ", a[i]); } // end for printf("\n"); } // end main

extern int partition(int array[], int low, int high);

void quickSort (int array[], int low, int high) { int pivotPosition;

if (low < high) { pivotPosition = partition(array, low, high); quickSort(array, low, pivotPosition - 1); quickSort(array, pivotPosition+1, high); } // end if

} // end quickSort

Turn in the following:

1) Print outs of the C and ARM assembly language programs files.

2) The "output" of the ARM program using the following 10 integers as data: 8 2 7 1 5 6 3 4

9 0 (I want a picture of ARM simulator after the program has run).