Table of Contents        Previous topic       Next topic       

ASSEMBLER DIRECTIVES->Other Assembler Directives->COMMON Specify Common Section

The COMMON directive causes the statements following it to be relocatably assembled into the named common section.  This directive remains in effect until another absolute or relocatable section is specified.

Only data and romable data can be common.  As a common section, the data space will be shared by other code using a common section.

The formats for the directive are:
[label]COMMON[.S]<section name>[,[alignment][,type]]
COMMON[.S]<section number>[,[alignment][,type]]
[label]COMMON[.S]<section number>[,[alignment][,type]]

<section name> can be any valid section name.
<section number> consists of up to two decimal characters.

alignment can be either 1, 2 or 4 and causes the data to be aligned on a byte, word or long word boundary.  The default alignment is 2.

type can be

 'D' or 'DATA' to specify data space or
 'R' or 'ROMABLEDATA' to specify romable data space.

The default type is DATA.

If <section name> is used, the optional label takes the value of the program counter in the usual way.

If <section number> is used without a label, the name of the section is the same as <section number>.

If <section number> is used with a label, the name of the section is constructed from the <section number> and the label by appending the label name to <section number>.  For instance if the label is 'cdata' and <section number> is '23', the section name becomes '23cdata'.

The optional .S can be used to force the linker to place the section in data space accessible with 16 bit addressing (ie below address 0FFFFH).

Once a section name has been used for a COMMON directive, it can only be re-used with another COMMON directive.  The attributes (alignment, type, etc.) used must be identical to the first usage.  When the COMMON directive is repeated with the same section name as before in the same module, the program counter is reset to the current value for this named section.  It is therefore possible to alternate between named sections - the assembler will keep track of each of them.