Hi Ben,
This is the kind of information I was looking for, but I've never found a definitive source. I have a very very tight inner loop asm function. Speed is everything for this asm function. My asm function uses d0 to d7, and a0 to a5. My asm function does NOT call anything else, so even though I saved A4 and A5, I'm not worried using them because I'm not calling anyone else or referencing global variables. On entry to my asm function, I save registers like this: movem.l d3-d7/a2-a5, -(sp) So, is my assumption that I don't need to save away d0 to d2 and a0 to a1 correct? Note I am not changing a6 and a7 (and sp is really a7). Thanks, Doug. -----Original Message----- From: Ben Combee [mailto:[EMAIL PROTECTED]] Sent: Monday November 19, 2001 04:46 To: Palm Developer Forum Subject: Re: Suppressing use of A4 by CW6 for automatic variables "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/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
