Translate the following simple C procedure program into MIPS assembly……solved




5/5 - (5 votes)

Question 1.

Translate the following simple C procedure program into MIPS assembly:
int compute(int a, int b){
return (a -b) *(a + b);
Solve question above again from homework 3, except this time rather than returning the result
print the answer using the syscall instruction. Assume the answer is an integer that fits into 32 bits .
The point of this question is to get you to use interrupts.

10 pts.

Question 2
Assuming the existence of the following .data segment
arbstr: .asciiz “This is an arbitrary string” # arbitrary string
Where arbstr can contain any ASCII string.
Write a procedure called strlen that prints the length of the string and returns the length of the string as an argument.
30 pts

Question 3
Given we have the solution in question 2, write a procedure that checks if an arbitrary string with the same .data segment above is a palindrome (Links to an external site.).
30 pts

Please submit all code in .asm files. Use the MARS simulator to debug your assembly code. Please put comments in your code, this should be considered part of writing good code. I will deduct marks for not having appropriate comments in your code . Also, you should include test cases as well.