16.6.3 Balancing Code Segments

Although it is a good idea to keep code segments small, compare the costs of a far call between code segments to a near call within a code segment. A far call costs more for Windows applications than it does for MS-DOS applications. Each far call carries the overhead of extra instructions, because Windows has to direct the call to a code segment that may have been moved or discarded.

The task of balancing code segments in an application is a matter of minimizing the frequency of far calls that must be made between segments, while maintaining roughly equal-sized segments whose sizes do not exceed 8K. Functions that frequently call each other should be grouped in the same code segment, subject to the code-size guideline.