Basic System Problem Analysis - August 2003

45
Procedure Calling Convention
There is considerably more to the procedure calling convention than is represented on the
previous page but those are some of the more important points.
A stack frame only needs to be built if the current procedure will call other procedures. A
leaf procedure would be one that makes no calls so there is no need for it to allocate
space to spill registers.
It is worth noting that while the caller and callee are responsible for saving ranges of
registers they are not obliged to save them all. For example, the “caller save” registers
only need to be saved if they are active at the time of the call and need to be restored to
their prior state on return from the call.
This fact can make it quite difficult, if not impossible to locate values that may have been
available before a procedure call was made but which may have disappeared after the
call because they are no longer needed.