11.14.2 Near or Far Code

Functions that are near (within a radius of 32 kWords of each other) may call each other more efficiently than those which are not. If it is known that all functions in an application are near, then the default -msmall-code command line option can be used when compiling each module to direct the compiler to use a more efficient form of the function call.

If this default option is not suitable, then the following alternatives are available:

  1. It is possible to compile some modules of an application using the -msmall-code command line option. In this case, only function calls in those modules will use a more efficient form of the function call.
  2. If the -msmall-code command-line option has been used, then the compiler may be directed to use the long form of the function call for an individual function by tagging it with the far attribute.
  3. Instead of using command-line options, which have module scope, the compiler may be directed to call individual functions using the near (small) or far (large) code models by tagging their declarations with the near or far attribute.
  4. Group locally referent code together by using named sections or keep this code in common translation units.

The linker will produce an error message if the function declared to be near cannot be reached by one of its callers using a more efficient form of the function call.