question on inline assembly and long long values

Chris Friesen cfriesen at nortel.com
Thu Apr 7 06:01:20 EST 2005


Kumar Gala wrote:
> I'm having a similar need (for a different purpose), this post might be 
> useful:
> 
> http://gcc.gnu.org/ml/gcc/2005-04/msg00283.html

Sweet!  My new code is now shorter *and* more efficient:

static inline unsigned long long getmsr()
{
	unsigned long long val;
         asm volatile( \
                 "mfmsr  %L0               \n\t" \
                 "rldicl %0,%L0,32,32       \n\t" \
                 "rldicl %L0,%L0,0,32        \n\t" \
                 : "=r" (val));
	return val;
}

This results in

unsigned long long a = asdf3();
unsigned long long b = asdf3();

being compiled to

	mfmsr  6
	rldicl 5,6,32,32
	rldicl 6,6,0,32
	
	mfmsr  8
	rldicl 7,8,32,32
	rldicl 8,8,0,32

Which is about as good as it gets...

Thanks!

Chris



More information about the Linuxppc-dev mailing list