ARM Technical Support Knowledge Articles

STRING TABLE IN XDATA

Applies to: C51 C Compiler

Answer

QUESTION

How do I locate an initialized array in XDATA memory. I am declaring an array thus:

char * lcd_message = { "message 1", "message 2", ... "last message" };

and need to get the messages and pointers into XDATA as they may be changed during runtime.

ANSWER

The best way to do this is to declare the messages separately from the array. For example:

#include <stdio.h>

char xdata m1 [] = "Message One";
char xdata m2 [] = "Message Two";
char xdata m3 [] = "Message Three";

xdata char xdata *message_table [] =
  {
  m1,
  m2,
  m3,
  NULL,
  };

char xdata NULL_PLACE_HOLDER _at_ 0;

This is the only way to force the constant strings into XDATA instead of CONSTANT (code) memory.

Note that the NULL_PLACE_HOLDER is declared to reside at 0 in XDATA. That is probably useful if you will test for NULL pointers.

Article last edited on: 2000-06-26 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential