delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/15/02:59:54

From: cnc AT netcom DOT com (Christopher Christensen)
Date: Mon, 14 Mar 1994 23:23:45 PST
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: gcc extended asm bug?

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019