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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,896 Views
marc_paquette
Contributor V
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;
Cpu_DisableInt();
(UWORD_16)uwTmptimer = (UWORD_16)m_uwTimer;
Cpu_EnableInt();
return(uwTmptimer);
}
 
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
 
thank's
 
   Posted: Jun 06, 2005 - 08:04 AM   
 
Hello
 
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:
 
#pragma DATA_SEG SHORT MY_ZEROPAGE
static UWORD_16 m_uwTimer = 0;
#pragma DATA_SEG DEFAULT
 
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.
mw_cbezy
Labels (1)
Tags (1)
0 Kudos
0 Replies