- Inside Macintosh: Mac OS Runtime Architectures /
- Chapter 5 - CFM-68K Runtime Conventions / Routine Calling Conventions
Function Value Return
In the CFM-68K runtime environment, the placement of the return value depends on its size:
- Functions returning
UInt8, SInt8, or Boolean data types place the return value in the least significant byte of D0. The three most significant bytes in D0 are undefined.
- Functions returning
UInt16 or SInt16 data types place the return value in the two least significant bytes of D0. The two most significant bytes in D0 are undefined.
- Functions returning pointers (including array pointers),
UInt32, SInt32, or float data types place the return value in D0.
- Functions returning small data structures or
union data types place them in the least significant bytes of D0. For example, a 4-byte structure takes up D0, while a 2-byte structure occupies the two least significant bytes of D0, with the extra bytes being undefined.
- If the function return value is larger than 4 bytes (this applies to
double and extended data types, as well as to large struct or union data types), a pointer must be pushed onto the stack at call time after all the user-visible arguments have been pushed. The address of the pointer must be a memory location large enough to hold the function return value. When the function exits, it returns this address in the D0 register.
© Apple Computer, Inc.
11 MARCH 1997