Keil™, An ARM® Company

LX51 User's Guide

CLASSES Linker Directive

Abbreviation CL
Arguments CLASSES (class-name (range« , ... ») « , ... »)
CLASSES (class-name ($offset, range))
CLASSES (class-name (range)[])
Default None.
µVision Options — LX51 Locate — User Classes.
Description 

The CLASSES directive allows you to specify an address range (range) for a class (class-name). This directive is used to define the memory layout of your application program or target hardware.

The LX51 Linker uses the following default class settings if no explicit class ranges are specified:

ClassAddress Range
BITI:000020h.0-I:00002Fh.7
CODEC:000000h-C:00FFFFh
CONSTC:000000h-C:00FFFFh
DATAD:000000h-D:00007Fh
ECODEC:000000h-C:FFFFFFh
HCONSTC:000000h-C:FFFFFFh
HDATAX:000000h-X:FFFFFFh
IDATAI:000000h-I:0000FFh
SROMC:000000h-C:00FFFFh
XDATAX:000000h-X:00FFFFh

Note

  • The address ranges used are listed in the linker MAP file in the Memory Classes section. You should check this section of the MAP file to verify that the linker assumptions about the memory in your hardware matches your physical system. Refer to Listing (MAP) File for more information.

Specifying the Memory Range for a Class

The CLASSES directive is typically specified as follows to define an address range for a memory class:

CLASSES (class-name (range« , ... ») « , ... »)

Where

class-nameis the name of the class.
rangeis the address range to assign to the class. All segments within a class are located and must fit within this range.

Note

  • You may specify multiple ranges for a memory class.

Specifying Addresses for OFFS Segments

The CLASSES directive allows you to modify the absolute addresses of segments with the OFFS relocation type. Refer to SEGMENT definitions in the Ax51 Assembler User's Guide for information on how to create these kinds of segments.

This form of the CLASSES directive is specified as follows:

CLASSES (class-name ($offset, range))

Where

class-nameis the name of the class.
offsetis the first address in the range. This will be the address of the segment with an OFFS of 0000h.
rangeis the address range to assign to the OFFS segments.

Typically, only the segments for the reset and interrupt vectors are defined using the OFFS relocation type. This form of the CLASSES directive allows you to quickly relocate these vectors to a new address range. This is useful when you use MON51 or FlashMON51 installed at address 0000h to debug.

Specifying Special ROM (SROM) Classes

You may specify memory classes which execute from one location (usually RAM) but which are stored in a different location (usually ROM). The application program must copy the program code from ROM to RAM before execution.

This form of the CLASSES directive is specified as follows:

CLASSES (class-name (execute-range)[])

Where

class-nameis the name of the class.
execute-rangeis the execution address range for the class.
[]empty brackets specify that the contents of the class are stored in the SROM memory class.

Refer to Special ROM Handling for more information about using the SROM memory class.

See Also SEGMENTS
Example 

The following example defines the memory classes for a classic 8051 device:

LX51 MYFILE.OBJ &
     CLASSES (IDATA (I:0-I:0xFF), XDATA (X:0-X:0xEFFF), &
              CODE  (C:0-C:0x7FFF, C:0xC000-C:0xFFFF))

The following example defines a user-defined memory class XDATA_FLASH:

LX51 MYFILE.OBJ &
     CLASSES (XDATA_FLASH (X:0x8000-X:0xEFFF))

The following example specifies a relocation address and range for segments in the CODE class created with an OFFS relocation type:

LX51 MYFILE.OBJ &
     CLASSES (CODE ($C:0x8000, C:0x8000-C:0xFFFF)

The following example specifies that the RAM_CODE class executes from the address range C:0xE000-C:0xFFFF but is stored in the SROM class:

LX51 MYFILE.OBJ &
     CLASSES (RAM_CODE(C:0xE000-C:0xFFFF)[]