Locating C Variables in Memory

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> Silicon_Labs on ‎02-17-2004 06:21 PM - edited on ‎09-29-2017 03:06 AM by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> PhillipB
Question

 


How do you locate variables in a specific memory segment or at a certain memory address using the Keil 'C' compiler?




Answer

 


The Keil C compiler uses the C extensions data, idata, bdata, xdata, pdata, and code to define the 8051 memory segment and addressing mode for a particular variable.   As described in Chapter 6, Section 'Accessing Absolute Memory Locations' of the Keil Cx51 Compiler User's Guide:

 

The C programming language does not provide a method of explicitly specifying the memory location of a static or global variable. You must do that manually using one of the following three methods:

 

For more information on using the _at_ keyword, refer to the "Absolute Variable Location" in the Keil User's Guide.