Question: How do I develop a function SQRT in MIPS assembly program for SPIM simulator, which will compute the square-root of a given number? My program

How do I develop a function SQRT in MIPS assembly program for SPIM simulator, which will compute the square-root of a given number? My program should accept a number x from the screen/console input, which can be a negative or a positive number as well as it can be an integer or a real number. Algorithm for SQRT: will basically be doing a binary search for the given number range. For example, if we are to find SQRT (5): then search the mid value of the range 5 [i.e. middle point of 0 to 5] = 2.5. Now, 2.5 * 2.5 = 6.25 which is greater than 5.0. So, the answer must be within 0 to 2.5, so then again take the mid-point of [0 to 2.5] which is 1.25. Check 1.25 * 1.25 = 1.5625 which is less than 5.0. So the answer must be within 1.25 to 2.5 and similarly take the midpoint of that range and check. By keep on doing the steps repeatedly, once I get a mid-point y for which y y = 5.0 or, is acceptably very close to 5.0, then that y will be your answer. For a given number x, my program i) must print all the calculated mid-points on the output screen and ii) print (and indicate) the square-root of x.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!