GNU Info

Info Node: (nasm.info)Section 5.6

(nasm.info)Section 5.6


Next: Section 5.7 Prev: Section 5.5 Up: Chapter 5
Enter node , (file) or (file)node

5.6. `COMMON': Defining Common Data Areas
=========================================

   The `COMMON' directive is used to declare _common variables_. A
common variable is much like a global variable declared in the
uninitialised data section, so that

     common  intvar  4

   is similar in function to

     global  intvar
     section .bss
     
     intvar  resd    1

   The difference is that if more than one module defines the same
common variable, then at link time those variables will be _merged_, and
references to `intvar' in all modules will point at the same piece of
memory.

   Like `GLOBAL' and `EXTERN', `COMMON' supports object-format specific
extensions. For example, the `obj' format allows common variables to be
NEAR or FAR, and the `elf' format allows you to specify the alignment
requirements of a common variable:

     common  commvar  4:near  ; works in OBJ
     common  intarray 100:4   ; works in ELF: 4 byte aligned

   Once again, like `EXTERN' and `GLOBAL', the primitive form of
`COMMON' differs from the user-level form only in that it can take only
one argument at a time.


automatically generated by info2www version 1.2.2.9