Keil Logo

Variable Location

Frequently accessed data objects should be located in the internal data memory of the 8051. Accessing the internal data memory is much more efficient than accessing external data memory. The internal data memory is shared among register banks, the bit data area, the stack, and other user-defined variables with the data memory type.

Because of the limited amount of internal data memory (128 to 256 bytes), all your program variables may not fit into this memory area. In this case, you must locate some variables in other memory areas. There are two ways to do this.

One way is to change the memory model and let the compiler do all the work. This is the simplest method, but it is also the most costly in terms of the amount of generated code and system performance. Refer to Memory Model for more information.

Another way to locate variables in other memory areas is to manually select the variables that can be moved into external data memory and declare them using the xdata memory specifier. Usually, string buffers and other large arrays can be declared with the xdata memory type without a significant degradation in performance or increase in code size.

  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.