This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm: How to push PIC reg before seven input operands get loaded?
On 24/03/07 11:11:52, Andrew Haley wrote:
> > I got a bit further with my problem. Now I'm stuck on how to save
> > the register used when -fPIC is enabled to the stack before my
> > seven input operands, needing all registers, get loaded. Is that
> > somehow possible? I couldn't find any examples on the net. It seems
> > not to be necessary in the original code for MSC.
>
> I doubt very much thath is possible.
Thanks for Your answer. I then wonder why gcc doesn't let me load the registers from the memory myself.
If I do eg:
Pixel16 *tileData[4]; uint16 *pDestPixel; Pixel16 *dataPtr, *transDataPtr;
sint32 startX, endX;
__asm__ __volatile__ (
"push %%ebx \n\t" // save reg for PIC!
//code here using %1 but now reg can be rused:
"movl %5, %1 \n\t" //no reg left for %5 when gcc should handel it
//but now gcc says:
//error: memory input 5 is not directly addressable
"movl (%1,%%ebx,4), %1 \n\t" //instead of "movl (%5,%%ebx,4), %1 \n\t"
//because m for %5 didn't work here
//more code using also ebx and ebp
"pop %%ebx \n\t" // restore reg for PIC!
:
: "D" (pDestPixel), "d" (endX), "c" (startX), "a" (transDataPtr), "S" (dataPtr), "m" (tileData)
: "cc" //don't tell gcc about what was done to ebx because of PIC!!!
);
gcc complains about: error: memory input 5 is not directly addressable
Why is that? How else should I load the tileData pointer from memory into a register?
> > Also I wonder which -f option that comes with -O2 makes gcc stop reporting:
> > error: can't find a register in class 'LEGACY_REGS' while reloading 'asm'
>
> I guess this is a joke.
No, it isn't. I wouldn't have asked else wise...
Is it the combination of all -f options in -O2? I coudn't find a single obviouse one in the manpage.
Is it a rule then to include -O2 or higher if inline asm is used???
>
> Andrew.
Thanks Andrew.
Lynx