Question
NEED (Assembly Language) CODE: Write and test an ARMv8 program to sort an array of elements. As I mentioned in class, this problem uses a
NEED (Assembly Language) CODE:
Write and test an ARMv8 program to sort an array of elements. As I mentioned in class, this problem uses a portion of your Programming Assignment 1 where you computed the smallest and largest values in an array. Here we will extend that assignment to find the index of the smallest and the index of the largest elements of the array.The following C code segment illustrates how we can sort the element of an array.
i =0; while (i < n) {
find_smallest (&a, i, n, index); /*returns the index of next smallest element
swap (&a, i, index); /* swap smallest with a[i]
find_largest (&a, i, n, index); /* returns the index of next largest element
swap (&a, n, index); /* swap largest with a[n]
i = i+1; n = n-1; }
The three functions called by above C segments are shown next.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void find_smallest (long long int *a, long long int i, long long int n, long long int index) { long long int smallest = a[i]; index = i; for (j = i; j } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void find_largest ( long long int *a, long long int i, long long int n, long long int index) { long long int largest = a[n]; index = n; for (j = i; j f (a[j] > largest) { largest = a[j]; index = j;} } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void swap (long long int *a, long long int i, long long int j) { temp = a[i]; a[i] = a[j]; a[j] = temp; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// You MUST use 3 functions and main in your assembly code also. Test input: n= 8; the eight positive integers are: 79, 55, 94, 48, 19, 13, 45, 21
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started