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 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 CC program. The array of integers should be created and populated with values inside the CC program. After sorting, the CC code should display the array in sorted order. The array could be loaded with random numbers
Part II 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 for ascending and for descending The user should be prompted in the CC program about the sorting order.
Part III points
In the CC 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 CC function for sorting. To get meaningful reading, the array should have 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 showArrayint arr int size;
void bubbleSortint arr int size, int mode;
extern C
void bubbleSortAsmint int, int;
int main
const int SIZE ;
int myArrSIZE;
int secondArrSIZE;
for int i ; i SIZE; i
myArri rand;
secondArri myArri;
showArraymyArr SIZE;
timet t; time variable in milliseconds
t clock; obtain current time in milliseconds
bubbleSortmyArr SIZE, ; ghostFunction;
long int time clock t; compute elapsed time
t clock; obtain current time in miliseconds
bubbleSortAsmsecondArr SIZE, ;
long int time clock t; compute elapsed time
showArraysecondArr SIZE;
cout "Time to execute function: time milliseconds
;
cout "Time to execute C function: time "miliseconds
;
return ;
to do something of long duration
void ghostFunction
double num ;
for int i ; i ; i
num i;
void bubbleSortint arr int size, int md
int temp ;
and here my assembly file
model flat
code
bubbleSortAsm PROC
push ebp
mov ebp,esp ;stack pointer to ebp
mov ebx,ebp ; address of first array element
mov ecx, ebp
mov ebp,
mov edx,
mov edi,
dec ecx
push esi
outsideLoop:
cmp edi, ecx
je allDone
mov ebp,
mov edx,
insideLoop:
cmp ebp,ecx
je continueOutside
mov eax, ebxedx
cmp eax, ebxedx
jl continueInside
mov eax, ebxedx
mov esi, ebxedx
mov ebxedx esi
mov ebxedx eax
ContinueInside:
add edx,
add ebp,
jmp insideLoop
continueOutside:
add edi,
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
