110k views
1 vote
What are callee/caller saved registers?

User Benyamin
by
8.2k points

1 Answer

5 votes

Final answer:

Callee-saved registers must be preserved by the function being called, while caller-saved registers must be preserved by the function making the call if they wish their values to remain unchanged. This is crucial for effective function calls and program state management.

Step-by-step explanation:

The terms callee-saved registers and caller-saved registers refer to the conventions used in computer function calls regarding register use and which registers must be preserved (saved) across function calls. In most calling conventions, certain registers are deemed callee-saved; this means that if a function uses these registers, it is responsible for saving and restoring their original values before it returns to the caller. This allows the calling function to assume that the values of these registers will not change across the function call.

Conversely, caller-saved registers (or volatile registers) are expected to be saved by the caller if they wish to preserve their values; the callee is free to modify them without saving. The use of callee and caller-saved registers is a critical aspect of efficient function call implementation and ensures that a program’s state is properly managed when passing control among various functions.

User Josh Gagnon
by
7.6k points