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

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

[avr-gcc-list] gcc bug


From: Troy
Subject: [avr-gcc-list] gcc bug
Date: Wed, 23 Jun 2004 11:38:20 -0700 (PDT)

Hi,

I am writing on behalf of a friend who has a problem
with output from win-avr-gcc (I am writing on his behalf
because of language issues).

The program has a global variable called "motor"
which is a struct containing a uint16_t variable
called "count."

struct smotor { uint16_t count; } motor;

main() {
        // code to set up a timer which sets up a 
        // signal handler for SIG_OVERFLOW0.
        ... 
        func();
        // never returns from func().
}

func() {
        motor.count = 10;
        while(motor.count > 0) {
                ;
        }
}

signal(SIG_OVERFLOW0) {
        if (motor.count) {
                motor.count--;
        }
}


The assembly code produced by gcc uses register R24 for "motor.count."
signal() stores R24 properly in data space, altering its value to
0, as it should.
func() has the problem. It doesn't read R24 from data space before each
comparison, but instead treats it as a local variable. This causes the 
busy loop in func() to never exit.

Optimizer options used were the default values for the Makefile
which came with the latest win-avr-gcc (downloaded one month ago).

If the code is altered to include further steps inside func()'s 
while loop, the generated assembly code is different and works properly.
This is, however, not desirable.

It seems like an error that the R24 variable's value is not read
from data space before each comparison, since it is a global
variable.




Thank you.



Troy (on behalf of Timo)

 











reply via email to

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