Hanas J.

asked • 05/31/23

RISC-V Conventions

You are the author of the function F while your friend is the author of the function G. Both F and G are located in the same RISC-V main memory but you and your friend do not know the contents of each other's codes. However, you both mutually agree to follow the RISC-V guidelines for using the appropriate registers in function calls.

Here is what is known to both of you:

1. The function F accepts its argument in a0 and returns its result in a1

2. The function G accepts its arguments in a0 and a1 and returns its result in a0

You have written the following lines of code for function F (which itself calls G) :

word-1.png

Since you don’t know how your friend implements G except that they follows the RISC-V conventions, which of the following registers must you store to stack memory before calling G(push at around line 10), and restore afterwards(pop at around line 12)? 


  1)a0,t1,t0

 

  2)t1,t0

 

  3)t0, ra

 

  4)t0

 

  5)None of the options

 

  6)a1,a0,t1,t0

 


1 Expert Answer

By:

Spencer B. answered • 07/22/23

Tutor
New to Wyzant

Computer Science and Cybersecurity Researcher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.