[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Assembly constraints in words
From: |
Theodore A. Roth |
Subject: |
Re: [avr-gcc-list] Assembly constraints in words |
Date: |
Tue, 20 Aug 2002 15:36:38 -0700 (PDT) |
Hi,
The information you want is available in two places:
The gcc manual:
http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Extended%20Asm
The inline asm cookbook:
http://freesoftware.fsf.org/download/avr-libc/doc/avr-libc-user-manual/inline_asm.html
I've just gone through the inline asm cookbook and fixed a bunch of
grammatical errors but haven't even made up a patch yet. ;-)
Now for you question, this _might_ work:
#define __LPM_enhanced_16__(addr) ({ \
unsigned short __addr16 = (unsigned short)(addr); \
unsigned short __result16; \
__asm__ ( \
"lpm %A0, Z+" \
"lpm %B0, Z" \
: "=r" (__result16) \
: "z" (__addr16) \
); \
__result16; \
})
I haven't tested this so it could be utter crap. Iffen I made a mistake,
could some kind soul correct me? ;-)
Ted Roth
On Tue, 20 Aug 2002, Svein E. Seldal 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?
:)
:) Svein
:)
:) avr-gcc-list at http://avr1.org
:)
avr-gcc-list at http://avr1.org