__loadds

The __loadds keyword causes the compiler to generate a function-entry sequence to load the data-segment (DS) register with the segment value of the most recently specified data segment. The compiler also generates code to restore the previous DS value when the function terminates.

Loading the DS register is essential for Windows call-back functions and Windows DLL entry points. Because there is no requirement for Windows or clients of a DLL to “know” about the entry function's use of memory, these functions cannot depend on DS pointing to their data segment at entry unless they are declared as __loadds or compiled with the /Au compilation option.

Note:

The __loadds keyword does not imply any change in calling convention; it can be specified with any calling-convention modifier that is compatible with 16-bit compilations.

When loading the DS register, the compiler uses the segment specified by the /ND (name-data-segment) option, or, if no segment has been specified, the default group DGROUP. Note that this function modifier has the same effect as the /Au option, but on a function-by-function basis.

32-Bit Specific

The __loadds keyword is not supported in 32-bit compilations.¨