Question: please help me fix this assembling code, my output is negative number when choosing sorting mode, output: sorting mode ( 0 for ascending, 1 for

please help me fix this assembling code, my output is negative number when choosing sorting mode, output: sorting mode (0for ascending, 1for descending): 1
C:\Users\user\Documents\final project\Debug\project.exe (process 19864)exited with code -1073741819.
Press any key to close this window ... it supposed to sort an array of integers by chosen mode either ascending or descending order. 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. here is my test code( add comments every lines to help me understand better please): #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 arr[], int size, int mode);
int main()
{
const int SIZE =100000;
int myArr[SIZE];
int secondArr[SIZE];
for (int i =0; i SIZE; i++){
myArr[i]= rand();
secondArr[i]= myArr[i];
}
int sortingOrder;
cout "sorting mode (0 for ascending, 1 for descending): ";
cin >> sortingOrder;
time_t t1; // time variable in milliseconds
t1= clock(); // obtain current time in milliseconds
//ghostFunction();
bubbleSortASM(myArr, SIZE, 1);
long int time = clock()- t1;
showArray(myArr, SIZE);
cout "Time to execute function: " time " milliseconds
";
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;
for (int idx =0; idx size -1; idx++)
{
for (int j =0; j size -1; j++)
{
if (md ==0)
{
//sorting ascending
if (arr[j]> arr[j +1])
{
//swap
temp = arr[j];
arr[j]= arr[j +1];
arr[j +1]= temp;
}
}
else
{
//sorting descending
if (arr[j] arr[j +1])
{
//swap
temp = arr[j];
arr[j]= arr[j +1];
arr[j +1]= temp;
}
}
}
}
}
void showArray(int arr[], int size){
for (int i =0; i size; i++)
cout arr[i]",";
cout endl;
}
 please help me fix this assembling code, my output is negative

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 Databases Questions!