[Icc-avr] Preserved registers?
bobgardner at aol.com
bobgardner at aol.com
Wed Apr 4 13:34:01 PDT 2007
Only exception... maybe one of these programs is using r20,21,22,23 by accident when it shouldnt be??
-----Original Message-----
From: richard-lists at imagecraft.com
Sent: Wed, 4 Apr 2007 4:03 PM
Subject: Re: [Icc-avr] Preserved registers?
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.
At 10:44 AM 4/4/2007, Peter LaDow wrote:
>I'm running into an issue with preserved registers being overwritten.
>
>For example, I have something like:
>
>extern void (*foo)(void);
>
>void bar(void)
>{
> int i;
>
> for(i=0; i < 16; i++)
> {
> foo();
> }
>}
>
>The problem is that i keeps getting destroyed after a call to foo(). I've >tracked this down and it is because foo() is using the same registers that >i is using. 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. Since bar() is unaware of foo()'s register usage, and foo() is >unaware of bar()'s register usage, they can pick the same registers.
>
>(The application calls functions in the bootloader to program the flash, >but the bootloader and application are compiled separately.)
>
>I do NOT have global optimizations enabled (which I think is -Wf-O8).
>
>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. Is this my only solution, or is there >an ICC way to handle this?
>
>Thanks,
>Pete
// richard (This email is for mailing lists. To reach me directly, please use richard at imagecraft.com)
_______________________________________________
Icc-avr mailing list
Icc-avr at imagecraft.com
http://dragonsgate.net/mailman/listinfo/icc-avr
________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20070404/97842353/attachment.html
More information about the Icc-avr
mailing list