Sender: root AT delorie DOT com Message-ID: <389ACC87.134F06F1@inti.gov.ar> Date: Fri, 04 Feb 2000 09:56:39 -0300 From: salvador Organization: INTI X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.0.38 i686) X-Accept-Language: es-AR, en, es MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Clobbering registers in asm and GCC 2.952 References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Nimrod Alonzo Abing wrote: > Hello! > > Just wondering, if there is a more down-to- > earth explanation of that register clobbering > stuff in asm using GCC 2.952. [snip] > > My reaction to this reasonably obfuscated > description of the problem and its solution was "Huh?!?" And the examples given were too > short to demonstrate the principles behind it. > > Q: Where can I find a more subtle explanation of > what's going on, aside from the cut-and-dry > explanations from the GCC FAQ? > > Help will be greatly appreciated. Thanks... :-))), isn't that obfuscated, but you aren't the first to ask for clarifications. Basically: you can't list an input register in the clobber list. So if you will pass a parameter to your assembler in ECX and you know it will be clobbered (example: is the counter of a loop) you can't put it in the clobber list. Forget about why it was possible in the past and why isn't now, the explanation is quite weak for x86 architecture. So now you are wondering how to indicate gcc that this register will be clobbered, because you know it will be clobbered. Simple: use it as an output register, but then you'll ask: and where do I put the content of ECX? and isn't it a waste of variables? To the first: use a "dummy" local variable. To the second: if you use this variable only to hold the output value and nothing more gcc will optimize it and remove the load and allocation of the local variable. So gcc will know the ECX carries new information (different to the one he put in ECX) and will also know you don't care about this information. SET -- Salvador Eduardo Tropea (SET). (Electronics Engineer) Visit my home page: http://welcome.to/SetSoft or http://www.geocities.com/SiliconValley/Vista/6552/ Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org set AT ieee DOT org set-soft AT bigfoot DOT com Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013