Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - the "zm" option instructs the code generator to place each function into a http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
The "zm" option instructs the code generator to place each function into a
separate segment.
In small code models, the segment name is "_TEXT" by default.

(C only) In large code models, the segment name is composed of the function
name concatenated with the string "_TEXT".

(C++ only) In large code models, the segment name is composed of the module
name concatenated with the string "_TEXT" and a unique integral number.

The default string "_TEXT" can be altered using the "nt" option (see
nt=<name>).

The advantages to this option are:

 1. Since each function is placed in its own segment, functions that are not
    required by an application are omitted from the executable by the linker
    (when "OPTION ELIMINATE" is specified).

 2. This can result in smaller executables.

 3. This benefit applies to both small and large code models.

 4. This option allows you to create granular libraries without resorting to
    placing each function in a separate file.

Example:

     static int foo( int x )
     {
         return x - 1;
     }


     static int near foo1( int x )
     {
         return x + 1;
     }


     int foo2( int y )
     {
         return foo(y) * foo1(y-1);
     }


     int foo3( int x, int y )
     {
         return x + y * x;
     }

The disadvantages to this option are:

 1. The "near call" optimization for static functions in large code models
    is disabled (e.g., the function foo in the example above will never be
    "near called".  Static functions will always be "far called" in large
    code models.

 2. Near static functions will still be "near called" (e.g., the function
    foo1 is "near called" in the example above).  However, this can lead to
    problems at link time if the caller function ends up in a different
    segment from the called function (the linker will issue a message if
    this is the case).

 3. The "common epilogue" optimization is lost.

 4. The linker "OPTION ELIMINATE" must be specified when linking an
    application to take advantage of the granularity inherent in object
    files/libraries compiled with this option.

This option can be used in paging environments where special segment
ordering may be employed.  The "alloc_text" pragma is often used in
conjunction with this option to place functions into specific segments.

The macro __SW_ZM will be predefined if "zm" is selected.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson