Starting from:

$30

Assignment 5: MIPS Programming

CDA 4205 Computer Architecture 
Assignment 5: MIPS Programming
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) {
x = abs(x); // absolute value
y = abs(y);
do {
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.
2.    Searching a String: Write a MIPS assembly language program to do the following:
Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of occurrences of the two-character string.

Enter a string of at most 100 characters: MIPS programming is nice
Enter a character: i
Number of occurrences of i = 4
Enter a string of two characters: mi
Number of occurrences of mi = 2
Repeat (Y/N)? n

    Submission Requirements
    Submit the source code of the program. 
    Make sure that your program is well documented.
    Only submissions via the link on Canvas where this description is downloaded are graded. Submissions to any other locations on Canvas will be ignored.
    Late submissions are accepted for a maximum of 3 late days with 20% assignment credit off as late penalization. Assignments submitted after 3 late days will not be accepted.

More products