When a function or subroutine is called, its address must be loaded into the PC so that it can be executed and, when it terminates, execution of the calling routine must continue. In addition, there must be a convention that defines the following:
How parameters are passed to the function
How parameters are returned
Which (if any) registers can be modified by the function
The ARM Architecture Procedure Call Standard deals with these issues (refer to Procedure Call Standard for the ARM Architecture, http://infocenter.arm.com/).
In this section, we will learn more about the ARM Architecture Procedure Call Standard (AAPCS) by writing an assembly language subroutine that receives a parameter from the C function that calls it. Moreover, in this example, the assembly language subroutine itself calls another C function. Functions or subroutines that call other functions or subroutines are called nested functions/subroutines.