Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems with addressing in Z80 firmware using IAR

Status
Not open for further replies.

wh_hsn

Member level 1
Joined
Oct 31, 2005
Messages
34
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
1,654
iar for z80

Hi All,

Anyone here familiar with IAR C compiler for the Z80?

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

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

I've a problem addressing variables across memory banks.

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 right mod_a_struc in memory.

What am I doing wrong?!!!

Thanks & best regards,

Waleed Hasan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top