<HTML><BODY>
<div>Only exception... maybe one of these programs is using r20,21,22,23 by accident when it shouldnt be??<SPAN contentEditable=false style="DISPLAY: inline-block"></SPAN></div>


<div>&nbsp;</div>
&nbsp;<br>
-----Original Message-----<br>
From: richard-lists@imagecraft.com<br>
Sent: Wed, 4 Apr 2007 4:03 PM<br>
Subject: Re: [Icc-avr] Preserved registers?<br>
<br>

<STYLE>
.AOLPlainTextBody {
    margin: 0px;
    font-family: Tahoma, Verdana, Arial, Sans-Serif;
    font-size: 12px; 
    color: #000; 
    background-color: #fff; 
}

.AOLPlainTextBody pre {
    font-size: 9pt;
}

.AOLInlineAttachment {
    margin: 10px;
}

.AOLAttachmentHeader {
    font: 11px arial;
    border: 1px solid #7DA8D4;
    background: #F9F9F9;
}

.AOLAttachmentHeader .Title {
    font: 11px arial;
    background: #B5DDFA;
    padding: 3px 3px 3px 3px;
}

.AOLAttachmentHeader .FieldLabel {
    font: 11px arial; 
    color: #000000;
    padding: 1px 10px 1px 9px;
    background: #F9F9F9;
}

.AOLAttachmentHeader .FieldValue {
    font: 11px arial; 
    color: #000000;
    background: #F9F9F9;
}

.AOLAttachmentHeader a, .AOLImage a {
    color: #2864B4;
    text-decoration: none;
}

.AOLAttachmentHeader a:hover, .AOLImage a:hover {
    color: #2864B4;
    text-decoration: underline;
}

.AOLWebSuiteCompose .AOLPicturesFullSizeLink,
.AOLWebSuite .AOLPicturesFullSizeLink {
    height: 1px;
    width: 1px;
    overflow: hidden;
}

body {
    background-color: white;
    font-family: "Verdana";
    font-size: 10pt;
    border: 0px;
}

.AOLWebSuiteCompose p {
    margin: 0px;
    padding: 0px;
}

img.managedImg {
    width: 0px;
    height: 0px;
}

img.placeholder {
    width: 275px;
    height: 206px;
    background: #F4F4F4 center center no-repeat;
    border: 1px solid #DADAD6 !important;  
}

</STYLE>


<div class=AOLPlainTextBody id=AOLMsgPart_0_2cb921f6-e871-4184-8921-efaf44a62bc0>Is "foo" compiled by ICC? If so, then it should not be a problem, since foo()'s code will save/restore the "Preserved Registers" (see Help on Calling Convention and Assembler Interface). If foo() is written in assembler, it will still need to obey the convention.&nbsp;<br>
&nbsp;<br>
At 10:44 AM 4/4/2007, Peter LaDow wrote:&nbsp;<br>
&gt;I'm running into an issue with preserved registers being overwritten.&nbsp;<br>
&gt;&nbsp;<br>
&gt;For example, I have something like:&nbsp;<br>
&gt;&nbsp;<br>
&gt;extern void (*foo)(void);&nbsp;<br>
&gt;&nbsp;<br>
&gt;void bar(void)&nbsp;<br>
&gt;{&nbsp;<br>
&gt; int i;&nbsp;<br>
&gt;&nbsp;<br>
&gt; for(i=0; i &lt; 16; i++)&nbsp;<br>
&gt; {&nbsp;<br>
&gt; foo();&nbsp;<br>
&gt; }&nbsp;<br>
&gt;}&nbsp;<br>
&gt;&nbsp;<br>
&gt;The problem is that i keeps getting destroyed after a call to foo(). I've &gt;tracked this down and it is because foo() is using the same registers that &gt;i is using. Now foo() is not located in the same executable ( i.e. not &gt;linked with bar()), and I think some sort of optimization is being &gt;done. Since bar() is unaware of foo()'s register usage, and foo() is &gt;unaware of bar()'s register usage, they can pick the same registers.&nbsp;<br>
&gt;&nbsp;<br>
&gt;(The application calls functions in the bootloader to program the flash, &gt;but the bootloader and application are compiled separately.)&nbsp;<br>
&gt;&nbsp;<br>
&gt;I do NOT have global optimizations enabled (which I think is -Wf-O8).&nbsp;<br>
&gt;&nbsp;<br>
&gt;I think my only way to handle this is to make sure that all preserved &gt;registers are saved and restored whenever leaving (or entering) code &gt;outside of the current executable. Is this my only solution, or is there &gt;an ICC way to handle this?&nbsp;<br>
&gt;&nbsp;<br>
&gt;Thanks,&nbsp;<br>
&gt;Pete&nbsp;<br>
&nbsp;<br>
// richard (This email is for mailing lists. To reach me directly, please use richard at imagecraft.com) &nbsp;<br>
_______________________________________________&nbsp;<br>
Icc-avr mailing list&nbsp;<br>
<A href='javascript:parent.ComposeTo("Icc-avr%40imagecraft.com", "");'>Icc-avr@imagecraft.com</A>&nbsp;<br>
<A href="http://dragonsgate.net/mailman/listinfo/icc-avr" target=_blank>http://dragonsgate.net/mailman/listinfo/icc-avr</A>&nbsp;<br>
</div>
<!-- end of AOLMsgPart_0_2cb921f6-e871-4184-8921-efaf44a62bc0 -->
<div class="AOLPromoFooter">
<hr style="margin-top:10px;" />
AOL now offers free email to everyone.  Find out more about what's free from AOL at <a href="http://www.aol.com?ncid=AOLAOF00020000000437" target="_blank"><b>AOL.com</b></a>.<br />
</div>

</BODY></HTML>