Reply by CBFalconer February 23, 20052005-02-23
neilwarnock@poboxes.com wrote:
> > No - there is no "code" keyword. I tried that approach already as > I am more familiar with the Keil C51 which does > (const char code * code XXX...) > but as Peter suggested above it should be > const char * const XXX...
What 'above'? You should quote enough of whatever you are replying to so that the context is clear. Don't use the broken google mechanism (see below in my sig). -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson
Reply by February 23, 20052005-02-23
Vadim,

Thanks for the suggestion. I have enough code space at the moment, the
problem was RAM. I'll keep your suggestion in mind for later when code
space does get tight - as it always does ;)

Neil

Reply by February 23, 20052005-02-23
Paul,

No - there is no "code" keyword. I tried that approach already as I am
more familiar with the Keil C51 which does
(const char code * code XXX...)
but as Peter suggested above it should be
const char * const XXX...

Regards,
Neil

Reply by February 23, 20052005-02-23
Peter,

Yes, that's it! Thanks for the reminder!

Neil

Reply by Vadim Borshchev February 23, 20052005-02-23
On 23 Feb 2005 06:56:57 -0800, <neilwarnock@poboxes.com> wrote:

> As I expand the text this will eat away at my RAM so how can I change > it so that it keeps the pointers located in code memory?
You may try something like this: const unsigned char TestResultString[] = { "PASS\0" "FAIL\0" "INCOMPLETE\0\0" }; There is only one array, and hence one pointer, regardless of how many strings you would have. Of course you'd need the code to traverse this array, but it is the usual tradeoff between code size and data size. HTH, Vadim
Reply by Peter Dickerson February 23, 20052005-02-23
<neilwarnock@poboxes.com> wrote in message
news:1109170617.393546.323610@z14g2000cwz.googlegroups.com...
> I am using the IAR C compiler for the Renesas M16C and have in my code > a string array declared as > > const unsigned char * TestResultString[NUM_LANGUAGES][3] = > { > { > "PASS", > "FAIL", > "INCOMPLETE" > }, > }; > (NUM_LANGUAGES is currently 1 but will be increased later) > > When I examine the resultant code it puts the text in code space but > the pointers are copied at runtime from code memory to RAM (into the > FAR_I segment). They are never changed during program operation so this > would seem to be unnecessary as the originals naturally remain where > they were copied from. > > As I expand the text this will eat away at my RAM so how can I change > it so that it keeps the pointers located in code memory?
const unsigned char * const TestResultString[NUM_LANGUAGES][3] = ... your pointers were declared to point to const but not to be const themselves - you need to tell the compiler what you want.
> One way would be to make the array have a fixed size like this > > const unsigned char TestResultString[NUM_LANGUAGES][3][11] = > { > { > "PASS", > "FAIL", > "INCOMPLETE" > }, > }; > > but this is quite wasteful of code memory as some of them have wide > variations in the lengths of their elements. > > I'm sure it is quite simple but I can't figure out what it is.
yes, it is quite simple. yes, you can figure it out. and yes you can stare at this sort of thing for ages while missing the key.
> Thanks for any advice.
Your welcome Peter
Reply by Paul Burke February 23, 20052005-02-23
neilwarnock@poboxes.com wrote:
> I am using the IAR C compiler for the Renesas M16C and have in my code > a string array declared as > > const unsigned char * TestResultString[NUM_LANGUAGES][3] =
Is there a keyword 'code' in the IAR compiler? Paul burke
Reply by February 23, 20052005-02-23
I am using the IAR C compiler for the Renesas M16C and have in my code
a string array declared as

const unsigned char * TestResultString[NUM_LANGUAGES][3] =
{
	{
		"PASS",
		"FAIL",
		"INCOMPLETE"
	},
};
(NUM_LANGUAGES is currently 1 but will be increased later)

When I examine the resultant code it puts the text in code space but
the pointers are copied at runtime from code memory to RAM (into the
FAR_I segment). They are never changed during program operation so this
would seem to be unnecessary as the originals naturally remain where
they were copied from.

As I expand the text this will eat away at my RAM so how can I change
it so that it keeps the pointers located in code memory?

One way would be to make the array have a fixed size like this

const unsigned char TestResultString[NUM_LANGUAGES][3][11] =
{
	{
		"PASS",
		"FAIL",
		"INCOMPLETE"
	},
};

but this is quite wasteful of code memory as some of them have wide
variations in the lengths of their elements.

I'm sure it is quite simple but I can't figure out what it is.

Thanks for any advice.