Question: Write a MIPS assembly language program that does the following: Ask the user to enter two integers x and y, compute and display the GCD,
Write a MIPS assembly language program that does the following: Ask the user to enter two integers x and y, compute and display the GCD, then ask the user whether he wants to repeat the program. Use the divu instruction to do the unsigned division and the mfhi instruction to move the remainder of the division to a general-purpose register. You can also use the remu pseudo-instruction that will compute the remainder of unsigned division.
MIPS programming with MIPS simulator, QtSPIM or Mars, for the following two questions. Submit the source code of the program. Make sure that your program is well documented. 1. Greatest Common Divisor (GCD): the greatest common divisor of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves integer division in a loop, described by the following code: int GCD (int x, int y) l x = abs(x) ; // absolute value y = abs (y) ; do t int n = x % y; // n = remainder of dividing x by y x=y; y=n; while (y > 0) return x; Write a MIPS assembly language program that does the following: Ask the user to enter two integers x and y, compute and display the GCD, then ask the user whether he wants to repeat the program. Use the divu instruction to do the unsigned division and the mfhi instruction to move the remainder of the division to a general-purpose register. You can also use the remu pseudo-instruction that will compute the remainder of unsigned division
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
