Hello everyone,
I am programming a MC9S12A256 microcontroller with CodeWarrior 5.9.0.
I have an array of "const char *far*far const" pointers to various "const char *far const" pointer arrays holding strings.
Example is as follows:
const char *far*far const TextPtrs[]{ farPtr1, farPtr2 }; const char *far const farPtr1[]{ "First pointer's first string", "First pointer's second string" }; const char *far const farPtr2[]{ "Second pointer's first string", "Second pointer's second string" };
Around these const array declarations, I have #pragma CONST_SEG and #pragma STRING_SEG to specific pages (i.e. 0x3C8000-0x3CBFFF). The CONST_SEG and STRING_SEG pages are different, and the strings will span over multiple pages before my project is complete.
So in my program, I have a function which I enter in the indices for each array, and this function should place the string in a buffer for a text display.
For arbitrary values, let's say TextPtrs address is 3C8000, farPtr1 is 3C8006, and the string in farPtr1[0]'s address is 358000.
In a local, temporary *far*far pointer (char *far*far temp2far), I place TextPtrs, then increment to the proper index. This effectively works. (temp2far = (char *far*far)TextPtrs; temp2far += index1;)
Then, I take a temporary *far pointer (char *far temp1far), and make it equal to the dereferenced value of the above local pointer (i.e. temp1far = *temp2far;). THIS is where I am having my problems. Instead of the proper value I can see in the MAP file, I get some random number, i.e. expecting 3C8006, and getting 30813b. Generally, I believe, the value I get is within my code's default pages.
I've tested putting this code into the same page as the constants (#pragma CODE_SEG). The dereferencing of the pointers to other pointers works well then, but dereferencing to the strings, which are on different pages, again, fails in a similar manner (although the random value is generally starting with 3C, pushing my suspicion that it's dereferencing to a value within the same page as the code itself).
I have datapage.c linked, and in the link order it is before most of the code written by myself and also before ansib.lib.
A few of my compiler variables are as follows: -CpPPAGE=RUNTIME -Cq -DHCS12 -Mb -Onf
So finally, my question.... what am I missing?