If data defined in one module is to be used in the other modules of a multiple-module program, the data must be made public and external. MASM provides several methods for doing this.
One method is to declare a symbol public (with the PUBLIC directive) in the module where it is defined. This makes the symbol available to other modules. Then place an EXTERN statement for that symbol in the rest of the modules that use the public symbol. This statement informs the assembler that the symbol is external—defined in another module.
As an alternative, you can use the COMM directive instead of PUBLIC and EXTERN. However, communal variables have some limitations. You cannot depend on their location in memory because they are allocated by the linker, and they cannot be initialized.
These two data-sharing methods are still available, but MASM 6.0 introduces a new directive, EXTERNDEF, that declares a symbol either public or external, as appropriate. EXTERNDEF simplifies the declarations for global (public and external) variables and encourages the use of include files.
The next section provides further details on using include files. Section 8.3, “Using Alternatives to Include Files,” provides more information on PUBLIC and EXTERN.