delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/03/19:57:58

Date: Wed, 3 Dec 1997 16:55:56 -0800 (PST)
Message-Id: <199712040055.QAA21354@adit.ap.net>
Mime-Version: 1.0
To: leathm AT solwarra DOT gbrmpa DOT gov DOT au (Leath Muller)
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Inline asm
Cc: fabrice AT trash DOT lip6 DOT fr, djgpp AT delorie DOT com

At 03:39  12/3/1997 +1000, Leath Muller wrote:
>> >	You MUST !!
>
>> Not necessarily. In many cases you can use GCC's extended asm features to
>> inform it that a certain register has been clobbered. I can't think of a
>> simple realistic example, so here's an imaginary one. The `frob' instruction
>> does something useful and puts undefined stuff into the given register.
>> asm("frob %ebx" : /* no outputs */ : /* no inputs */ : "%ebx");
>
>Correct me if I am wrong, but if you have a piece of assembly in its own
>subroutine:
>
>	void whatever()
>	{
>		asm {
>		}
>	}
>
>then you don't have to push/pop any registers other than the stack/stack
>frame ones (like ebp if you use it) as the subroutine has its own stack
>frame anyway...
Not quite. You will have to (save/restore) or (tell the compiler that you
clobbered) registers which it expects to be preserved across function calls.
Last I checked, this was %ebx, %esi, %edi and %ebp. IMHO, you should inform
the compiler about clobbering every register that you change, and it will
then take appropriate action if necessary.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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