EmbeddedRelated.com
Forums

AVR IAR C Compiler

Started by Vidya August 3, 2005
How to force the compiler to use stack as parameter passing for a
particular function (for recursive functions)?

Infact, my function isnt a recursive one, but has a big parameter list.
Due to this, the register values are being tampered, which were set by
other functions. SO, i want the compiler to use stack for this
particular function for its parameter calling.

Thanx in advance

Vidya <vidyaranya.c@trianz.com> wrote:

> Due to this, the register values are being tampered, which were set > by other functions.
Hold it right there. You're writing a C function. If it wants to take values from other functions, put them in the argument list, not in registers. C is not assembler, so don't pretend otherwise. One of the differences is that you *have to* give up control over the CPU registers, and leave them to the C compiler to work with. You're fighting the C compiler instead of using it. Don't. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
"Vidya" <vidyaranya.c@trianz.com> wrote in message 
news:1123105189.153479.278310@f14g2000cwb.googlegroups.com...
> How to force the compiler to use stack as parameter passing for a > particular function (for recursive functions)? > > Infact, my function isnt a recursive one, but has a big parameter list. > Due to this, the register values are being tampered, which were set by > other functions. SO, i want the compiler to use stack for this > particular function for its parameter calling.
Big parameter list? Have you considered simply passing a pointer to a structure? Steve http://www.fivetrees.com
"Vidya" <vidyaranya.c@trianz.com> skrev i meddelandet 
news:1123105189.153479.278310@f14g2000cwb.googlegroups.com...
> How to force the compiler to use stack as parameter passing for a > particular function (for recursive functions)? > > Infact, my function isnt a recursive one, but has a big parameter list. > Due to this, the register values are being tampered, which were set by > other functions. SO, i want the compiler to use stack for this > particular function for its parameter calling. > > Thanx in advance >
Why not push these registers in your function before use? -- A. P. Richelieu