Both the #pragma and the __far qualifiers are needed as they serve a different purpose.
The "#prgama DATA_SEG __RPAGE_SEG XYZ" places the variable in the corresponding section and it also tells the compiler to access the variable with rpage access.
The __far pointer qualifier (should be after the * for every pointer) tells the compiler that this is a pointer capable of accessing __far objects.
With the assumption that StructB is allocated correspondingly in a #pragma with a __RPAGE_SEG or __GPAGE_SEG qualifier, I would write it like this.
StructA should be just the same.
Code:
void foo(unsigned char indexA, unsigned char indexB) unsigned char * __far pointerStructA = (unsigned char* __far) 0xf8000; unsigned char *__far pointerStructB; unsigned char data = 0; pointerStructB = (unsigned char*__far)&StructB; data = pointerStructB[indexB]; pointerStructA[indexA] = data;}
Of course it's a lot simpler to write StructA.fielda= StructB.fieldb, if the pragmas are correct, that should work fine too. If it does not for you, please show a complete sample. Also consider using two arrays, if that is the normal way accessing your data. Then ArrayA[indexA]= ArrayB[indexB] should work just fine.
Note that in your sample, you did not use a __far pointer for the pointerStructB, I wonder why that actually worked.
Also things I would really suggest to look into are the following two technical notes:
TN 238- HCS12X - Data Definition
TN 240- HCS12X - Accessing Data
TN's can be downloaded separately, they are not in the default installation, as far as I know.
Daniel