Question: Write as Assembly MIPS program. Run these 4 experiments on your code. The experiment details are: Input 8 integers. Do not enter them in order,
Write as Assembly MIPS program.
Run these 4 experiments on your code. The experiment details are: Input 8 integers. Do not enter them in order, they should be put in order by the stack-control routine from project 3. You must save a separate log file for experiment. 1. search for the smallest integer that you had entered 2. search for the largest integer that you had entered 3. search for an integer near the median of the list entered 4. search for an integer that doesnt exist Note: These searches can be done in separate runs, you do not have to write code to run all four tests in a single run. ? Your main routine must read from input the value to be searched and pass value to the search subroutine using an $a register. Of course this will happen after inputting the 8 ints. ? The search subroutine should return 0 if the integer was not found and 1 if it was This value must be returned on $v0 register. ? The main method only needs to report whether or not the integer was found based on the return value of the subroutine. ? Remember, your search subroutine will need to store data on the stack before it calls itself recursively Pseudo code for binary Search: # val is the int to be searched # low is the lowest index of the portion of the array (stack) to be searched # high is the highest index of the portion of the array to be searched int binSearchRec(int val, uint &s, int low, int high) { if (low > high) return 0; int mid = (low + high) / 2; if (s[mid] == val) return 1; else if (s[mid] < val) return binSearchRec(val, s, mid + 1, high); else return binSearchRec(val, s, low, mid - 1); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
