COMM             Define communal variable                           Directive

COMM definition [,definition]...

Defines a communal variable. Each definition describes a symbol and
has the following format:

[distance] [language] symbolname [[count1]] :complex_type [:count2]

- distance can be either NEAR or FAR and defaults to the size of the
default data memory model
- language is either C, CPP, PASCAL, BASIC, FORTRAN, PROLOG, or
NOLANGUAGE and defines any language-specific conventions to be
applied to symbolname; temporarily overrides language set with a
MODEL statement
- symbolname is the communal symbol (or symbols, separated by commas)
- if distance is NEAR, the linker uses count1 to calculate the total
size of the array; if distance is FAR, the linker uses count2 to
indicate how many elements there are of size count1 times the basic
element size (determined by type)
- complex_type is the data type of the argument; it can be either a
simple type or a complex pointer expression
- count2 specifies how many items this communal symbol defines
- both count1 and count2 default to 1


Communal variables function like external variables, with a major
difference: COMMs are allocated by the linker. Communal variables are
like global variables, but you can't assign them initial values. Use
the GLOBAL directive if you wish to initialize data items that are to
be shared between modules. The linker also doesn't guarantee the
allocation of communal variables in any particular order, so you can't
make assumptions about data items allocated by COMM directives on
sequential source lines.

In MASM mode, communal symbols declared outside of any segment are
presumed to be reachable via the DS register, which may not always be
a valid assumption. Make sure that you either place the correct
segment value in DS or use an explicit segment override when referring
to these variables. In Ideal mode, Turbo Assembler correctly checks
for whether the communal variable is addressable, using any of the
current segment registers as described with the ASSUME directive.


Examples:

COMM buffer:BYTE:512 ; 512 bytes allocated at link time
COMM FAR abc[41]:BYTE:10 ; 410 bytes (10 elements of 41 bytes)
; allocated at link time