Function Structure and Calling Conventions

The C/C++ compiler imposes a strict set of rules on function calls. Except for special run-time support functions, any function that calls or is called by a C/C++ function must follow these rules. Failure to adhere to these rules can disrupt the C/C++ environment and cause a program to fail.

The following sections use this terminology to describe the function-calling conventions of the C/C++ compiler:

Figure 6-1 illustrates a typical function call. In this example, arguments are passed to the function, and the function uses local variables and calls another function. Registers F14-R29 are used to pass arguments 1 through 16. If there are additional arguments, the stack is used. This example also shows allocation of a local frame and argument block for the called function. Functions that have no local variables and do not require an argument block do not allocate a local frame.

Figure 6-1 Use of the Stack During a Function Callstack_func_pru2.png