I&#39;m running into an issue with preserved registers being overwritten.<br><br>For example, I have something like:<br><br>extern void (*foo)(void);<br><br>void bar(void)<br>{<br>&nbsp; int i;<br><br>&nbsp; for(i=0; i &lt; 16; i++)
<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; foo();<br>&nbsp; }<br>}<br clear="all"><br>The problem is that i keeps getting destroyed after a call to foo().&nbsp; I&#39;ve tracked this down and it is because foo() is using the same registers that i is using.&nbsp; Now foo() is not located in the same executable (
i.e. not linked with bar()), and I think some sort of optimization is being done.&nbsp; Since bar() is unaware of foo()&#39;s register usage, and foo() is unaware of bar()&#39;s register usage, they can pick the same registers.
<br><br>(The application calls functions in the bootloader to program the flash, but the bootloader and application are compiled separately.)<br><br>I do NOT have global optimizations enabled (which I think is -Wf-O8).<br>
<br>I think my only way to handle this is to make sure that all preserved registers are saved and restored whenever leaving (or entering) code outside of the current executable.&nbsp; Is this my only solution, or is there an ICC way to handle this?
<br><br>Thanks,<br>Pete <br>--<br>&quot;To love for the sake of being loved is human;&nbsp;&nbsp;to love for the sake of loving is Angelic.&quot;&nbsp;&nbsp;-- Alphonse de Lamartine