Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q.1. Write a MIPS assembly language program that implements the following: (i) A procedure, PrintA, that prints the content of an array of integers in

Q.1. Write a MIPS assembly language program that implements the following:

(i) A procedure, PrintA, that prints the content of an array of integers in a twodimensional format (row-wise) leaving a space between elements. Assume that the procedure receives as parameters the address of the array in register $a0, the number of rows in register $a1, and the number of columns in register $a2.

(ii) A procedure, RSum, that computes the sum of a given row. Assume that the procedure receives as parameters the address of the array in register $a0, the number of columns in register $a1, and the index of the row to be summed in register $a2. The procedure should return the sum of the row in register $v0.

(iii) A procedure, CSum, that computes the sum of a given column. Assume that the procedure receives as parameters the address of the array in register $a0, the number of rows in register $a1, the number of columns in register $a2, and the index of the column to be summed in register $a3. The procedure should return the sum of the column in register $v0.

(iv) A procedure, ArrayRowSum, that displays the sums of all rows in the array based on using RSum procedure. Assume that the procedure receives as parameters the address of the array in register $a0, the number of rows in register $a1, and the number of columns in register $a2.

(v) A procedure, ArrayColSum, that displays the sums of all columns in the array based on using CSum procedure. Assume that the procedure receives as parameters the address of the array in register $a0, the number of rows in register $a1, and the number of columns in register $a2.

(vi) Ask the user to enter number of rows, R, and number of columns, C, and read it.

(vii)Ask the user to enter an RxC matrix of integers and read it.

(viii)Print a menu from which the user can select one of the following options: 1. Print the Entered Array 2.

Print Sum of a Row 3.

Print Sum of a Column 4.

Print Rows Sum 5.

Print Columns Sum

6. Exit the program A sample execution of the program is shown below: Enter number of rows:2 Enter number of columns:3 Enter an array of 2x3 integers: 1 2 3 4 5 6 Select one of the following functions: 1. Print the Entered Array 2. Print Sum of a Row 3. Print Sum of a Column 4. Print Rows Sum 5. Print Columns Sum 6. Exit the program If the user selects the first option, then the following should be displayed: Array of 2x3 integers is: 1 2 3 4 5 6 If the user selects the second option, then the following should be displayed: Enter the row number: 0 Sum of row number 0 is:6 If the user selects the third option, then the following should be displayed: Enter the column number: 1 Sum of column number 1 is:7 If the user selects the fourth option, then the following should be displayed: Array rows sum are: Sum of row 0: 6 Sum of row 1: 15 If the user selects the fifth option, then the following should be displayed: Array columns sum are: Sum of column 0: 5 Sum of column 1: 7 Sum of column 1: 9

If any of the entered row numbers or column numbers are out of range, your program should display an error message and asks the user to reenter the required information.

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions