[Top][All Lists]

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

Re: [avr-chat] Missed Optimisation ?

From: Erik Christiansen
Subject: Re: [avr-chat] Missed Optimisation ?
Date: Wed, 2 Mar 2011 02:03:14 +1100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Tue, Mar 01, 2011 at 03:27:34PM +0100, bob wrote:

> > 
> > Have to agree, 'cos the code can break if it doesn't respect a genuine
> > volatile.
> > 
> > Mind you, if "result" is genuinely volatile, then it can change between
> > the |= and the >>=, so we could be right shifting the other thread's
> > value, couldn't we?
> > 
> > <$.02>
> > Over 25 years I've always written ISRs in assembler. That has made them
> > easy to optimise, predictable in behaviour, and independent of compiler
> > "improvements" in the event of having to use another version. (Not that
> > in-line asm stuff, rather a proper linked-in asm file. Lots easier. ;-)
> > Oh, 'n don't have to argue with the compiler about what's "volatile"
> > either.
> > </$.02>
> > 
> > Erik
> > 

> Hi Erik ! (and Graham and Jan and Alex)
> I suppose 'big machines' might interrupt in the interrupt (as can the
> avr, but it doesn't unless you make it).
> I think that, in an interrupt where no other interrupt has been enabled
> (i.e. in the interrupt code itself), then it would be better to save
> some bytes.

Errrrr ... Bob, if "result" is in RAM, and so can't be changed by
hardware, and interrupts have not been reenabled (we're in an ISR),
then how can "result" be volatile?

> You are right in saying that ISRs are better written in assembler (and
> linked), only then do you have 'full control'.
> I will do this in assembler anyway, it was just a point I wanted to
> discuss with the list - thanks for doing just that.

If memory serves me, here "volatile" is nearly as good as beer, for
starting a discussion. :-)

> It still seems to me that cheating on a part of the code, but not the
> other part is a bit screwy :-)

We have too few maintainers for the avr port, and the rest of us are
grateful to them, but not enough to compete for the job of making a good
tool "perfect". Oh, and I wonder if there are more little corner cases
than we would like to tackle.

It doesn't do any harm to keep one's assembler skills honed, and the
ISRs are usually short enough to be easily done, barring surprises. 


An idealist is one who, on noticing that a rose smells better than a
cabbage, concludes that it will also make a better soup. -- H.L. Mencken

reply via email to

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