Overview - Preserving callee-saved registers
What is it?
Preserving callee-saved registers means saving certain CPU registers before a function uses them and restoring them before the function ends. These registers hold important data that must not be lost when one function calls another. The ARM architecture defines which registers are callee-saved, meaning the called function is responsible for keeping their values intact. This ensures that the calling function can continue correctly after the call.
Why it matters
Without preserving callee-saved registers, data stored in these registers could be overwritten by called functions, causing incorrect program behavior or crashes. This preservation allows multiple functions to work together safely, sharing the CPU without losing important information. It is essential for reliable software, especially in complex systems like operating systems or embedded devices.
Where it fits
Before learning this, you should understand basic ARM CPU registers and how function calls work. After this, you can learn about calling conventions, stack management, and how compilers generate code for function calls.