I'm maintaining some old code for the M.Core MMC2114 in CodeWarrior 4.1 / 0622 (yes I have to shovel coal into the laptop to make it run!) and have hit a problem I can't work out the answer to, although I'm sure it's a simple thing.
Basically, within the code are arrays of strings, system messages, which are in several different languages. Currently the code loads one set of strings into a struct in RAM at runtime, something very roughly like:
void load english(){for(number of messages){copy ENGLISH_MESSAGE_NUMBER -> sys_messages[MESSAGE_NUMBER] }
So say we have 200 messages, we store N * 200 text strings (N = number of translations) in FLASH, and then copy one load of them to RAM at runtime.
What I'd like to do is just define all the messages in the code and then point to their location in flash, so they could be addressed something like this:
sprintf(sys_messages[%LANG][MSG_HELLO]) // Prints "hello" in chosen language
So %LANG is a variable that indicates the selected language.
What I'm stumped by is how to define this lot as a pile of static data rather than have to clog up the available RAM with a copy of data which is never going to change?
(I would add that I didn't write the original code, so I don't need to be told it makes no sense!)
I remember M*Core. One of those steam-powered processors.
Check out FAQ-28651 and FAQ-27630. Both deal with storing constants in ROM (flash). The first FAQ is for the HCS12(X) MCU, and the second is for a Power Architecture CPU, but maybe they'll give you some ideas. Sorry I cannot give you something specific on M*Core.
---Tom