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



>unsigned short foo;
>#define MODBASE  0xFFFFF000L
>#define CNTR1   (MODBASE+0x060A)
>asm volatile ("move.w %1,%0" : "=g" (foo) : "g" (CNTR1));
>--
>
>And the inline assembler generates:
>--
>move.w #0F60A,(0FFFE,A6)
>--
>
>This looks OK except that the constant is used as an immediate value.
>
>How do I tell the inline assembler that a constant is to be used as
>an address and not as an immediate value?
>

If I understand the problem correctly, then you want to store the
value foo at the 16 bit I/O register CNTR1. If so then the code should be:

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

Where foo is the input, and *CNTR1 is the output. The previous version
had the address of of the I/O register as the input, and foo as the
output.

I don't have a 68k version of gcc around, but try it and see what it
does for you.

-- 
Peter Barada                             pbarada@wavemark.com
Wizard
WaveMark Technologies, Inc.

"Real men know that you should never attempt to accomplish with words
what you can do with a flame thrower" --Bruce Ferstein

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