From: Endlisnis 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: NNTP-Posting-Host: fctnts13c50.nbnet.nb.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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