What is the difference between caller and callee recorded registers?

Specifically, how can you find out the number of save / restore operations performed on variables in a piece of code in the register stored for the caller and in the register registered with callee?

0


source to share


2 answers


Caller registers, also known as volatile registers, are CPU registers that a calling function must execute (usually on the execution stack) if the calling function needs a register value; those. if the value is "live". Callee-stored registers, also known as non-volatile registers, are CPU registers that contain values ​​that a function must promise in order not to destroy. If a called function (called a function) is to use these registers, it must first store the values ​​in these registers (usually on the execution stack) and then restore them before returning to the caller.

As Karl Norum mentions, which main CPU registers are the caller and which are the calls being called is determined by the calling convention (historically poorly documented and historically compiler specific) or defined by the ABI (Application Binary Interface).

While his information is clearly x86-specific, the following Agner Fog document does a really good job of describing calling conventions and caller / caller save registers:



http://www.agner.org/optimize/calling_conventions.pdf

The following describes EABI PowerPC, including its calling convention. But in this document find "volatile" and "non-volatile" (save and save calls accordingly):

http://www.freescale.com/files/32bit/doc/app_note/PPCEABI.pdf

+3


source


Physically, there is no difference between a stored register and a stored register. The difference is made only by the standard procedure call (calling convention) or the ABI. If you need to parse a piece of code, you can compile (but not compile) or disassemble the binary and step through the function by function and instruction instructions using the ABI manual or invocation as reference.



+2


source







All Articles