LX51 User's Guide

SEGMENTS Linker Directive

Abbreviation

SE

Arguments

SEGMENTS (segment-name 〚(address)〛 〚, ...〛)
SEGMENTS (segment-name 〚(LAST)〛 〚, ...〛)
SEGMENTS (segment-name (execute) [〚!〛〚storage〛] 〚, ...〛)

Default

None.

µVision

Options — LX51 Locate — User Segments.

Description

The SEGMENTS directive allows the user to specify:

  • The absolute memory location for a segment.
  • The segment order in memory.
  • Special ROM (SROM) Handling allows SEGMENT content to execute and store at different addresses.

Note

  • The LX51 Linker allows you to use wildcards for segment names.

Specifying the Memory Location for a Segment

The following SEGMENTS directive specifies the absolute segment location in memory:

SEGMENTS (segment-name 〚(address)〛 〚, ...〛)

Where

segment-nameis the name of the segment.
addressis the beginning or ending address of the segment. If the address begins with a carat character ('^'), then the address represents the ending address of the segment. Subsequent segments will not be allocated below that address.

Specifying the Order of Segments in Memory

The following SEGMENTS directive specifies the order of segments in memory:

SEGMENTS (segment-name1 (address1) [, segment-nameX 〚, ...〛])

Where

segment-name1is the name of the starting segment. This segment is located at the lowest possible address in its memory class.
segment-nameXare the names of subsequent segments. These segments are located in the order of their definition.
address1is the address of segment-name1. Subsequent segments will not be allocated below that address.

Using the LAST Parameter

The SEGMENTS directive below locates the segment as the last segment in its memory class. These segments are located after all the other segments have been located.

SEGMENTS (segment-name 〚(LAST)〛 〚, ...〛)

Where

segment-nameis the name of the segment.
LASTspecifies that this segment is the last segment.

Note

  • An explicit address specification with previous segment names serves as base address for following segments. When the LAST segment should be placed before this base address, specify it before in the SEGMENTS directive.

Specifying Special ROM (SROM) Segments

Use the following form of the SEGMENTS directive specifies Special ROM Handling to define different storage and execution addresses.

SEGMENTS (segment-name (execute) [〚!〛〚storage〛] 〚, ...〛)

Where

segment-nameis the name of the segment.
executeis the execution address of the segment. The segment must be copied from the storage address to the execution address by the application program before it can be executed.
!specifies that the linker should not reserve memory at the execute address for the segment. This is useful when you have several SROM segments that execute from the same memory space.
storageis the storage address of the segment. If the storage address is not specified, the segment is stored in the SROM memory class.
See Also

CLASSES

Example

The following example places the ?DT?A and ?DT?B segments at 28h and 30h in DATA memory:

LX51 A.OBJ,B.OBJ SEGMENTS (?DT?A(D:0x28),?DT?B(D:0x30))

The following example specifies the order for the ?DT?A, ?DT?B, and ?DT?C segments. These segments start at the beginning of the memory class (the DATA class in this example). All other segments in the DATA class are located AFTER these segments.

LX51 A.OBJ,B.OBJ,C.OBJ SEGMENTS(?DT?A,?DT?B,?DT?C)

The following example places the ?PR?FUNC2?B segment in code bank 0 and the ?PR?FUNC2?A segment in code bank 1 at address 8000h.

LX51 BANK0 {A.OBJ}, BANK1 {B.OBJ} &
     SEGMENTS(?PR?FUNC2?B (B0:), ?PR?FUNC1?A (B1:0x8000))

The following example locates the ?DT?B segment as the last segment in the DATA class.

LX51 A.OBJ,B.OBJ,C.OBJ SEGMENTS(?DT?B(LAST))

The following example locates the ?PR?SUM?B segment so that it ends at address 0FF7FFFFh in the CODE class.

LX51 A.OBJ,B.OBJ SEGMENTS(?PR?SUM?B(^0xFF7FFFF))

The following example assigns the ?PR?FUNC1?A segment an execution address of 4000h and a storage address of 0FF8000h. Memory is reserved at 4000h for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x4000)[0xFF8000])

The following example assigns the ?PR?FUNC1?A segment an execution address of 4000h and a storage address of 0FF8000h. Memory is reserved at 4000h for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x4000)[0xFF8000])

The following example assigns the ?PR?FUNC1?A segment an execution address of 2000h. The segment is stored in the SROM memory class. Memory is not reserved for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x2000)[!])