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

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

Re: AW: [avr-gcc-list] avr-gcc bug: global register variable is broken


From: Klaus Rudolph
Subject: Re: AW: [avr-gcc-list] avr-gcc bug: global register variable is broken
Date: Wed, 01 Dec 2004 17:29:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6) Gecko/20040114

Hi Bjoern,

as you told me the usage of lower registers seems to work. But that is only a workaround and not the expected behaviour. With register r10 for example the compile is totally corrupt. The register r10 is used in a function but not filled in by the caller! This seems to be also a bug. And if lower registers work, why isn´t there any error message or warning? Because of undefined behaviour we must fix this bug. Also the libc doc says nothing against the use of global register vars.
And in addition: I need more then one register above r16 if possible:-)
I have no idea how the internal machine description works, but I think there is something wrong in avr specific implementation.


I tested with this simple example:
------------------
register unsigned char myGlobalVar asm("r9");

volatile long y;

void f1(long a, long b, long c, long d, long e, long f, int g, char h) {
   y=a+b+c+d+e+f+g;
}


void callIt() {
   f1( y,y,y,y,y,y,y,y);
}

int main() {
   callIt();
   return 0;
}
-----------------

Regards
   Klaus




Haase Bjoern (PT-BEU/MKP5) * schrieb:

Hi,

I have never tried it, but as much as I know, it should be possible to declare one of the lower 
registers for "fixed" purposes. I recommend you to try r2 and/or r3. The compiler will 
certainly not be able to work properly if you declare one of the registers usually being used for 
passing parameters to functions or one of the pointer registers to be "fixed". E.g. the Y 
register is required for the frame pointer.

Yours,

Björn Haase

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Auftrag von Klaus Rudolph
Gesendet: Mittwoch, 1. Dezember 2004 15:49
An: address@hidden
Betreff: [avr-gcc-list] avr-gcc bug: global register variable is broken


Hi all,

it is impossible to define a global register variable in avr-gcc.
The register is used by the compiler on some places and it is really not
preserved.


The actual gnu documentation says:
"Defining a global register variable in a certain register reserves that
register entirely for this use, at least within the current compilation. The
register will not be allocated for any other purpose in the functions in the
current compilation. The register will not be saved and restored by these
functions. Stores into this register are never deleted even if they would
appear to be dead, but references may be deleted or moved or simplified."

I know that it is not ok to call to LIBRARY functions, but it is allowed to
use
all functions which are compiled with the knowledge of the reserved
register.
As a hint the documentation says that it is allowed to recompile all used
library functions with -ffixed-reg option to preserve the register for
use.
The bug is:
It is not possible to define a global register variable because it is used
from
ompiler.
It is impossible to preserve the register with -ffixed-reg option.

Any idea for a workaround? I need some register vars for interrupt handler
:-(

Is there allready a patch available or is this maybe fixed in current CVS
head of release 4.0 in gcc sources?

Thanks
   Klaus









reply via email to

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