This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Suggestion for function attributes on x86 architecture
- From: "Ben. K." <bkausbk at web dot de>
- To: "Robert Dewar" <dewar at gnat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Wed, 17 Apr 2002 20:39:07 +0200
- Subject: Re: Suggestion for function attributes on x86 architecture
- References: <20020417182541.1B3ABF28D5@nile.gnat.com>
> <<.global _MyFunc
> _MyFunc:
> sub esp,4
> pusha
> mov [esp],12345678
> add esp,4
> ret
> >>
>
> Hmmm, I don't think the above is a very good advertisement. It sure
> invites the comment that this allows you to get into trouble easily :-)
As a programmer I want be able to get the full control over my code,
and then this surely could produce unpredictable results:
void MyFunc() {
int a;
a=12345;
/* surely this could produce unpredictable results, but this is my
problem, not the compilers problem */
}
So, either we use something like this:
register int a asm("eax") or memory int a asm("esp-4")
or we save all registers with pusha/popa before modifing anything.
Using naked functions is not impossible.
Benjamin