On Feb 17, 2006, at 8:04 PM, Serge Dundich wrote:
I need to define the constant memory address/offset in i386 gcc
inline asm,
i.e. immediate value without $ prefix, so I can use it as a
constant offset for
some memory address statement.
Is there any way to do that?
Sure, the manual describes how do this and other neat things...
Roughly:
void foo() {
register char *ebx asm ("%ebx");
register int esi asm ("%esi");
asm ("blabla %0" : : "m" (*(ebx+esi+23)));
}
I think you're working to hard to constrain gcc, you don't have to do
that. Instead, pull it up into the C layer and just use it. It can
and will optimize as appropriate. If you have a specific question on
how to make something happen where writing it higher doesn't work,
ask that specific question.
PS: I wasn't sure what mailing list this message is the most
appropriate for.
So I posted it both here and in "gcc-help".
Please don't do that, it is always wrong to do that. gcc-help is a
list for people that need help using gcc. gcc is a list for people
writing gcc.
Now, if you really, really must do this:
#define S(s) #s
void foo() {
asm ("blabla " S(12));
}
is another way to do this.