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 11 - Classic 68K Runtime Conventions / Classic 68K Stack Structure and Calling Conventions


Pascal Calling Conventions

When following Pascal calling conventions, the caller passes space for the return value before pushing any parameters. The caller then passes parameters from left to right. For example, given the code

cow = PasFunc(moo1, moo2, moo3);
the calling routine first pushes the value of moo1 onto the stack, followed by moo2 and then moo3 as shown in Figure 11-2.

Figure 11-2 Passing parameters onto the stack in Pascal

Pascal allows only a fixed number of parameters to be passed to the called routine. However, this means the size of the stack frame can be determined at compile time, so the called routine assumes responsibility for deallocating (popping) parameters before returning.

Function values are returned on the stack, as follows:

The calling routine must allocate space on the stack for the return value before pushing any parameters, and the same routine is responsible for popping the result after the call.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997