Keil Logo

Overlaying Data Memory

Data and bit segments marked as OVERLAYABLE may overlap the same physical memory space. By default, the Keil Cx51 Compiler and the Intel PL/M-51 Compiler store program arguments and local variables in fixed, overlayable memory rather than on the hardware stack. There are two reasons for this:

  1. The 8051 hardware stack resides in on-chip DATA memory which is limited to a maximum of 256 bytes.
  2. Stack-based addressing on the 8051 is slow and inefficient.

There are several benefits to overlaying data space rather than using the stack:

  • The linker can maximize the available space by overlaying memory.
  • Direct access to memory is much faster on the 8051 than indirect access.

To accomplish overlaying, the linker analyzes all references (calls) between the various functions in the program. Using this information the linker determines precisely which data and bit segments may be overlaid.

The following table describes all BL51 Linker/Locator directives that affect data overlaying.

Directive Description
NOOVERLAY Disables data segment overlaying.
OVERLAY Modifies the call tree for overlaying of local bit and data segments.


  • The Keil Cx51 Compiler supports reentrant functions where the parameters and automatic variables are stored on a simulated stack.
  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.