delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/23/21:38:32

Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: Endlisnis <s257m AT unb DOT ca>
Date: Mon, 24 Aug 1998 02:33:58 +0000
MIME-Version: 1.0
Subject: Re: ASM
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com
Message-Id: <E0zAlXY-0003kX-00@sable.ox.ac.uk>

On 23 Aug 98 at 20:49, Endlisnis wrote:

> George Foot wrote:
> 
> > On 23 Aug 98 at 11:39, Endlisnis wrote:
> > >     I was trying to make an 'RGB' function that took 3 byte's as parameters and
> > > returned a long.  My idea was to do something like:
> > >     That would be faster than loading R,G,B into registers then combining them into
> > > one register.
> >
> > Hmm.  Write your own function then; you can then access the
> > parameters directly, on the stack.
> 
>     But, wouldn't it be easier, if you could access the parameters of a function as their
> names (in ASM) (with an underscore if required) rather than having to use the stack?
> Would that interfere with anything or be hard to do?

It would involve gcc tweaking your code to fill in the addresses -- 
replacing the names of parameters and local variables with offsets, 
normally from EBP.  Omitting the frame pointer would be tricky in 
this situation.

GCC would also have to turn off optimisations on the variables you 
reference to some extent; it couldn't, for instance, hold them in a 
register all the time.  It would have to save back values currently 
held in registers before running your code.  Ultimately it's probably
faster the way it is now for most purposes.

Perhaps it's possible to do this through that immediate value option,
by having an input operand which is a pointer to some parameter.  I
don't know too much about inline assembly though.  If I care this 
much I tend to write it as an external assembly routine instead.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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