"Mohan Mohit" <[EMAIL PROTECTED]> wrote in message
news:68339@palm-dev-forum...
>
> Hi All,
>
> Is there any way to direct the code warrior c compiler
> NOT to use the processor's A4 register for it's
> automatic variables?
> The problem I am facing is of corruption of automatic
> variables when I call a shared library function. One
> of the automatic variables in the calling function is
> allocated on A4 by Metrowerks C compiler and after the
> control returns from the shared library API of a
> standard product, the contents of the A4 register is
> changed and therefore the contents of the variable.
> One way to overcome this (I could think of) is to
> somehow make sure that Metrowerks compiler does not
> use A4 for its local variables (but I do not know how

CodeWarrior will use A4 for variables, but by the Palm OS calling
convention, it should be restoring A4 to its original value before
returning to your code.  In the scheme used by Palm OS, the A0 and A1
registers are volatile, while A2, A3, and A4 are callee-saved.  A5 is
reserved for the global pointer, while A6 is used as a frame pointer and
A7 is the stack pointer.

Note: generally, shared libraries in CodeWarrior are built using the
"code fragment" compiler option.  This makes A4 even more off limits, as
the compiler is assuming that A4 is used for the global pointer (even
though global access through it isn't allowed)

Can you supply a sample of the code that isn't restoring A4?



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to