Keil Logo

Linker Location Controls

Another method of referencing explicit memory locations is to declare the variables in a stand-alone C module and use the linker location directives to locate them at an absolute memory address.

In the following example, the alarm_control structure is defined containint 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 far alarm_control;
.
.
.

The C166 Compiler generates an object file for ALMCTRL.C and includes a section for variables in the far memory area. Since alarm_control is the only variable declared in this module, it is the only variable in far section. The name of the section is ?FD0?ALMCTRL. If the NOINIT directive was used the section is named ?FD?ALMCTRL.

The L166 Linker can locate a section at any address. The following example shows how to locate the ?FD0?ALMCTRL section starting at address 128000h.

L166 ... almctrl.obj SECTIONS(?FD0?ALMCTRL%FDATA0(128000h)) ...

The SECTIONS linker directive instructs the linker to locate the section named ?FD0?ALMCTRL in the FDATA0 class at address 128000h. Refer to the L166 Linker User's Guide for more information.

Related Knowledgebase Articles

  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.