Banked memory quesion (Z80 using IAR)

Hi All,

I've just inherited a project that was written for a Z80 platform usin IAR 2.01G compiler.

It?s using banked memory to cross the 64k boundary.

I've a problem addressing variables across pages.

Consider the following example:

///////////// file: moduleA.c //////////////////////////////// //Module A:

#pragma memory=dataseg(MOD_A_DATA) MOD_A_STRUC mod_a_struc;

#pragma memory=constseg(MOD_A_CONST) const char teststr[]="test string"; #pragma memory=default

#pragma codeseg(MOD_A_CODE) Void MOD_A_SET(MOD_A_STRUC * m, int x, int y) { m->member1 = x; m->member2 = y; }

int MOD_A_GET1(MOD_A_STRUC * m, int x, int y) { return m->member1; }

int MOD_A_GET2(MOD_A_STRUC * m, int x, int y) { return m->member2; } /////////////// end module A ////////////////////////////////

Now the main module:

///////////// file: main.c //////////////////////////////// //Module main:

#pragma memory=dataseg(MOD_A_DATA) extern MOD_A_STRUC mod_a_struc;

#pragma memory=constseg(MOD_A_CONST) extern const char teststr[]; #pragma memory=default void main(void) { int I, j; MOD_A_SET(mod_a_struc, 0x12, 0x34); i = MOD_A_GET1(mod_a_struc); j = MOD_A_GET2(mod_a_struc);

printf("%s : %i %i\n\r", teststr, i, j ); }

///////////// end module main ////////////////////////////////

The calls to the set & get function don't seem to address the righ mod_a_struc in memory.

What am I doing wrong?!!!

Thanks & best regards,

Waleed Hasan

Reply to
wh_hsn
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.