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
When a subroutine is called, the return address, register values, local variables and so on are pushed onto the stack. The stack is last-in, first-out (LIFO), so even nested calls return in the correct order. The stack pointer indicates the top of the stack.
- 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.