views:

40

answers:

2

hi ,

While reading some calling convention in some CPU architecture i read something like

"epilog and prolog" , when a function is called from another function.

Can anybody give more inputs on this?

/renjith_g

A: 

Wikipedia FTW: https://secure.wikimedia.org/wikipedia/en/wiki/Function_prologue

This seemed to explain it fairly well, in my opinion. If there is anything that is unclear, let me know and I can try and clear things up.

Adam Shiemke
Nice one.Thanks. :-)
Renjith G
+2  A: 

The epilogue and prologue of a function are simply the set of instructions that 'set up' the context for the function when it's called and clean up when it returns.

The prologue typically performs such tasks as:

  • saves any registers that the function might use (that are required by the platform's standard to be preserved across function calls)
  • allocates storage on the stack that the function might require for local variables
  • sets up any pointer (or other linkage) to parameters that might be passed on the stack

The epilogue generally only needs to restore any save registers and restore the stack pointer such that any memory reserved by the function for its own use is 'freed'.

The exact mechanisms that might be used in a prologue/epilogue are Dependant on the CPU architecture, the platforms standard, the arguments and return values of the function, and the particular calling convention the function might be using.

Michael Burr
Great Thanks dear Burr
Renjith G