[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Assembly constraints in words

From: John Devereux
Subject: Re: [avr-gcc-list] Assembly constraints in words
Date: Wed, 21 Aug 2002 10:29:07 +0100
User-agent: Mutt/1.4i

* Svein E. Seldal (address@hidden) wrote:
> Hello,
> I want to create an word LPM that is based on the one found in avr-libc, 
> only that this new one reads out a complete word, not just a single 
> byte. How do I constuct the asm constraint? I want to do the following:
>     __asm__ (
>         "lpm %0, Z+" "\n"
>         "lpm %0+1, Z" "\n"
>         : "=e" (__result16)
>         : "z" (__addr16)
>         : "z"
>     );
> where i want "%0" to be one of the word registers (but not Z, of course) 
> and i want "%0+1" to be this word register +1. I can easily pin it down 
> to use a specific register pair, but I would prefer that gcc still can 
> select what register to use. Can anyone tell me how, please?
> PS! Also note that the asm clobbers the z register. Is there a better 
> way to specify that z is input *and* is clobbered?

Well, here's something I did for 32 bit words that you could probably adapt

// this macro reads a 32 bit long constant from program memory (lower 64k only)
static inline UINT32 PGM_LDL( UINT32  * address )
  UINT32 result;
  asm volatile( "lpm %A0,Z+" "\n\t"
                "lpm %B0,Z+" "\n\t"
                "lpm %C0,Z+" "\n\t"
                "lpm %D0,Z+" "\n\t"
                : "=r" (result) 
                : "z" (address) );
  return result;

John Devereux
avr-gcc-list at http://avr1.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]