Solved-Programming Assignment II- Solution

$35.00 $24.00

Implement the following C code in MIPS assembly and run it in the SPIM simulator: int main() { int A[8] = {19, 25, 10, 0, 15, 1, 22, 2} int i, int fib_value; for (i = 0; i < 8; i++) { fib_value = fib(A[i]); printf(“%d\n”, fib_value); } return 0; } int fib(int n) {…

You’ll get a: . zip file solution

 

 

Description

5/5 – (1 vote)

Implement the following C code in MIPS assembly and run it in the SPIM simulator:

int main()

{

int A[8] = {19, 25, 10, 0, 15, 1, 22, 2}

int i,

int fib_value;

for (i = 0; i < 8; i++) {

fib_value = fib(A[i]);

printf(“%d\n”, fib_value);

}

return 0;

}

int fib(int n)

{

if (n==0)

return 0;

else if (n == 1)

return 1;

else

return fib(n−1) + fib(n−2);

}

  1. If your code does not run or produces result very different from correct one, your score would be substantially reduced. By adding comments, you may help grader to understand your program and lose fewer points.

  1. Please refer to the sample code of Lab1 for printing results.

  1. Submit your source code (lab2.asm) via the blackboard by the due time.

  1. Start your work as early as possible.