power up variable initialization

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have defined some variables outside of the functions with initail values.

u08 var[]={1,2,3,4};

But I found that gcc doesn't initialize it. Is it a correct behaviour of gcc? Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will have to be more explicit.

How does it not work?
What version of the tools are you using?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And, are you only simulating in AVR Studio, or rather observing this
on a real device?

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using winavr20040720.

The variable constant is random in the real device.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just tried compiling the following program with the latest WinAVR:

unsigned char var[] = {1,2,3,4};

int main(void) 
{
  while(1);
} 

Looking at the disassembled output I can see the loop that initializes the variable. Further, using the latest Studio, I was able to simulate it and see the data section being loaded with the correct values.

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What optimisation settings are being used?

Note that GCC bug #16884 may be related:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16884

If so, it was only recently fixed on the GCC mainline.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi dharper,

Could you please recommend a good (multipass?) disassembler? Thanks!

Vincent

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avea wrote:
Could you please recommend a good (multipass?) disassembler? Thanks!

Actually, all I did was check the *.lss file produced by WinAVR when I compiled the program. It contains both the C source and disassembled output. There's a lot of useful information produced by the compile process - take a look at the *.sym file to see where your variables are located in memory.

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi dharper,

Thanks. I can found the .lss file but not the .sym files. Could you please help.

Vincent

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi dharper,

I did it by changing the makefile. Thanks!

Vincent