avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] ATmega2560 and gcc __prologue_saves__


From: Stu Bell
Subject: [avr-gcc-list] ATmega2560 and gcc __prologue_saves__
Date: Mon, 14 Jul 2008 13:21:04 -0600

Hi all,

I've stumbled across another problem with ATmega2560 support.  Although
the problem is triggered from avr-libc, I believe this to be a gcc
problem.

I'm trying to use the rand() function.  The function that calls rand()
is close to the 128K flash boundary in lower flash, and the rand()
function (and practically all of the std library) is placed above the
128K boundary.

The compiler generates a direct CALL to the rand() function.  So far, so
good.  Then, the rand() function calls do_rand(), defined in the
avr-libc rand.c file.  Again, so far, so good.

Then the do_rand() calls __prologue_saves__.  That function saves the
appropriate registers, but then assembles an EIJUMP without setting the
proper value in EIND.  This wouldn't matter on anything *but* an
ATmega2560.  On my code, EIND = 0 (because I've never made an EICALL to
set EIND = 1) so the code jumps into lower flash and I'm dead.

I *assume* (yeah, bad that) that the _prologue.* file is under the
jurisdiction of GCC since I was unable to find it in the avr-libc
source.  But then, I could be smoking something wonderful and
hallucinating badly.

I don't have a test case (yet), but will generate one if/when asked.  I
can also give my current disassembled code of these three areas, if
anyone is interested.

Best regards,

Stu Bell
Senior Software Engineer
DPHI, Inc. (DataPlay)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]