How to use C macros in asm

Claudio Bley bley@cs.uni-magdeburg.de
Wed Nov 5 11:49:00 GMT 2003


On Wed, Nov 05, 2003 at 11:19:21AM +0100, Falk Hueffner wrote:
> Kapileswar Rao <kapileswar_rao@mentorg.com> writes:
> 
> >     I am trying to use a C macro inside the asm instruction.But inside
> > the asm instruction macro is not replaced by macro definition. Is there
> > anyway I can do that.
> > 
> > Here is an Example what I want to do.
> > 
> > #define Register  R0
> > 
> > asm("mov Register, #1");
> 
> #define foo(R0) asm("mov Register, " #R0);

Maybe I misunderstood sth. but I think the OP wants to replace the
word `Register' with `R0' inside of a string. And that's usually
not possible because the C preprocessor doesn't replace/expand macros
inside of string literals and there's AFAIK no way of convincing it
to do this.

-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \



More information about the Gcc-help mailing list