www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/25/20:01:32

Sender: nate AT cartsys DOT com
Message-ID: <35BA6E5E.F577ED1D@cartsys.com>
Date: Sat, 25 Jul 1998 16:46:38 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
MIME-Version: 1.0
To: Inquisitor Nikodemus <nikki AT kki DOT net DOT pl>
CC: djgpp AT delorie DOT com
Subject: Re: extended asm & function result
References: <35ba024e DOT 1072650 AT news DOT icm DOT edu DOT pl>

Inquisitor Nikodemus wrote:
> 
> Hey!
> 
> The problem is returning function result. Let's say,I've a piece of
> asm code in my function,frankly,the asm code is whole function.
> In extended assembly we've got possibility of outputing some values.
> Now,I don't want to declare stupid additional eg. "int result" in my
> function only as a returning buffer for ,let's say, value in eax
> register ( that's the factual result of asm code) - what i want is
> direct return of my asm EAX value.
> 
> So, my idea was to declare somthing like that :
> 
> int    my_function ( parameters...) {
>            asm ( "blahblahblah..."
>                         : /* output */       "=a"  (my_function)
>                         : blah,blah
>                         : blah,blah); };
> instead of :
> 
> int my_function(parameters     ..){
>             int result ;
>           asm (" blah..."
>                    ; "=a" (result)
>                    : blah
>                    : blah ); return result };
> 
> and IT WORKED! but only for a one function call, the further execution
> of the program resulted in SIGSEV . How to solve that ?

Your new code was completely meaningless.  You can't change the value of
an object of type function.  In fact, I consider it a bug that GCC
accepted it.  The second version you give is correct, and if you
optimize enough, GCC should eliminate the `result' variable entirely.
-- 

Nate Eldredge
nate AT cartsys DOT com


- Raw text -


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