CPUs and architecture

When a program calls a subroutine (function), which area is generally used to temporarily save the return address and similar information?

  1. AThe stack
  2. BCache tags
  3. CA fixed region of ROM
Show answer and explanation

Answer: A. The stack

Calling a subroutine pushes the return address, registers to be preserved and local variables onto the stack. On ARM and RISC-V, the return address first goes into a link register and is saved to the stack when needed. Its last-in, first-out (LIFO) structure ensures correct returns even with nested or recursive calls, and the stack pointer marks its top. Excessive recursion exhausts it (stack overflow), and buffer overruns that overwrite return addresses are a classic attack.

  • A. Correct. Return addresses and similar data are saved on the stack.
  • B. Cache tags indicate which address the cached data belongs to.
  • C. ROM cannot be written, so it cannot be used for temporary storage at run time.

Related calculators

Books on CPUs and architecture Ad

As an Amazon Associate I earn from qualifying purchases.

More CPUs and architecture questions

  1. Which correctly lists the "three Cs" classification of cache misses?
  2. In an out-of-order CPU, which mechanism commits (retires) the results of instructions executed out of order in the program's original order?
  3. What is the main purpose of register renaming in out-of-order CPUs?
  4. In AI accelerators and similar, which architecture arranges many multiply-accumulate units in a grid and computes matrix products by passing data from one unit to the next?
  5. Which model plots whether a program's performance is limited by compute throughput or memory bandwidth, using arithmetic intensity (operations per byte) on the horizontal axis?

Comparisons in this topic