Marc Paquette

CodeWarrior 8- & 16-bit tools: Error message in the linker wheb using near

Discussion created by Marc Paquette Employee on Jan 27, 2006
To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.
  Posted: May 31, 2005 - 10:45 AM   
This is my case :
CPU HC08 series AP08,
I wasn't using page 0, (I thought the compiler was assigning the adress so the linker will know which page the RAM is in ), So I put only one RAM variable into PAGE ZERO RAM area. this is what I do :
static UWORD_16 near m_uwTimer = 0;
I use a function to get the value of this variable that is incremented in an interrupt function:
UWORD_16 uwGetTime(void)
UWORD_16 uwTmptimer;
(UWORD_16)uwTmptimer = (UWORD_16)m_uwTimer;
the linker give me this error when linking :
Link Error : L1907: Fixup overflow in uwGetTime, to m_uwTimer type 1, at offset 0x1
When not using near (or when using #pragma DATA_SEG MY_ZEROPAGE ), the code is linking ok, do you know why ? I'm using the small memory model and don't want to used any #pragma
   Posted: Jun 06, 2005 - 08:04 AM   
When building in small memory model, the only solution to tell the compiler to access a variable using direct addressing mode is to define the variable in a SHORT segment.
The variable definition should be made as follows:
static UWORD_16 m_uwTimer = 0;
Defining a variable as near will not allocate the variable in a segment located on the direct page.
Alternatively you can choose to use the tiny memory model if all your variables are allocated on the direct page.
In that case you do not need any pragma to force direct addressing mode.
I hope this helps.