How to pass a #defined constant as an address to the inline assembler

Ian Lance Taylor ian@zembu.com
Wed Sep 1 07:37:00 GMT 1999


   Date: Wed, 01 Sep 1999 10:20:48 +0200
   From: Mark Jonas <jonas@informatik.uni-freiburg.de>

   unsigned short foo;
   #define MODBASE  0xFFFFF000L
   #define CNTR1   (MODBASE+0x060A)
   asm volatile ("move.w %1,%0" : "=g" (foo) : "g" (CNTR1));

The 'g' constraint permits an immediate operand, and that's what
you're getting.  Try using the 'm' constraint instead for CNTR1.

I haven't tried this myself, so I don't know whether it will work.
However, in general I think you need to find the right constraint to
tell gcc to emit a memory address rather than an immediate value.

Ian

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list