[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte
From: |
David Brown |
Subject: |
Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege |
Date: |
Fri, 4 Nov 2005 16:31:54 +0100 |
> From: Vincent Trouilliez <address@hidden>
>
> [...]
>
> >About the -Os flag, I noticed this morning that it managed MASSIVE code
> >size reduction ! SO far I had been using just -O (I guess that means no
> >particular optimisation ?), and the program is about 13KB in size. With
> >-Os, it's only 10KB !!! Sadly, for some reason, when compiled with this
> >flag, my program misbehaves badly (I get massive corruption of the LCD
> >display) !! Too bad... :o(
>
> I believe it was Gerry Weinburg who once wrote that "optimization is
easy --
> if you don't have to get the right answer."
>
> I suspect, though, that some of your code might be relying on behavior
> that's not guaranteed (e.g., the value of an uninitialized variable)
rather
> than a bug in the optimizer.
>
> Regards,
>
> -=Dave
>
The bug is almost certainly a delay loop variable that is not declared
volatile. The delay function is probably something like:
void shortDelay(void) {
uint8_t n = 50;
while (n--);
}
That (might) work fine with little or no optomisation, but when optomisation
is on, it fails. The solution is simply to make n "volatile". Note that it
will not give you precise control of your delay - different optomisations or
different compiler versions might give slightly different code, and may or
may not inline the function. But in a case like this it doesn't matter -
all you are looking for is a slight delay, and it doesn't matter if it is
too long. I've done exactly this sort of thing (with "volatile", naturally)
myself for LCD routines.
mvh.,
David
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, (continued)
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Vincent Trouilliez, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Royce Pereira, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Vincent Trouilliez, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Ian Caddy, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Vincent Trouilliez, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within amulti-byte integer ?, Jurek Szczesiul, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within amulti-byte integer ?, Vincent Trouilliez, 2005/11/04
- RE: [avr-gcc-list] How to (efficeiently !!!) test a bit withinamulti-byte integer ?, niklo, 2005/11/04
- RE: [avr-gcc-list] How to (efficeiently !!!) test a bit withinamulti-byte integer ?, Vincent Trouilliez, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit withinamulti-byte intege, Dave Hansen, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege,
David Brown <=
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Dave Hansen, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Dave Hylands, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Joerg Wunsch, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Joerg Wunsch, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) testabitwithinamulti-byte intege, Dave Hansen, 2005/11/07
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege, David Kelly, 2005/11/05