| ||||||||
Technical Support On-Line Manuals C251 User's Guide | Linker Location ControlsAnother method of referencing explicit memory locations is to declare the variables in a stand-alone C module and use the L251 linker location directives to specify at an absolute memory address. In the following example, the alarm_control structure is defined containing the variables to locate.
.
.
.
struct alarm_st {
unsigned int alarm_number;
unsigned char enable flag;
unsigned int time_delay;
unsigned char status;
};
struct alarm_st near alarm_ctrl;
.
.
.
The C251 Compiler generates an object file for the above source (ALMCTRL.C) and includes a segment for variables in the near memory type. Since alarm_ctrl is the only variable declared in this module, it is the only variable in the near segment. The name of the segment is ?ED?ALMCTRL. The L251 linker can locate a segment at any address by using the location control directive SEGMENTS. The L251 SEGMENTS directive must be used as follows: L251 ... almctrl.obj SEGMENTS(?ED?ALMCTRL(0x2000h)) ... This instructs the linker to locate the segment named ?ED?ALMCTRL at address 02000h in the linear 16MB address space. You may also locate segments in the other memory areas like code, xdata, pdata, idata, and data. Refer to the L251 Linker User's Guide for more information. | |||||||
| ||||||||