Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

50 points Write a MIPS assembly program that finds the maximum number in an integer array using a recursive procedure. Normally, we can write a

image text in transcribed

50 points Write a MIPS assembly program that finds the maximum number in an integer array using a recursive procedure. Normally, we can write a for loop that scans through the array and compute the maximum number. Instead, we will use an alternate recursive algorithm. The pseudocode for the algorithm is given below. Here, FindMax is the recursive procedure to be implemented. This procedure takes as input an array of n numbers (you will need two arguments: base address of array and length of the array). It then compares the first element in the array with the maximum of the rest of the n-1 numbers (by making a recursive call), and returning the one that is greater. FindMax(Alo] AIn) if (n1) return Al0]; if (A0 FindMax (AlI],, Aln) return Al0 else return FindMax(A],..., Aln]) Your implementation must correctly create and destroy the stack frame for each invocation of the recursive procedure. You must also use the calling convention described in class: The first four input arguments must be in $a0-$a3 and the remaining (if anyust be passed through the stack. Likewise, the first two output arguments must be in $vo--$v1 and the remaining (if any) must be passed through the stack. 50 points Write a MIPS assembly program that finds the maximum number in an integer array using a recursive procedure. Normally, we can write a for loop that scans through the array and compute the maximum number. Instead, we will use an alternate recursive algorithm. The pseudocode for the algorithm is given below. Here, FindMax is the recursive procedure to be implemented. This procedure takes as input an array of n numbers (you will need two arguments: base address of array and length of the array). It then compares the first element in the array with the maximum of the rest of the n-1 numbers (by making a recursive call), and returning the one that is greater. FindMax(Alo] AIn) if (n1) return Al0]; if (A0 FindMax (AlI],, Aln) return Al0 else return FindMax(A],..., Aln]) Your implementation must correctly create and destroy the stack frame for each invocation of the recursive procedure. You must also use the calling convention described in class: The first four input arguments must be in $a0-$a3 and the remaining (if anyust be passed through the stack. Likewise, the first two output arguments must be in $vo--$v1 and the remaining (if any) must be passed through the stack

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Identify cultural barriers to communication.

Answered: 1 week ago

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago