LX51 User's Guide

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 LX51 Linker/Locator directives that affect data overlaying.

DirectiveDescription
NOOVERLAYDisables data segment overlaying.
OVERLAYModifies the call tree for overlaying of local bit and data segments.

Note

  • The Keil Cx51 Compiler supports reentrant functions where the parameters and automatic variables are stored on a simulated stack.