Xref: news2.mv.net comp.os.msdos.djgpp:4833 From: terra AT diku DOT dk (Morten Welinder) Newsgroups: comp.os.msdos.djgpp Subject: Re: Inline ASM and variables Date: 10 Jun 1996 16:22:15 GMT Organization: Department of Computer Science, U of Copenhagen Lines: 33 Sender: terra AT tyr DOT diku DOT dk Message-ID: <4phi3n$ajc@vidar.diku.dk> References: <31BB2931 DOT 3BB0 AT ix DOT netcom DOT com> NNTP-Posting-Host: tyr.diku.dk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Brian Drum writes: >For eaxample: >void foo(int x) { > __asm__ __volatile__ (" > movl _x, %%eax" > : > : > :"eax" ); >} >Won't work. I get the following linker error: >test_asm.c(.text+0x4): undefined reference to `x' >I know that I could simply have GCC load x for me but that won't do in >the more complicated things that I'm doing because I don't want to use >up a bunch of registers. Well, you _should_ make GCC do those things. Your objection seems to be based on an incorrect basis; if you use "m" (or "g") as constraint you don't (necessarily) get the operand passed in a register. The worst problem with this method seems to be that you can't have more than ten arguments. Anyway, GCC handles asm (...) by shipping it out into the assembler file. It doesn't even attempt to grok symbols so only non-local symbols can be accessed. Perhaps if you post more about your problem you can get more specific advice. Morten