Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /
Chapter 2 - Indirect Addressing in the CFM-Based Architecture / PowerPC Implementation


Glue Code for Pointer-Based Calls

Pointer-based function calls must make use of the transition vector since the eventual call may be cross-fragment. (A routine pointer does not point to the code, but to the transition vector of the called routine.)

The glue code for a pointer-based call, as shown in Listing 2-2, is very similar to that for the named indirect call.

Listing 2-2 Glue code for a pointer-based call

   lwzR12, address_of_TVector
   bl    ptr_glue
   lwz   R2, R2_save_offs(SP); restore the caller's base pointer

   ...

ptr_glue:
   lwz   R0, 0(R12)        ; get the entry point
   stw   R2, R2_save_offs(SP); save the caller's base pointer
   mtctr R0                ; move entry point to Count Register
   lwz   R2, 4(R12)        ; load the new base pointer
   bctr                    ; jump through the Count Register

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997