Question

If you need to keep the value held in $1, what is a safe way to...

If you need to keep the value held in $1, what is a safe way to call the subroutine other that might use this register, i.e what do you need to do before (and after) you jal other?

Homework Answers

Answer #1

There are two ideas behind a subroutine.

  1. You should be able to call the subroutine from anywhere.
  2. Once the subroutine is complete, it should return back to the place that called the subroutine.

For making a subroutine call is jal which means "jump-and-link".

jal takes a label as its operand. This label is an address in memory for a subroutine. The assembler translates the label to an address.

To jump to that address really means to update the PC (program counter) to the address of the subroutine. The PC is a hidden register that holds the address of the current instruction being run.

The jal instruction saves the return address in register $r31. This register is also called $ra (where "ra" means return address).

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Q1 ) We are writing a subroutine, and want to use $t0. What are the considerations?...
Q1 ) We are writing a subroutine, and want to use $t0. What are the considerations? (check all that apply) 1 - We know that the routine which called us gives us permission to use this register, so we don't have to save its value before using it. 2 - The routine which called us may have an important value in that register, so we should save its value before using it. 3- We know that the subroutine won't touch...
what should you do if the member is not safe (>1)? Provide three things to do...
what should you do if the member is not safe (>1)? Provide three things to do and why what should i do to make a beam or a column safe ? For example increase or decrease the section because .... i need three things
How do healthcare providers(e.g. Hospital,emergency department,personal physician,nurse practitioner,therapist,pharmacist) keep you safe from being harmed by the...
How do healthcare providers(e.g. Hospital,emergency department,personal physician,nurse practitioner,therapist,pharmacist) keep you safe from being harmed by the effects of healthcare services?what could your providers do better to keep you safe?
What is cash only accounting and what records do you need to keep for it? NO...
What is cash only accounting and what records do you need to keep for it? NO HAND WRITTEN ANSWERS PLEASE
You currently have $1,440,000 of wealth, which you keep in the form of two assets: a...
You currently have $1,440,000 of wealth, which you keep in the form of two assets: a bank account worth $1,400,000 and $40,000 in cash in your home safe. However, while you are confident that your home safe is secure, you are concerned that there is a probability ?>0 that your bank will fail (i.e., declare bankruptcy), in which case you would lose all the money in your bank account. (Assume this is the only bank available to you.) The von...
1) What considerations do you need to be aware of before you recognize and reward an...
1) What considerations do you need to be aware of before you recognize and reward an employee? (2) What are some awards/rewards you would like to use to recognize an engaged employee?
When you write code, how do you know that you need to use value or reference?...
When you write code, how do you know that you need to use value or reference? Please show with an example. I know reference is two way communication but it is not clear to me. Thanks
As you all know,The only constant thing in the world is Change. We need to keep...
As you all know,The only constant thing in the world is Change. We need to keep changing in order to grow further and to achieve success on a continuous basis. Moving forward, we have decided to bring about certain changes in the organizational structure. The organization is moving from a flat structure to a tall structure as the handling of subordinates and giving proper attention on each has become little difficult. The best way to implement the change is to...
What variables will you keep the same in this experiment? Check off the items in this...
What variables will you keep the same in this experiment? Check off the items in this list that you would use for this experiment. You may add any items you feel you would need. Skim milk (which contains lactose) Lactase drops Graduated cylinder Eye dropper Ice cubes pH paper Hot plate Mixing spoon Thermometer Vinegar (acidic) Test tubes Glucose test strips Baking soda (basic) Other items you feel you would need to use for this experiment. Describe what you would...
What is the difference between future value and present value? What data do you need to...
What is the difference between future value and present value? What data do you need to do a future value or present value calculation?