11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRStatementsIn <strong>the</strong> following, if-body, while-body, ...etc. are synonymous to C statements.Expression Statement[ label: ] [expression];See Expressions <strong>and</strong> Type Promotions <strong>for</strong> discussion on expressions. An emptysemicolon by itself is a null expression statement.Compound Statement{ [statement ]* }A compound statement is a sequence of zero or more statements enclosed in a set of{}. Notably, local declarations are only valid immediately after a { <strong>and</strong> be<strong>for</strong>e anyexecutable statement, so sometimes a {} is introduced just <strong>for</strong> that purpose.If Statementif () if-body [ else else-body ]If evaluates to non-zero, <strong>the</strong>n it executes <strong>the</strong> if-body. O<strong>the</strong>rwise, itexecutes <strong>the</strong> else-body if it exists. There is no “dangling-else” problem, as an elsekeyword is always associated with <strong>the</strong> nearest preceding if keyword.While Statementwhile () while-bodyExecutes <strong>the</strong> while-body as long as <strong>the</strong> evaluates to non-zero. Note thatour <strong>compiler</strong>s compile this to something similar togoto bottomloop_top: bottom: if goto loop_topWhile not as straight<strong>for</strong>ward as <strong>the</strong> obvious test-at-<strong>the</strong>-top translation, this sequenceexecutes n+2 branches <strong>for</strong> a loop that executes n times, vs. 2n+1 branches <strong>for</strong> <strong>the</strong>obvious translation.For Statement<strong>for</strong> ( [] ; ; ) <strong>for</strong>-body82

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!