Trouble overlaying 'global' variables....

Hi,

I'm working on a project that has a branch right at the start of main, so the software is essentially split into two complete sections, neither of which will ever be running at the same time. We've created the right root segments and things for overlay analysis, but there are a bunch of global or module variables that are all exclusive. How can I efficiently overlay them? I get a bit lost with the overlay controls because this is not for variables contained within functions, and they are not code segments, so how can I tell the linker in the right way to overlay them? I'm thinking that the best way to do this is to define two different memory segments for the xdata, and locate them at the same starting address.

eg.

File 1:
just one or two globals variables;

main()
{ if (a == 0) { branchA(); } else { branchB(); }
}

file A1, A2, A3, etc:
Some global variables Ag1, Ag2, Ag3, Agx etc used only by funcs in file Ax
lots of module variables;

branchA(void)
{ Lots of funcs and stuff from files A2, A3 etc
}

file B1, B2, B3, etc:
Some global variables Bg1, Bg2, Bg3, Bgx etc used only by funcs in files Bx
lots of module variables;

branchB(void)
{ Lots of funcs and stuff from files B2, B3 etc
}

How can I make sure that the linker overlays all of the memory usage for variables Agx with the memory for Bgx? I'm thinking that the best way to do this is to define two different memory segments for the xdata, and locate them at the same starting address. Correct?

Many Thanks,

Robbie.

More questions in this forum