Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the following C code in MIPS assembly. In other words, you must implement the recursive calls. You need to test the program for n

Implement the following C code in MIPS assembly. In other words, you must implement the recursive calls.

image text in transcribed

You need to test the program for n = 1, 2, 3, 5, 7, and 10 respectively. I'm adding a program down which you must use to test it. Include the results as well (output).

Test Program:

# $s7 - save $ra # $s1 - s6 - used as a temporary register # $a0 - for function parameter / syscall parameter # $v0 - syscall number / function return value .text .globl main main: addu $s7, $ra, $zero, # Save the ra la $a0, int_prompt # Display the prompt li $v0, 4 syscall li $v0, 5 # Read an integer from the user syscall bgtz $v0, positive # If the number is not positive, # we negate the number. sub $v0, $zero, $v0 positive: slti $s1, $v0, 1001 # is $v0  

Also, what is the total number of MIPS instructions needed to execute the function n = 10?

Thanks!

int my fib(int n)( if (n= 0) else if (n=-1) else return my_fib(n-1) +my fib(n-2); return 2; return 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions