Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 2521 - LAB 03 FUNCTIONS AND PROCEDURES LAB GOALS: Learn about implementing functions and procedures, using address referencing, in MIPS We've learned how to

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
CS 2521 - LAB 03 FUNCTIONS AND PROCEDURES LAB GOALS: Learn about implementing functions and procedures, using address referencing, in MIPS We've learned how to implement branching and conditionals in MIPS, but what about functions? Recall that functions are a way to perform a specific task without having to rewrite all of the code each time, instead just (perhaps) passing in a few important values to the function and getting back the result. They are a way to avoid having to think about solving specific problems within a bigger problem, and are thus very useful. But how do we implement this functionality in MIPS? To understand how we can implement functions in MIPS, we have to understand what happens before and after a function is called. Let's look at an example of a function call (called calculate. value) within a program: //earlier program code int myInt = 2; int newint = calculate-value (my1nt); //program continues There are several things we should note about this call: 1. We give the function a value (which it presumably does something with) 2. The function has a return value, which we are setting a new integer to 3. The call to the function jumps (branches) to a different location in memory where the function resides After this we jump back to our program at the line just after the function call (llprogram continues) 4

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

More Books

Students also viewed these Databases questions

Question

=+ One person creates a new design using thumbnail sketches.

Answered: 1 week ago

Question

=+Discuss the key benefits and challenges of a personal brand

Answered: 1 week ago