linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Paubert <paubert@iram.es>
To: Chris Friesen <cfriesen@nortel.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: question on inline assembly and long long values
Date: Wed, 6 Apr 2005 23:18:43 +0200	[thread overview]
Message-ID: <20050406211843.GA2737@iram.es> (raw)
In-Reply-To: <42544010.4020105@nortel.com>

On Wed, Apr 06, 2005 at 02:01:20PM -0600, Chris Friesen wrote:
> 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

If you are running in 32 bit mode, you don't need
to clear the upper half of %L0. The architecture is 
designed so that pure 32 bit code runs unmodified despite
the fact that you can access the upper 32 bits using
64 bit instructions.

	Regards,
	Gabriel

  reply	other threads:[~2005-04-06 21:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06 18:26 question on inline assembly and long long values Chris Friesen
2005-04-06 19:16 ` Kumar Gala
2005-04-06 20:01   ` Chris Friesen
2005-04-06 21:18     ` Gabriel Paubert [this message]
2005-04-06 21:37       ` Chris Friesen
2005-04-06 23:19 ` Benjamin Herrenschmidt
2005-04-06 23:30   ` Chris Friesen
2005-04-06 23:49     ` Benjamin Herrenschmidt
2005-04-06 23:56       ` Chris Friesen
2005-04-06 23:57         ` Benjamin Herrenschmidt
2005-04-07  0:09           ` Chris Friesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050406211843.GA2737@iram.es \
    --to=paubert@iram.es \
    --cc=cfriesen@nortel.com \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).