Question: Part I ( 7 0 points ) Build an assembly function that will sort an array of integers. Bubble sort algorithm can be used. The

Part I (70 points)
Build an assembly function that will sort an array of integers. Bubble sort algorithm can be used. The function receives the array and the array size from a C/C++ program. The array of integers should be created and populated with values inside the C/C++ program. After sorting, the C/C++ code should display the array in sorted order. The array could be loaded with random numbers
Part II (30 points)
Modify the assembly function from part I to allow sorting for either ascending or descending order. A third parameter should be passed into the function to represent the chosen sorted order (for example 0 for ascending and 1 for descending). The user should be prompted in the C/C++ program about the sorting order.
Part III (25 points)
In the C/C++ program write a separate function for bubble sort. Set up a timer using the time() function and record the time difference for the assembly and for the C/C++ function for sorting. To get meaningful reading, the array should have 10,000 elements or more. The two functions should be given the same, unsorted array to work with. The recorded time differences should be displayed on the console.
Example for measuring the time of execution:
timetest.cpp
#include
#include
using namespace std;
void ghostFunction();
void showArray(int arr[], int size);
void bubbleSort(int arr[], int size, int mode);
extern "C"{
void bubbleSortAsm(int[], int, int);
}
int main()
{
const int SIZE =10000;
int myArr[SIZE];
int secondArr[SIZE];
for (int i =0; i < SIZE; i++)
{
myArr[i]= rand();
secondArr[i]= myArr[i];
}
//showArray(myArr, SIZE);
time_t t1; // time variable in milliseconds
t1= clock(); // obtain current time in milliseconds
bubbleSort(myArr, SIZE, 1); //ghostFunction();
long int time = clock()- t1; // compute elapsed time
t1= clock(); //obtain current time in miliseconds
bubbleSortAsm(secondArr, SIZE, 1);
long int time2= clock()- t1; //compute elapsed time
showArray(secondArr, SIZE);
cout << "Time to execute function: "<< time <<" milliseconds
";
cout << "Time to execute C++ function: "<< time2<< "miliseconds
";
return 0;
}
//to do something of long duration
void ghostFunction()
{
double num =33.66;
for (int i =0; i <2000000; i++)
num /= i;
}
void bubbleSort(int arr[], int size, int md)
{
int temp =0;
and here my assembly file
.686
.model flat
.code
_bubbleSortAsm PROC
push ebp
mov ebp,esp ;stack pointer to ebp
mov ebx,[ebp+8] ; address of first array element
mov ecx, [ebp+12]
mov ebp,0
mov edx,0
mov edi, 0
dec ecx
push esi
outsideLoop:
cmp edi, ecx
je allDone
mov ebp, 0
mov edx, 0
insideLoop:
cmp ebp,ecx
je continueOutside
mov eax, [ebx+edx]
cmp eax, [ebx+edx+4]
jl continueInside
mov eax, [ebx+edx]
mov esi, [ebx+edx+4]
mov [ebx+edx], esi
mov [ebx+edx+4], eax
ContinueInside:
add edx,4
add ebp,1
jmp insideLoop
continueOutside:
add edi, 1
jmp outsideLoop
allDone:
pop esi
pop ebp
ret
_bubbleSortAsm ENDP
END
please fix for me to get full credit for my problem and can run it in vsstudio

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!