Question: write and test a mips program using only mars with...
Write and test a MIPS program USING ONLY MARS WITH NO PSEUDOINSTRUCTION consisting of four functions. Note: In the following descriptions, the symbol & means “address of”.
1. void main(): The main function must print your name, call readvals to place the values into an array of 10 single precision floating point numbers and then call the print function to complete the program. The main function must set up all parameters before calling each of the functions.
2. int readvals (&array): The starting address of an array is passed to the function as a parameter using $a0. The function must prompt for, read and store floating point numbers into the array until either a negative number is entered or 10 numbers are read. Once the tenth number is entered, your program must stop reading. The function must return (using $v0) the number of values read and stored in the array (10 or less). The negative ending input is not part of the array and must not be stored in the array. If the first input is a negative number, then the array will be empty and the count returned is zero.
3. float average (&array, count): The starting address of an array (in $a0) and the number of values stored in the array (in $a1) are passed to the function. The purpose of the function is to calculate and return (using $f0) the floating point average of the numbers. If the count is zero, return 0.0.
4. void print (&array, count): The starting address of an array (in $a0) and the number of values stored in the array (in $a1) are passed to the function. The function should print all values stored in the array each on its own line. Then the average function is called to determine the average value. The returned value is then printed. As this function calls another function, it must store the $ra on the stack and then restore it at the end.
Example input and output. Note: floating point output cannot be formatted. This is not real output.
Enter a number 3.0
Enter a number 6.0
Enter a number 2.0
Enter a number 4.0
Enter a number -1.0
? Functions must be called using jal and return using jr.
? Parameters must be passed as specified and used correctly. The readints, average and print functions must access the array through the parameter $a0, not determine the address directly.
? Be sure to comment all instructions. All functions must include comments describing the function and its parameters and return value (if any)