Question: Find MAX/MIN values in an array using assembly functions that are callable from C++. This is what i have done, but it doesn't work when

Find MAX/MIN values in an array using assembly functions that are callable from C++.

This is what i have done, but it doesn't work when i try to run it. Please help me to figure what i did wrong. Explain and show your work. Thank you

Write a C++ program that does the following:

1) Declare an array of integers (size is your choice)--your program should work with any array size.

#include  using namespace std; extern"C"{ int average(int*,int); int max(int*, int); int min(int*, int); 
 } int main() const int SIZE = 7; int arr[SIZE] = {1,2,3,4,5,6,7}; int val = average(arr,SIZE); int val2 = max(arr, SIZE); cout << "The average is " << val << endl; cout << "The max is " << val2 << endl; system("pause"); return 0; 

2) Call an assembly function to compute the largest (max) of all elements in the array (pass the array and the size of the array). Need to search for the largest value in the array(.asm) and display(.cppp)

.686 .model flat .code _max PROC push ebp; mov ebp, esp; mov ebx, [ebp+8]; mov ecx, [ebp+12]; mov ebp, 0; mov edx, 0; mov eax, 0; L1: cmp ebx, ecx; jg greater; jmp lessThan; L2: cmp ebp, ecx; je done; Cont: mov ebx, eax; mov ecx, [ecx + edx]; add edx, 4; add ebp, 1; cmp ebx, ecx; jg greater; jmp lessThan; greater: mov eax, ebx; jmp L2; lessthan: mov eax, ecx; jmp L2; done: xor edx, edx; mov ebp, eax; pop ebp; ret; _max ENDP END 

3) call an assembly function to compute the smallest (min) of all elements in the array (pass the array and the size of the array)

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!