Re: Fast computation of parity
From: Mok-Kong Shen (mok-kong.shen_at_t-online.de)
Date: 12/31/03
- Next message: Michael Amling: "Re: Q: Fast computation of parity"
- Previous message: Alexis Machado: "Re: Fast computation of parity"
- In reply to: Alexis Machado: "Re: Fast computation of parity"
- Next in thread: Mok-Kong Shen: "Re: Fast computation of parity"
- Reply: Mok-Kong Shen: "Re: Fast computation of parity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 31 Dec 2003 02:02:06 +0100
Alexis Machado wrote:
>
> "Mok-Kong Shen" <mok-kong.shen@t-online.de> wrote:
> >
> > /* returns 0 if even parity, else 1 */
> > int Parityasm(unsigned int w)
> > { int p;
> >
> > __asm
> > {
> > mov eax,w
> > mov ebx,eax
> > shr ebx,16
> > xor eax,ebx
> > mov ebx,eax
> > shr ebx,8
> > xor eax,ebx
> > jp pr
> > mov p,1
> > jmp ee
> > pr:
> > mov p,0
> > ee:
> >
> > }
> >
> > return p;
> > }
>
> An alternative :
>
> MOV EAX, w
> MOV EBX, EAX
> BSWAP EAX
> XOR EAX, EBX
> XOR AL, AH
> SETPO AL /* AL=1 if parity is odd, AL=0 otherwise */
> AND EAX, 1 /* return EAX ... */
I tried it with VC++. It's slower. (BTW, I don't
yet know how to run under gcc a group of asm statements
(grouped by {} and with labels within it as is my code
above) and should appreciate help.)
M. K. Shen
- Next message: Michael Amling: "Re: Q: Fast computation of parity"
- Previous message: Alexis Machado: "Re: Fast computation of parity"
- In reply to: Alexis Machado: "Re: Fast computation of parity"
- Next in thread: Mok-Kong Shen: "Re: Fast computation of parity"
- Reply: Mok-Kong Shen: "Re: Fast computation of parity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|