Understanding RISC-V Function Calls

Slide Note
Embed
Share

In RISC-V function calls, the decision to place variables in caller-saved or callee-saved registers depends on various factors such as recursion and variable usage within the function. Additionally, understanding how function arguments are passed and stored is crucial for efficient program execution. The quiz questions further test knowledge about jal and jr instructions, register saving practices, and argument handling in RISC-V functions.


Uploaded on Jul 26, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. L08 RISC V Function Calls CS295 Question You are a compiler. Do you choose to put a in a: (A) Caller-saved register (t) (B) Callee-saved register (s) (C) Depends on where we put the other variables in this fn (D) Both are equally valid 1

  2. L08 RISC V Function Calls CS295 Question You are a compiler. Do you choose to put a in a: (A) Caller-saved register (t) (B) Callee-saved register (s) (C) Depends on where we put the other variables in this fn (D) Both are equally valid Repeat but assume that foo is recursive (bar/baz foo) 2

  3. L08 RISC V Function Calls CS295 Question You are a compiler. Do you choose to put b in a: (A) Caller-saved register (t) (B) Callee-saved register (s) (C) Depends on where we put the other variables in this fn (D) Both are equally valid 3

  4. L08 RISC V Function Calls CS295 Question Which is a true statement about the arguments to the function void sub(int a, int b, int c, int d, int e, int f, int g, int h, int i); A. Arguments a-i are all passed in registers. B. Arguments a-i are all stored on the stack. C. Only i is stored on the stack, but space is allocated for all 9 arguments. D. Only a-h are stored on the stack, but space is allocated for all 9 arguments. 4

  5. L08 RISC V Function Calls CS295 Quiz Which statement is FALSE? 1: RISC-V uses jal to invoke a function and jr to return from a function jal saves PC+1 in ra 2: The callee can use temporary registers (ti) without saving 3: and restoring them The caller can rely on save registers (si) without fear of callee 4: changing them

Related


More Related Content