Keil Logo

C51: Runtime Determination of Last XDATA Address Used


Information in this article applies to:

  • C51 All Versions

QUESTION

Is there a way to determine, at runtime, the last used location in xdata? I want to use the remaining xdata space (beyond the last xdata variable allocated) as a small heap.

ANSWER

One way to do this is to create a file containing only an xdata variable declaration. For example:

xdata unsigned char last_var_used;

When you create your project, make sure that this is the last file in the project file list. When the project is linked, this file will be linked last AND the last_var_used variable will be located at the end of xdata memory.

You may use the C address-of operator ('&') to get the address of this variable.

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.