Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an MIPS program that prompts the user for a series of 10 integers and hold

ID: 3586623 • Letter: W

Question

Write an MIPS program that prompts the user for a series of 10 integers and holds them in an integer array. Print the array with tabs between the elements, go to the next line, then reverse the elements in the array and print the integers again (with tabs) in the resulting reversed order. Do not just pass through the array in reverse order to print it. Exchange the actual data elements in the array.

For example, if the user enters this series (again, prompt for these on separate input lines):

12 8 11 32 20 1 29 6 19 12

print this (on two lines as shown):

12 8 11 32 20 1 29 6 19 12

12 19 6 29 1 20 32 11 8 12

Explanation / Answer

Reverses order of array elements between index values Lo and Hi.

Pre:

$a0 points to the zero-th element of array A

$a1 contains the value of Lo

$a2 contains the value of Hi

0 <= Lo <= Hi < dimension of array

Post:

Elements A[Lo]...A[Hi] have been reversed

Returns (in $v0):

0 if operation is completed normally

1 if pointer to array is <= 0 # 2 if Lo < 0

3 if Lo >= 0 but Hi < Lo

Registers modified: $t*, $v0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote