In: Computer Science
Binary Search. Write a MIPS assembly program to perform a binary search on A[10], which is an array of 10 positive integers. Your program should have a main routine that does the following:
(a) Prompt the user to enter all the 10 integers in the array.
(b) Prompt the user to enter the number to be searched.
(c) Reads the integer values and makes sure it is a positive integer.
(d) Prints the index of the integer. If the input is not available in the string, the code should print a string: "Element not present in the array".
Please add comments next to each MIPS Instruction stating what it is exactly doing. Also include the psuedo code in C for your MIPS program.
Pseudo code for Binary search in C
A ← sorted array n ← size of array x ← value to be searched Set lowerBound = 1 Set upperBound = n while x not found if upperBound < lowerBound EXIT: x does not exists. set midPoint = lowerBound + ( upperBound - lowerBound ) / 2 if A[midPoint] < x set lowerBound = midPoint + 1 if A[midPoint] > x set upperBound = midPoint - 1 if A[midPoint] = x EXIT: x found at location midPoint end while end procedure