This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

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


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

This does not work, too. 

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

The compiler produces (at address 402B0):
--
move.w (296,PC),(0FFFE,A6)
--

This can't be right because of (402B0 + 2 + 296) != FFFFF60A

> 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.

I think one should just use the constraints only if a command can for
example just accept registers. Also it is not clever to constraint the
compiler to much because then it can't take what fits in best.

Any other ideas will be appreciated.

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


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