I'm having a lot of trouble with the way GCC treats various objects. In
particular, if I want to pass falgs about in my program, unless I'm very
pernickety it optimeses them out, assuming they aren't wanted. For
example: (ticks is incremented by an interrupt)
void wait_ticks( unsigned int nticks)
{
unsigned int t;
t = ticks;
while( (ticks-t) < nticks)
;
}
If I don't declare ticks as volatile, I get this:
000047d4 <wait_ticks>:
47d4: 0e 43 clr r14 ;
47d6: 0e 9f cmp r15, r14 ;
47d8: fe 2b jnc $-2 ;abs dst addr
0x47d6
47da: 30 41 ret
which just hangs.
Is there any way of forcing the compiler to assume everything is
volatile? Why does it do this anyway?
Paul Burke