This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bug report (reverse_bits asm)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: bug report (reverse_bits asm)
- From: Etienne LORRAIN <etienne_lorrain at yahoo dot fr>
- Date: Mon, 17 Jan 2000 11:17:38 +0100 (CET)
- Reply-To: etienne dot lorrain at ibm dot net
Zack Weinberg wrote:
> asm ("decl %2
> rev1:
> rcrl $1,%3
> rcll $1,%0
> loop rev1" : "=r" (res) : "0" (res), "c" (len), "d" (code));
>
> Two additional notes: you should use a 'local label', so you can
> inline this function safely, and you should let the compiler do as
> much of the register allocation as possible. The only instruction
> that cares which register something's in is 'loop', so:
Just a tip: use the %= feature:
asm ("decl %2
.L%=rev1:
rcrl $1,%3
rcll $1,%0
loop .L%=rev1"
: "=r" (res) : "0" (res), "c" (len), "d" (code));
So then you can declare the function:
static inline unsigned reverse_bits(unsigned value, int len)
{
}
And do not need the __fastcall, i.e. regparm(3).
I would use a byte translation array for such a task,
if I had some speed concern.
Hope that helps,
Etienne.
___________________________________________________________
Do You Yahoo!?
Achetez, vendez! À votre prix! Sur http://encheres.yahoo.fr