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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;

 

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computing Algorithms
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education