In: Computer Science
Write MIPS code for finding the (estimated) square-root of a number N, by using the following pseudo-code:
sqrt = N; repeat 10 times {
sqrt = (sqrt + N/sqrt)/2; }
The number N is entered by the user and the answer is displayed on the screen as (for example):
The square root of 121 is 11.
Write MIPS code for finding the distance between two points [x1,y1] and [x2,y2]. The formula for the distance is:
z = ?(x2 − x1)2 + (y2 − y1)2
x1,x2,y1 and y2 are entered by the user and the answer z is
displayed on the screen as
(for example):
The distance is 12.
(Hint: Reuse the square-root code from the previous question.
Write MIPS code that finds and prints the smallest number in the integer array “arr”. The declaration of the array is shown below:
.data arr: .word 100, 10, 3, -2, 110, 0, -50, 150, -17, 8