Crossware

Table of Contents        Previous topic       Next topic       

ASSEMBLER DIRECTIVES->Other Assembler Directives->SECTION

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>[,type][,relocation type][,bank number]
SECTION[.S]<section number>[,type][,relocation type] [,bank number]
SECT can be used instead of SECTION.

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

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 opcode or directive encountered is RMB 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 8 bit addressing (ie below address 0FFH).

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 section should be relocated to an address higher than all other sections in the same address space except section s with the relocation type HIGH.  This type is only valid in data sections.  Typically this should be used for the heap section which grows upwards during run time.
'H' or 'HIGH'This specifies that the section should be relocated as high as possible in the available address space.  This type is only valid in data sections. Typically this should be used for the stack section which grows downwards during run time.
'I' or 'INPAGE'This specifies that the section should be relocated into a single page of memory. Sections must have this relocation type if they are to be addressed using the direct addressing mode.  See section for an example of the use of this relocation type.
BANKThis specifies that the section should be located in a separate bank. BANK must be followed the bank number as discussed in Using the Section Directive.  This type is only valid for CODE and DATA segments.  
<Bank number> is only valid when the relocation type is BANK.

<bank number> is a numerical value between 0 and 255.  This must correspond to the bank number used with a /ROM or /RAM linker option.