CS计算机代考程序代写 mips assembly Question 1: Implement a MIPS-version of the strncmp() C function, as standardized by the ISO C standard.

Question 1: Implement a MIPS-version of the strncmp() C function, as standardized by the ISO C standard.
Task: Given the following C code snippet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include #include
int main() {
char s1[5] = STRING 1; char s2[6] = STRING 2;
int n = N;
int result = strncmp(s1, s2, n);
printf(“The result is %d.”, result);
return 0; }
Note: To execute the code snippet above, you may need to replace the RED colored content by syntactically correct C code. For example:
6 char s1[5] = “abcd”;
7 char s2[6] = “abcde”;
8 int n = 2;
Then the program should output The result is 0.
You are required to implement the MIPS assembly code that returns EXACTLY the same result as efectively calling the strncmp() function in line 10 of the code snippet above. You should not change any parts in the above code snippet, except the red colored content. Input:
Once you execute your code, at the simulator console, by invoking the appropriate syscall, your program should intake a string in the following format (Px indicates Parameter x): P1:STRING 1;P2:STRING 2;P3:N;
where the RED colored content should be replaced in the same way as the above C snippet. For example:
P1:”abcd”;P2:”abcde”;P3:2;
Output:
After your code is executed based on the above input, by invoking the appropriate syscall, at the simulator console, your program should output the corresponding strncmp result. For the example above, the output should be:
0
What happens if strncmp() returns an error?
At the simulator console, your program should output the following message below. Note that: you do not have to specify the error, but make sure your program generates exactly this error message whenever strncmp() generates any error message.
An error has occurred.

Question 2: Write a program in MIPS32 assembly language which takes three input arguments: register A will receive the initial address of a string, register B will receive a character, and register C will receive another character. Within the string A, your program will replace any occurrence of the character stored in register B by the character stored in register C. Finally, output the
replaced string in register A. For example: Input string in register A: common
Input character in register B: m
Input character in register C: t
Output string in register A: cotton
Question 3: Implement a MIPS32 program which prompts user two integer inputs x, y from the console and calculate the following expression in signed 32-bit arithmetic:
x3 + 3x2y + 3xy2 + 9y3
Note that you are NOT allowed to use pseudo-instructions with overflow checking for the calculation (e.g. you cannot use mulo). If an overflow occurs during any step of the calculation, you should print an error message instead, and stop the program.
Hint: You could simplify the expression before calculation. Please remember to test your program with a range of different inputs, for example: x = 2, y = 3; x = -3, y = 4;
x = 1000; y = 150000; etc.