[Top][All Lists]

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

Re: [avr-gcc-list] Global variables and space efficient programming agai

From: Denis Chertykov
Subject: Re: [avr-gcc-list] Global variables and space efficient programming again
Date: 28 Mar 2001 22:41:39 +0400

address@hidden (Robert Rozman) writes:

> Hello,
> a little while ago I posted message concerning usage of main variables
> in avr-gcc programs and code space efficient programming.
> I have a program that uses quite some global variables (30-40). I
> discovered that every access to this variable takes assembly
> instructions (sts, std if I remember right) that results in quite
> inefficient use of code space.
> Then I forced variables into struct and define global pointer to this
> struct and declare it as a r28,r29 register variable (this registers
> were obviously reserved from other usage). I saved a lot of code space
> (600 bytes in 8000 bytes) but it still seems that leaving this choice to
> compiler would be better than forcing him to stay away from those
> registers. If I do this, then avr-gcc is filling those registers at each
> access, so all profit is lost .

Send me examples.

> Denis replied that obviously optimizer in avr-gcc is in some way
> broken.

It's a generic GCC problem. You can try `-fstrict-aliasing'

About your previous example:
try: avr-gcc -Os -fstrict-aliasing -S test.c


struct time_struct
  char day;
  char hour;
  char min;
  char sec;

struct time_struct * const time;
/*          --------^^^^^^^-------------    This `const' important */
int main(void)
  time->day = 5;
  time->hour= 9;
  time->min = 10;
  time->sec =10;

reply via email to

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