Question: Code and comments for each line of code please. main.c and array _ functions.asm are provided. Write two functions in NASM assembly that are callable

Code and comments for each line of code please. main.c and array_functions.asm are provided.
Write two functions in NASM assembly that are callable from C. The C
prototypes are as follows:
int array_max(int array[], int array_size);
int array_sum(int array[], int array_size);
Function *array_sum* takes an array (base address) of int's and the size of
the array as parameters. This function is to return the sum of all elements
in the array.
Function *array_max* takes an array of int's and the size of the array as
parameters. This function is to return the value of the greatest element
in the array.
Both of these function are to be implemented in assembly. The given C code
includes code to call these functions. You will need to uncomment that code
to test your functions.
main.c :
#include
int array_max(int array[], int array_size);
int array_sum(int array[], int array_size);
int main (){
int int_size = sizeof(int);
printf("Size of int is %d bytes.
", int_size);
int array1[]={1,17,32,14,5,32,48,29,3,7};
const int array1_len = sizeof(array1)/ sizeof(int);
int array2[]={7,-5,-15,3};
const int array2_len = sizeof(array2)/ sizeof(int);
int max, sum;
// TODO: Uncomment the following code when assembly function are in place
// max = array_max(array1, array1_len);
// sum = array_sum(array1, array1_len);
// printf("array1: sum=%d, max=%d", sum, max);
// max = array_max(array2, array2_len);
// sum = array_sum(array2, array2_len);
// printf("array2: sum=%d, max=%d", sum, max);
return 0;
}
array_function.asm:
section .text ; start of code segment
section .data ; start of initialized data segment
section .bss ; start of uninitialized data segment

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!