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

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

Re: [avr-gcc-list] Global variables and ISRs ???


From: Vincent Trouilliez
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Wed, 07 Sep 2005 10:53:24 +0200

> generated with basic -O optomisation is far easier to read and understand 
> than code
> generated with -O0, since it keeps variables in registers instead of the
> stack.

Oh, that's interesting... because as soon as I compile my small
programs, I rush to check to have a look at the assembler output, to get
the hang of things, and am often very confused by the way the compile
does things, it's often very obscure !
So far I have noticed a few recurrent things...

- at start-up, to initialize variables to zero... it won't write zero
into them (immediate constant I mean), instead it will always copy R1
into the variable. Apparently R1 is kept cleared at all times and is
used whenever a variable needs to be cleared.

- everytime I want to increment a variable, instead of just using the
"INC" or "DEC" instructions, it prefers to substract the complement...
just as fast (one cycle), but boy not exactly as "readable"/clear as
"INC" or "DEC", insn't it ?! :-/


- everytime I test if a variable is zero or not, it AND's it with
itself... instead of just using the dedicated 'TST' instruction.


So it doesn't make it very easy for me to learn the AVR's assembler... 


The optimazation option is "-Os" as that's what is used in avr-libc's
documentation, which I used to get me started with using the tool-chain.
Maybe gcc-avr should have a new option : "if you have the choice between
two ways of doing thing, that will take the same space and clock
cycle... please take the one that's most readable by human
beings" !! ;o)


> > is a problem in your code also - you are not making
> > flag=0 after you send back the character. HTH.
> That's certainly true - I suppose he'd have noticed if his program had got
> far enough...

No boys, not a bug, a feature !! ;-P
That said, once this worked, I did clear the flag so I can enjoy seeing
it working more than just once, without having to reset the AVR, but it
didn't really add anything, since I already knew it was working even
when the flag wasn't cleared...


--
Vince





reply via email to

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