Below is C code that runs successfully but now i want to rewrite this C code and convert it to MIPS Assembler Language Program . using MARS code environment Please include .data and .te #include
Computer Science
Below is C code that runs successfully but now i want to rewrite this C code and convert it to MIPS Assembler Language Program . using MARS code environment
Please include .data and .te
#include<stdio.
#include<stdlib.
// add two matr
void add(int m[2][2], int n[2][2], int sum[2][2
for(int i=0; i<2; i++
for(int j=0; <2; j+
sum[i][j] = m[i][j] + n[i][j
// subtract two matri
void subtract(int m[2][2], int n[2][2], int result[2][2
for(int i=0; i<2; i++
for(int j=0; j<2; j+
result[i][j] = m[i][j] - n[i][j
// multiply two matri
void multiply(int m[2][2], int n[2][2], int result[2][2
for(int i=0; i < 2; i++
for(int j=0; j < 2; j++
result[i][j] = 0; // assign
// find produ
for (int k = 0; k < 2; k+
result[i][j] += m[i][k] * n[k][j
// find transpose matr
void transpose(int matrix[2][2], int trans[2][2
for (int i = 0; i < 2; i++
for (int j = 0; j < 2; j+
trans[i][j] = matrix[j][i
// display matri
void display(int matrix[2][2
for(int i=0; i<2; i++
for(int j=0; j<2; j++
printf("%d\t",matrix[i][j]
printf("\n"
// ma
int main
// matri
int a[][2] = { {8,2,7}, {3,1,2}
int b[][2] = { {7,8,9}, {1,2,3}
int c[2][2
// print both matr
printf("First Matrix:\n"
display(a
printf("Second Matrix:\n"
display(b
// variable to take choi
int choic
// menu-driv
// men
printf("\nChoose one of the matrix operation:\n"
printf("----------------------------\n"
printf("1. Addition\n"
printf("2. Subtraction\n"
printf("3. Multiplication\n"
printf("4. Transpose\n"
printf("5. Exit\n"
printf("----------------------------\n"
printf("Enter your choice: "
scanf("%d", &choice
switch (choice)
case
add(a, b, c
printf("Sum of matrix: \n"
display(c
brea
case
subtract(a, b, c
printf("Subtraction of matrix: \n"
display(c
brea
case
multiply(a, b, c
printf("Multiplication of matrix: \n"
display(c
brea
case
printf("Transpose of the first matrix: \n"
transpose(a, c
display(c
printf("Transpose of the second matrix: \n"
transpose(b, c
display(c
brea
case
printf("Thank You.\n"
exit(0
defaul
printf("Invalid input.\n"
printf("Please enter the correct input.\n"
}while(1
return
}0;); }););t:););5:k;););););););4:k;);););3:k;);););2:k;);););1: {););););););););););u
{doene;ce););););ix];};};x
{()in}
}););)
{)
{])x
}];+))
{])ix}
} }];+)ct 0 {)
{)
{])x
}];+))
{])x
}];+))
{])ixh>h>xt. case 5:
printf("Thank You.\n");
exit(0);
default:
printf("Invalid input.\n");
printf("Please enter the correct input.\n");
}
}while(1);
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)