This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

inline assembly operands


hi all,

why out-of-function asm statements can't have operands?
An example for case when it would be useful is to
make the compiler calculate offsetof-s or sizeof-s (because
it knows best how to do it, taking into account alignment
rules, etc).

I used the following ugly hack to get around this limitation:

	asm (".if 0");
	void dymmy_func(void) {
	asm (".endif"::);

	/* here I can use operands. for example: */
	asm (".equ A, %0"::"i"(sizeof(something)));
	/* and compile with -masm=intel to make the
	 * compiler not to prefix the "immediate operand" */

	asm (".if 0"::);
	}
	asm (".endif");

but now it seems unreliable since with the new
unit-at-a-time feature the compiler may reorder
the functions and top-level asm statements arbitrarily.

Is it so hardly implementatiable to permit operands
in the top-level asm statements?

lucho



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]