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 / CFM-68K Implementation


Direct and Indirect Calls

A direct call does not require switching of the direct data area since it makes use of the calling party's direct data area by default. A direct assembly-language call to the function mooFunc would simply be

BSR.L          _$mooFunc
where _$mooFunc signifies the internal entry point of mooFunc.

IMPORTANT
When discussing routine calls and the direct data area switching method, the external entry point refers to the entry point of the routine when called indirectly through a transition vector. A direct (in-fragment) call enters a routine through the internal entry point.
To allow the switching of the direct data area, the CFM-68K runtime architecture specifies that a procedure pointer points to a transition vector.

All indirect or cross-fragment calls go through a transition vector. The fragment uses the code and data world pair to set up a direct data area associated with the called routine. An indirect call to the function mooFunc would be as follows:

MOVE.L         _@mooFunc,A1; load transition vector into A1
MOVE.L         (A1)+, A0   ; get code address
JSR            (A0)        ; make the call
MOVE.L         "lcl", A5   ; restore A5 from "cl" 
                           ; after the call.
The term "lcl", which can be either a memory-based load variable or a register variable, is the location where the procedure saved its own A5 value prior to the call.

Note
Unlike the PowerPC case, glue code in the called routine is responsible for switching the direct data area in CFM-68K. However, the other actions of the caller's code (loading the transition vector into a register, calling the routine, and restoring the base register after the call) are identical.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997