$30
• All problems must be solved using MIPS assembly language programs. The programs should be tested using SPIM.
• Please refer to the SPIM commands and introduction to SPIM handouts already posted on course webpage. Additionally, Sections A.9 and A.10 from Appendix A of Patterson and Hennessy have all details regarding SPIM.
• Use of pseudo-instructions supported by SPIM is allowed.
• When you enter a value from keyboard, make sure to press “ENTER” after entering the value; otherwise the system call layer will not accept the input. As a result, when entering an array of values, please enter them one per line.
1. Write a recursive function to do binary search on a given sorted array for a given element. Write a main function that accepts an integer n and n integer elements of a sorted array and an integer k to search in the array as inputs (from keyboard) and searches for k in the array using the binary search function. At the end, if the element is found, the main function should print “Found element at index N” where N is the index of the found element in the array and if the element is not found, the main function should print “Element was not found”. Allocate the array statically and assume n ≤ 12.
2. Take an integer n and a single-precision floating-point n-dimensional vector A = (an−1,an−2,...,a0) as inputs. The vector components are input in the order a0,a1,...,an−1. Compute using a MIPS assembly language program. The final single-precision floating-point result should be printed on the display. Allocate the vector statically and assume n ≤ 15.