Table of Contents        Previous topic       Next topic       

ASSEMBLER DIRECTIVES->Other Assembler Directives->SECTION Define Relocatable Section (or Segment)

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

In this manual we refer to segments as well as sections.  We mean exactly the same thing by both terms.

The formats for the directive are:

[label]SECTION[.S]<section name>[,[alignment][,type][,relocation type]]
SECTION[.S]<section number>[,[alignment][,type][,relocation type]]

SECT can be used instead of SECTION.

<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:

 'C' of 'CODE' to specify code space
 'D' or 'DATA' to specify data space
 'M' or 'MIXED' to specify mixed code and data
 'R' or 'ROMABLEDATA' to specify romable data space

The default type is CODE unless the first directive encountered us DS and then the default type is DATA.

The optional label takes the value of the program counter in the usual way.

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 SECTION directive, it can only be re-used with another SECTION directive.  The attributes (alignment, type, etc.) used must be identical to the first usage.  When the SECTION 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.

<relocation type> is one of the following:

'P' or 'POSTPONE'This specifies that the segment should be relocated to an address higher than all other segments in the same address space except segments with the relocation type HIGH.  This type is only valid in data segments.  Typically this should be used for the heap segment which grows upwards during run time.
'H' or 'HIGH'This specifies that the segment should be relocated as high as possible in the available address space.  This type is only valid in data segments.  Typically this should be used for the stack segment which grows downwards during run time.