I need this project done in 24 hours, by 4/19/17 at 6:00pm Pacific Time.
Create a program named "sort.s" that does the following:
reads integers from a file named "[login to view URL]". (There will no more than 8192 integers in the file)
Sorts all the numbers
Prints the sorted integers out, one per line, to a file named "[login to view URL]"
You must implement and use the following functions:
int read(int filenamelocation, int arrayaddress, int arraysize)
void sort(int arrayaddress, int itemcount)
int findsmallest(int arrayaddress, int start, int end)
void swap(int arrayaddress, int a, int b)
void print(int filenamelocation, int arrayaddress, int itemcount)
Here are those functions in java but they need to be changed to ARM assembly for the project:
void sort(int [] array, int itemcount)
{
int pos;
int smallpos;
pos = 0;
while (pos < itemcount-1) {
smallpos = findsmallest(array, pos, itemcount);
swap(array, pos, smallpos);
pos = pos + 1;
}
}
int findsmallest(int [] array, int first, int itemcount)
{
int smallest
int index;
smallest
index=1;
while (index < itemcount) {
if (array[index] < array[smallest])
smallest = index;
index = index + 1;
}
return smallest;
}
void swap(int [] array, int first, int second)
{
int temp = array[first];
array[first] = array[second];
array[second] = temp;
}
Or super sneaky using the power of logic and math
without a third variable or register...
void swap(int [] array, int first, int second)
{
array[first] = array[first] ^ array[second];
array[second] = array[first] ^ array[second];
array[first] = array[first] ^ array[second];
}