16.8 Calling Functions

By default, functions are called using the direct form of the call (jal) instruction. This allows calls to destinations within a 256 MB segment. 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.

The -mlong-calls option, see 5.7.1 Options Specific to PIC32M 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 attributes longcall or far can be used with a function definition to always enforce the longer call sequence for that function. The near 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.