Keil™, An ARM® Company

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 has several different forms which allow you to specify:

  • The absolute memory location for a segment,
  • The order of segments in memory,
  • Special ROM (SROM) segments which execute from one address but are stored at a different address.

Note

  • The LX51 Linker allows you to use wildcards when locating program segments. For example, ?PR?*?MYFILE may be used to represent all program segments from the MYFILE source file.

Specifying the Memory Location for a Segment

Use the following form of the SEGMENTS directive to specify the location of segments in memory.

SEGMENTS (segment-name « (address) » « , ... »)

Where

segment-nameis the name of the segment.
addressis the beginning address of the segment. If the address begins with a carat character ('^') then the address represents the ending address of the segment.

Note

  • The SEGMENTS directive specifies the absolute location of a segment.
  • The specified address may be the starting address or the ending address of the segment.

Specifying the Order of Segments in Memory

Use the following form of the SEGMENTS directive to specify the order of segments in memory.

SEGMENTS (segment-name « (address) » « , ... »)

SEGMENTS (segment-name « (LAST) » « , ... »)

Where

segment-nameis the name of the segment.
addressis the beginning address of the segment. If the address begins with a carat character ('^') then the address represents the ending address of the segment.
LASTspecifies that the segment is to be the last segment.

Note

  • Segments may be ordered as the first or last segments in a memory class.
  • Segments are stored in memory in the order in which they are specified.
  • The first segment specified is located at the lowest possible address in its memory class.

Specifying Special ROM (SROM) Segments

Use the following form of the SEGMENTS directive to specify the Special ROM (SROM) segments.

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.

Refer to Special ROM Handling for more information about using SROM segments.

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)[!])