nick stein

Need to word align tables in code space

Discussion created by nick stein on Jan 4, 2008
Latest reply on Jan 4, 2008 by Jim Donelson
system: Codewarrior 4.6
processor: 9s12c32
This will actually be a two part question.  First, what is the correct way to define a table in code.  I have it defined as:
          const unsigned int Table1[8] = {0,1,2,3,4,5,6,7};
The compiler will place it in flash or ROM depending upon how I use the table in the program.
For example:
    void SomeFunction()
       unsigned int i;
Places the table at address 0 in RAM but, ....
   void SomeFunction()
       const unsigned int * i;
Places the table at address 0xC043.  Is there a better way to define the table such that it will always wind up in code space?  I tried using #pragma CODE_SEG but the compiler just ignored it.  Any help is appreciated.
Second question:  What compiler directive or technique can be used to word align the table?
The align directive (#pragma align 2) doesn't work.   Doing a test compile then poking a byte in if needed is not an option.   Fixing the table at a defined address is not an option either, although I would like to know how to do that.  Basically the table should be relocatable, always the same size and always begin on an even word.  Thanks, hope you can help.