Keil Logo

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:

Class Address Range
BIT I:000020h.0-I:00002Fh.7
CODE C:000000h-C:00FFFFh
CONST C:000000h-C:00FFFFh
DATA D:000000h-D:00007Fh
ECODE C:000000h-C:FFFFFFh
HCONST C:000000h-C:FFFFFFh
HDATA X:000000h-X:FFFFFFh
IDATA I:000000h-I:0000FFh
SROM C:000000h-C:00FFFFh
XDATA X: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-name is the name of the class.
range is 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-name is the name of the class.
offset is the first address in the range. This will be the address of the segment with an OFFS of 0000h.
range is the address range to assign to the OFFS segments.

Note

  • An offset address can only be specified for the memory class CODE.
  • 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-name is the name of the class.
execute-range is 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)[]
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.