Please help write a MIPS program that: 1.Place the given array in memory: my_arr
ID: 3591938 • Letter: P
Question
Please help write a MIPS program that:
1.Place the given array in memory: my_array=[1,4,5,7,9,12,15,17,18,20,21,30]
2.Place the size of the array in memory: array_size=11
3.Load the base address of your array into $s0 using ‘la’ and load the size of your array into $s1 using ‘lw’
4.Write a function: binary_search to perform binary search on my_array. The function will take the following 3 inputs from registers in main:
<1> the base address of the array from $s0
<2> size of the array from $s1 and
<3> the element you’re searching for in the array from $s2. It will return the index of the element search for in $v0.
5. Run
the following 4 tests in main to check the correctness of your code:
(a) Perform binary_search to find the index of element ‘15’ and save the index on $s3
(b) Perform binary_search to find the index of element ‘4’ and save the index on $s4
(c) Perform binary_search to find the index of element ‘30’ and save the index on $s5
(d) Perform binary_search to find the index of element ‘0’ and save the index i.e. (-1) onto $s6. Since ‘0’ is not in my_array, the binary_search should return (-1) as the index.