The second method of referencing explicit memory location is to declare the variables in a stand-alone C module and use the location control directives of the L51 Linker/Locator to specify an absolute memory address.
.
.
.
struct alarm_st
{
unsigned int alarm_number;
unsigned char enable flag;
unsigned int time_delay;
unsigned char status;
unsigned int high_level;
unsigned int low_level;
};
xdata struct alarm_st alarm_control;
.
.
.
The C51 compiler generates an object file for ALMCTRL.C and includes a segment for variables in the xdata memory area. Because it is the only variable declared in this module, alarm_control will be the only variable in that segment. The name of the segment will be ?XD?ALMCTRL.
XDATA(?XD?ALMCTRL(2000h))
This instructs the linker to locate the segment named ?XD?ALMCTRL at address 2000h in the xdata memory area.
There are linker directives for locating segments in the code, xdata, pdata, idata, and data memory areas. Refer to the L51 Linker/Locator for more information.