Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a MIPS program and execute in MARS 1 . Nested Procedures. The following is a pseudo code for performing the Fibonacci series up to
Write a MIPS program and execute in MARS
Nested Procedures. The following is a pseudo code for performing the Fibonacci series up
to n terms using nested functions.
import java.util.Scanner;
public class Fibonacci
public static void mainString args
Scanner scanner new ScannerSystemin;
System.out.printEnter the number of terms in the Fibonacci sequence: ;
int n scanner.nextInt;
Calculate and print the Fibonacci sequence
System.out.printlnFibonacci sequence:";
for int i ; i n; i
System.out.printfibonaccii;
scanner.close;
public static int fibonacciint n
if n
return n;
else
return fibonaccin fibonaccin ;
Implement the above pseudo code in MIPS assembly, execute it in MARS simulator and
submit your asm file. Make sure you add comments next to every instruction.
Recursive Function. Write a MIPS program and execute in MARS to recursively reverse
and array of integers. Submit your asm file with comments included. The following is the
pseudo code for the program.
public class Main
Function to reverse arr from start to end
static void reverseArrayint arr int start,
int end
int temp;
if start end
return;
reverseArrayarr start end ;
temp arrstart;
arrstart arrend;
arrend temp;
Utility that prints out an array on a line
static void printArrayint arr int size
for int i ; i size; i
System.out.printarri;
System.out.println;
Driver function to test above functions
public static void mainString args
int arr;
System.out.printOriginal array is : ;
printArrayarr;
reverseArrayarr;
System.out.printReversed array is : ;
printArrayarr;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started