Le Jeudi 22 Mars 2007 10:01, Vineet Golchha a écrit :
> Aujourd'hui 10:01:43
>    
> Hi there,
>    My concern is this.
>    For example:
>
>
>   TR0 = 0;                    // reset the timer
>   while( TR0 == 0 );       // wait for the flag to be set.
>  i++;                           // get out of the loop and increment
> }
>
> What is SDCC going to do in this case.
> Will it say that line corr. to "i++" as unreachable code.

Probably.
TR0 = 0; does not RESET the timer, it STOPS the timer.
Nothing will retart it once you're in the loop.
You may want to wait for an interrupt from the timer-counter.
So 
TR0=1; 
// tell how the interrupt will be triggered
TF0=0; // reset the overflow interrupt flag
// then
  while( TF0 == 0 );    // wait for the INTERRUPT flag to be set by some        
                        
                        // cause outside the loop





>
> But how does the compiler know that?
>
> Regards,
> Vineet.

-- 
Never jump into a loop!

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to