ID Number: Q66841
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a
MS-DOS | OS/2
Summary:
This article describes the differences in functionality between the
/Aw and /ND switches.
The /Aw switch is used by the compiler to determine if local variables
(typically stack based) can be based on DS, as well as SS. For
example, if a variable needs to be copied from local data to global
data, which would normally include several MOV instructions, if the
compiler can assume DS=SS, it can generate a LEA instruction on the
stack-based variable and set up ES:DI with the destination. DS will
already be set to the correct value. If DS != SS, the compiler will
have to generate more code to correctly access the stack-based
variable.
For the /ND switch, the data segment for the module is not the default
segment. The compiler will do an explicit DS load at function entry
point because of just this fact; that is, there is no way for the
compiler to know that DS is properly set to the nonstandard segment
name (not DGROUP). While this behavior is indeed the same behavior as
the _loadds keyword, it has nothing to do with the main reason for /Aw
(DS!=SS).
To summarize, the /Aw switch doesn't cause the segment load, but it
also doesn't stop it. This is one case where one switch (/ND) can
override one of the effects of another switch (/Aw). However, the main
effect of the /Aw switch is not changed (don't assume DS = SS).