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



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.


  • 8-bit MCUs
  • Knowledge Base Articles