18.2 DLL Programming Requirements

Four programming requirements arise from the nature of DLLs. These requirements apply to all code used in a dynamic-link call—both in an exported procedure and in any procedure it may call:

You cannot assume that the SS and DS registers hold the same value, unless you explicitly set SS equal to DS.

You should avoid using the math coprocessor or emulator routines unless you are certain a coprocessor or emulator library is available.

The DLL should be “re-entrant,” because there is no guarantee that only one program will use the DLL. A re-entrant procedure is one that can be called by different programs concurrently. This creates problems for static data in the DLL, unless you declare data to be NONSHARED in the module-definitions file.

Be careful how you place data and code in segments. The location of data and code in different segments and the contents of the module-definition file also determine the content of the executable file.

This section discusses these requirements.