Mail Archives: djgpp/1994/03/15/02:59:54
I'm running into a problem with the extended asm feature of DJGPP...
GCC seems to be ignoring the list of clobbered registers for some
reason. The generated code isn't doing anything to preserve registers
like %esi, %edi, and %ebx which need to be preserved.
Here's an example:
--- foo.c ---
void foo()
{
asm(
"movl $0,%%edi
movl $0,%%esi
movl $0,%%ebx"
:: "b" (5), "S" (10) /* list of inputs */
: "%%ebx", "%%esi", "%%edi", "cc" /* list of clobbered registers */
);
}
--- foo.s ---
.file "foo.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 2
.globl _foo
_foo:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %ebx
movl $5,%ebx
movl $10,%esi
/APP
movl $0,%edi
movl $0,%esi
movl $0,%ebx
/NO_APP
leal -8(%ebp),%esp
popl %ebx
popl %esi
leave
ret
--- eof ---
In this example, %ebx and %esi were preserved because they were listed
as inputs, but %edi (which I listed as a clobbered register) does not
get saved! The obvious workaround is to insert my own pushes and pops
to save the appropriate registers, but I was wondering if perhaps there
is a more elegant way. Is this a GCC bug or am I doing something wrong?
thanks for any help,
Christopher
p.s. I'm using 1.11.maint3
--
----------------------------------------------------------------------
: Christopher : Huntington Beach California, USA :
: Christensen : email: cnc AT netcom DOT com :
----------------------------------------------------------------------
- Raw text -