From: Scott Wood <scottwood@freescale.com>
To: Kevin Diggs <kevdig@hypersurf.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: inline assembly
Date: Wed, 04 Jun 2008 14:45:04 -0500 [thread overview]
Message-ID: <4846F0C0.80808@freescale.com> (raw)
In-Reply-To: <4846EEAE.3000908@hypersurf.com>
Kevin Diggs wrote:
> Hi,
>
> When doing inline assembly, is there a way to get the compiler to
> assign "extra" (one not specified for inputs and outputs) registers? In
> the following:
>
> __asm__ __volatile__ (
> "addi 5,%1,-1\n"
> "andc 5,%1,5\n"
> "cntlzw 5,5\n"
> "subfic %0,5,31":
> "=r"(j):
> "r"(i)
> );
>
> Can I get the compiler to choose a register for r5?
Yes, like this:
int tmp;
asm volatile("addi %1, %2, -1;"
"andc %1, %2, %1;"
"cntlzw %1, %1;"
"subfic %0, %1, 31" : "=r" (j), "=&r" (tmp) : "r" (i));
However, it'd be better to let the compiler do more, by just using the
existing cntlzw() function.
-Scott
next prev parent reply other threads:[~2008-06-04 19:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 19:36 inline assembly Kevin Diggs
2008-06-04 19:45 ` Scott Wood [this message]
2008-06-05 10:44 ` David Howells
2008-06-05 16:52 ` Scott Wood
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=4846F0C0.80808@freescale.com \
--to=scottwood@freescale.com \
--cc=kevdig@hypersurf.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.