Xref: news2.mv.net comp.os.msdos.djgpp:7221 From: John Luebs Newsgroups: comp.os.msdos.djgpp Subject: Re: Accessing Variables in Inline ASM Date: Tue, 13 Aug 1996 20:30:27 -0400 Organization: EpiCenter Software Lines: 38 Message-ID: <32111E23.40CF@sprynet.com> References: <199608071658 DOT JAA08681 AT bluesky> Reply-To: jkluebs AT sprynet DOT com NNTP-Posting-Host: dd03-082.compuserve.com 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 Kevin Baca wrote: > > > Ok, I'm starting to get the hang of inline ASM, but I just can't > > find a good reference on how to access variables via inline ASM. > > I've heard that you must declare everything globally, but this can't > > be the best solution. Does anyone know a better way, or a place > > where I could read up on the subject? If I declare a variable > > within a function, how can I use that variable in my inline ASM > > routine? If the function is recursive, how will that affect things? > > Thanks! > > > > -David :) > > The following function adds 3 ints and returns the result. You can > see how it accesses local variables. The "rm" means the variable > could either be in a register or in memory. Check out the info > section of gcc on inline assembly for more of this kind of stuff. > > int add3(int i, int j, int k) > { > int ret; > > __asm__(" > movl %1,%%eax > addl %2,%%eax > addl %3,%%eax" > : "=a" ret > : "rm" (i),"rm" (j),"rm" (k) > : "eax"); > > return ret; > } > > -Kevin Go to http://remus.rutgers.edu/~avly/djasm.html It has the official tutorial to inline assembler, it gives alot of information about how to deal with inputs, outputs, and handling modified registers.