Procedure Call Model

   

When a procedure call is made, the following steps must take place.

  1. Save all caller save registers (registers 19 through 26). This means if the information in these registers is to be saved, the calling procedure is responsible for saving it on the stack.

  2. Store arguments to be passed. The arguments that are passed to the called procedure are placed into registers and/or on the stack. The first four arguments, arg0 through arg3, are placed in registers r26 through r23. If the procedure call requires more than four arguments, the remaining arguments are placed on the stack.

  3. Branch to the called procedure. A branch is taken to the called procedure using a B,L or BE,L instruction. The return pointer is placed into GR2 as a result of the branch.

  4. Save the return pointer. The called procedure first saves the return pointer, GR2, onto the stack.

  5. Allocate a stack frame for any calls that will be made. The called procedure next allocates space on the stack by incrementing the stack pointer. This space is used for local storage as well as for any procedure calls that it might be making.

  6. Save any callee save registers that will be used. Any of the callee save registers (GR3 through GR18) that will be altered by the procedure must be saved on the stack.



HP-UX 11i Internals
HP-UX 11i Internals
ISBN: 0130328618
EAN: 2147483647
Year: 2006
Pages: 167

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net