What is Return address?

The address to go back to when a function finishes. In RISC-V, jal puts the next instruction's address in ra (x1); in x86, call pushes it on the stack.

Field: ISA & Assembly

Return address in the explanations

Questions that mention Return address (10)

  1. When a program calls a subroutine (function), which area is generally used to temporarily save the return address and similar information?
  2. What does a CPU's program counter (PC) hold?
  3. What is the property of register x0 (zero) in RISC-V?
  4. What does the RISC-V instruction "jal ra, func" do?
  5. A function that calls no other functions (a leaf function) often does not need to save ra on the stack. Why?
  6. What is the purpose of executing "addi sp, sp, -16" at the start of a RISC-V function?
  7. The code above is the start (prologue) of a function. What does it do?
  8. How is a call through a C function pointer, "(*fp)(x)", generally performed in RISC-V?
  9. Which attack does W^X (never allowing a page to be both writable and executable) make harder?
  10. When returning from an interrupt or exception handler, why is a dedicated return instruction (such as RISC-V's sret or mret) used instead of an ordinary function return?

Related terms

Stack frame Stack pointer Calling convention Pseudo-instruction Leaf function Interrupt Privileged mode Addressing mode Application binary interface (ABI) Assembler

Back to the glossary