This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
inline assembly operands
- From: Luchezar Belev <l_belev at yahoo dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 14 Jun 2004 18:59:16 -0700 (PDT)
- Subject: 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/