Sender: nate AT cartsys DOT com Message-ID: <374730AF.831BEA33@cartsys.com> Date: Sat, 22 May 1999 15:33:19 -0700 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.5 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: problem with extended inline asm References: <3743B4E7 DOT 12663C12 AT go DOT ro> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Radu Georgescu aka skoola wrote: > > > > the static and the automatic variables are located in memory one next to > > > another, if they are declared so > > > > This is simply not true. Static variables go to the data section > > while automatic variables are on the stack. So they could be > > megabytes apart. You can easily verify that by taking an address of a > > variable and printing it. > > you didn't understand what i'm talking about. you have to know the address of > one static variable and then you can address the others using the following > model: > static short a,b; > asm(" > mov 2+%0,%%ax > " > : > :"g"(a)); > and you get > > mov b,ax > > if both a and b are automatic variables, you may also do this stuff but there > should be -2+%0 instead 2+%0 ,IMHO NO. This may work now but you CANNOT depend on it. The compiler is at liberty to place variables wherever it wants. There is absolutely nothing requiring it to put variables declared together adjacent to each other. This is even more so for auto variables. One or both may be put in registers or even optimized entirely out of existence. If you want to know where a variable lives, you have to ask the compiler. Plain and simple. -- Nate Eldredge nate AT cartsys DOT com