Prolog and epilog

On entry to a procedure, you might have to do some or all of the following steps:

  1. Save the link register.
  2. If you use any of the CR bits 8-23 (CR2, CR3, CR4, CR5), save the CR.
  3. Save any nonvolatile FPRs that are used by this procedure in the FPR save area.
  4. Save all nonvolatile VPRs that are used by this procedure in the callers VPR save area.
  5. Save the VRSAVE register
  6. Save all nonvolatile GPRs that are used by this procedure in the GPR save area.
  7. Store back chain and decrement stack pointer by the size of the stack frame. Note that if a stack overflow occurs, it will be known immediately when the store of the back chain is done.

On exit from a procedure, you might have to perform some or all of the following steps:

  1. Restore all GPRs saved.
  2. Restore all VPRs saved
  3. Restore the VRSAVE register
  4. Restore stack pointer to the value it had on entry.
  5. Restore link register if necessary.
  6. Restore bits 8-23 of the CR if necessary.
  7. If you saved any FPRs, restore them.
  8. Return to caller.