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 isbroken


From: Bernard Fouché
Subject: RE: AW: [avr-gcc-list] avr-gcc bug: global register variable isbroken
Date: Wed, 1 Dec 2004 17:59:05 +0100

Is it normal that 'y' being a long, it is given to f1() even for 'g' and 'h'
parameters?
These two are int and char...

Maybe there is a way to avoid using particular registers for your
application? If the code that you show is like the one you use in your
interrupt handler and if you want to use a specific register because of
performance, calling a function from an interrupt handler (and a function
with so much parameters than many registers will be touched or the stack
frame will have to be calculatedd) will use code space and processing time.

If the problem is not performance but only to call some particular function
requiring specific register usage, why not write a few assembly lines to
save/restore the corresponding registers?

 Bernard
(my 0.00002cts comment)

-----Message d'origine-----
De : address@hidden
[mailto:address@hidden la part de Klaus Rudolph
Envoyé : mercredi 1 décembre 2004 17:30
À : Haase Bjoern (PT-BEU/MKP5) *
Cc : address@hidden
Objet : Re: AW: [avr-gcc-list] avr-gcc bug: global register variable
isbroken


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
>
>
>
>
>
>
>
>


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

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