CPUs and architecture
When a program calls a subroutine (function), which area is generally used to temporarily save the return address and similar information?
- AThe stack
- BCache tags
- 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.