Question: Make a MIPS MARS program to The desired functionality is 1) for your program to allocate a 32 bytes space in heap. 2) Then your
Make a MIPS MARS program to
The desired functionality is 1) for your program to allocate a 32 bytes space in heap. 2) Then your program should prompt the user to enter eight integer numbers (One integer needs 4 bytes, eight integers need 32 bytes). Think of these numbers as getting stored into an array A that are allocated in heap, with the first number entered stored in A[0], the second number stored in A[1], etc. 3) After the user enters eight natural numbers, your programs will input two more natural numbers, i and j, then 4) these two numbers and the base address of array A are passed into a function (a procedure), which can calculates and outputs the quotient and remainder when A[i] is divided by A[j].
If the user enters an i or j value beyond the bounds of A (for example, As last element is stored at A[7] but the user enters 8 for the value of i or j), your program needs to print an error message indicating that the users input is not valid.
If the user tries to divide a number by 0, your program should also output a message showing that Illegal operation, division by 0.
Examples of Desired Behavior:
1) Example 1
Enter a natural number: 8
Enter a natural number: 7
Enter a natural number: 6
Enter a natural number: 5
Enter a natural number: 4
Enter a natural number: 3
Enter a natural number: 2
Enter a natural number: 1
Enter an index: 1
Enter an index: 6 7/2: Quotient is 3, remainder is 1
2) Example 2
Enter a natural number: 8
Enter a natural number: 7
Enter a natural number: 6
Enter a natural number: 5
Enter a natural number: 4
Enter a natural number: 3
Enter a natural number: 2
Enter a natural number: 1
Enter an index: 9
Enter an index: 7 Invalid input. Out of boundary.
3) Example 3
Enter a natural number: 8
Enter a natural number: 7
Enter a natural number: 6
Enter a natural number: 5
Enter a natural number: 0
Enter a natural number: 3
Enter a natural number: 2
Enter a natural number: 1
Enter an index: 1
Enter an index: 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
