This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization bug on i386, stack fiddling
- To: Lars Balker Rasmussen <lbr at mjolner dot dk>
- Subject: Re: Optimization bug on i386, stack fiddling
- From: Bernd Schmidt <bernds at balti dot cygnus dot co dot uk>
- Date: Thu, 6 Jan 2000 16:12:33 +0000 (GMT)
- cc: gcc-bugs at gcc dot gnu dot org
>
> int printf(const char *, ...);
> int main()
> {
> asm ("pushl %ebp");
> printf("Hello world\n");
> asm ("popl %ebp");
> return 0;
> }
I'm sorry, but you can't do that. asm statements may not modify the
stack pointer (or the frame pointer, PIC register, or anything else
that is "special").
>
> asm ("pushl %edi");
> asm ("pushl %esi");
> asm ("pushl %eax");
> asm ("pushl %ebx");
> asm ("pushl %ecx");
> asm ("pushl %edx");
> foo();
> asm ("popl %edx");
> asm ("popl %ecx");
> asm ("popl %ebx");
> asm ("popl %eax");
> asm ("popl %esi");
> asm ("popl %edi");
Try
asm ("all the pushes
call foo
all the pops");
or, even better, leave the saving of registers to the compiler:
asm ("call foo" : : : "eax", "ebx", "ecx", ...);
Note that you can't use %ebp the same way.
Bernd