Question: Write a program in MIPS machine language code to be run on a MARS simulator that calls a procedure called average to calculate the average

Write a program in MIPS machine language code to be run on a MARS simulator that calls a procedure called "average" to calculate the average of two values.

Initialize the two values to be averaged in main as 2 (num1) and 12 (num2). Pass these two values as parameters on the stack to the average procedure. Compute the average of the two value parameters in the procedure. Use the stack to pass the result back to main.

REQUIREMENTS:

1. Load immediate values for num1 and num2 into save registers $s0, $s1 respectively.

2. Create a procedure to calculate the average of the two values. Store the average result in the temporary register $t0.

3. Use the stack to pass the values obtained in main to the procedure.

4. Use the stack to return the result generated in the procedure back to main.

5. Be sure to create and destroy stack frames as needed to cleanly implement your solution.

6. Use "#" on every line to describe what you are doing/what act you are performing.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!