delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/23/14:29:37

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ASM
Date: Sun, 23 Aug 1998 11:39:17 -0300
Organization: NBTel Internet
Lines: 42
Message-ID: <35E02995.A2754BB7@unb.ca>
References: <E0zARVp-0004QJ-00 AT sable DOT ox DOT ac DOT uk>
NNTP-Posting-Host: fctnts13c50.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

George Foot wrote:

> On 22 Aug 98 at 23:31, Endlisnis wrote:
> > int main(){
> >  int T=9;
> >  asm("movl T, %eax");
> >  }
> >     How can I make that program compile.  How can I load 'T' into %eax without
> > using input registers.
>
> You have to ask gcc to load it for you, because there's no guarrantee
> that `T' has a place in memory.  It might for instance be stored in a
> register throughout its useful life.
> You can only load global variables directly; prefix the variable's
> name with an underline.
> Why don't you want to use input registers?

    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:

unsigned int RGB(unsigned char R, unsigned char G, unsigned char B)
{
 unsigned Ret;
 asm ("shll $8, %%eax; "
      "movb G, %%al; "
      "shll &8, %%eax; "
      "movb B, %%al; "
      : "=a" (Ret) : "a" (R) : );
 return Ret;
 }

    That would be faster than loading R,G,B into registers then combining them into
one register.

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca



- Raw text -


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