| 65 |
\code |
\code |
| 66 |
uint8_t flag; |
uint8_t flag; |
| 67 |
... |
... |
| 68 |
|
SIGNAL(SIG_SOMETHING) { |
| 69 |
|
flag = 1; |
| 70 |
|
} |
| 71 |
|
... |
| 72 |
|
|
| 73 |
while (flag == 0) { |
while (flag == 0) { |
| 74 |
... |
... |
| 75 |
} |
} |
| 76 |
\endcode |
\endcode |
| 77 |
|
|
| 78 |
the compiler will typically optimize the access to \c flag completely |
the compiler will typically access \c flag only once, and optimize further accesses completely |
| 79 |
away, since its code path analysis shows that nothing inside the loop |
away, since its code path analysis shows that nothing inside the loop |
| 80 |
could change the value of \c flag anyway. To tell the compiler that |
could change the value of \c flag anyway. To tell the compiler that |
| 81 |
this variable could be changed outside the scope of its code path |
this variable could be changed outside the scope of its code path |
| 120 |
register unsigned char counter asm("r3"); |
register unsigned char counter asm("r3"); |
| 121 |
\endcode |
\endcode |
| 122 |
|
|
| 123 |
|
Typically, it should be possible to use r2 through r15 that way. |
| 124 |
|
|
| 125 |
See \ref c_names_in_asm for more details. |
See \ref c_names_in_asm for more details. |
| 126 |
|
|
| 127 |
<small>Back to \ref faq_index. |
<small>Back to \ref faq_index. |
| 165 |
<tt>-Wl,-Tdata,0x801100</tt> to start the data section above the |
<tt>-Wl,-Tdata,0x801100</tt> to start the data section above the |
| 166 |
stack. |
stack. |
| 167 |
|
|
| 168 |
For more information on using sections, including how to use them from C code, |
For more information on using sections, |
| 169 |
see \ref mem_sections. Note that in C code, any such function would |
see \ref mem_sections. |
| 170 |
|
There is also an example for \ref c_sections. |
| 171 |
|
Note that in C code, any such function would |
| 172 |
preferrably be placed into section \c .init3 as the code in \c .init2 |
preferrably be placed into section \c .init3 as the code in \c .init2 |
| 173 |
ensures the internal register <tt>__zero_reg__</tt> is already cleared. |
ensures the internal register <tt>__zero_reg__</tt> is already cleared. |
| 174 |
|
|
| 296 |
So in general, variables should only be explicitly initialized if the initial |
So in general, variables should only be explicitly initialized if the initial |
| 297 |
value is non-zero. |
value is non-zero. |
| 298 |
|
|
| 299 |
|
\note Recent versions of GCC are now smart enough to detect this |
| 300 |
|
situation, and revert variables that are explicitly initialized to 0 |
| 301 |
|
to the .bss section. Still, other compilers might not do that |
| 302 |
|
optimization, and as the C standard guarantees the initialization, it |
| 303 |
|
is safe to rely on it. |
| 304 |
|
|
| 305 |
<small>Back to \ref faq_index. |
<small>Back to \ref faq_index. |
| 306 |
</small> |
</small> |
| 307 |
|
|