LX51 User's Guide

Segment Information

The linker creates special symbols (using no program or data space) that contain address and length information for segments used in an application.

Symbol NameDescription
_PR_segment-name_S_The starting address of the segment.
_PR_segment-name_B_The code bank in which the segment is stored.
_PR_segment-name_L_The length of the segment in bytes.
_PR_segment-name_E_The ending address of the segment.
_PR_segment-name_T_The execution/target address of the segment.

You may create declarations from external variables to access this information. For example, use the following to get information about the length of the main function in the measure module:

extern unsigned char _PR_main_measure_L_;

unsigned main_length = (unsigned int) & _PR_main_measure_L_;

The SROM.H header file contains macro definitions that simplify access to segment information:

#include <srom.h>

SROM_PS(main_measure) // Create external declarations for main_measure

unsigned measure_size   = SROM_PS_LEN(main_measure);
unsigned measure_start  = SROM_PS_SRC(main_measure);
unsigned measure_end    = SROM_PS_END(main_measure);
unsigned measure_target = SROM_PS_TRG(main_measure);