16.8 Calling Functions

By default, functions are called using the direct form of the call (bl) instruction. This operation can be changed through the use of attributes applied to functions or command-line options so that a longer, but unrestricted, call is made. Long calls are typically used when calling between memory regions, such as calling a function located in RAM from a function located in Flash and vice versa.

The -mlong-calls option, see 5.7.1 Options Specific to PIC32C/SAM Devices, forces a register form of the call to be employed by default. Generated code is longer, but calls are not limited in terms of the destination address.

The long_call attribute can be used with a function definition to always enforce the longer call sequence for that particular function. The short_call attribute can be used with a function so that calls to it use the shorter direct call, even if the -mlong-calls option is in force.