Re: Fast computation of parity
From: Alexis Machado (alexis.machado_at_task.com.br)
Date: 12/31/03
- Next message: Mok-Kong Shen: "Re: Fast computation of parity"
- Previous message: Tom St Denis: "Re: Cipher whitenoise, David Wagner etc."
- In reply to: Mok-Kong Shen: "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: Tue, 30 Dec 2003 22:15:58 -0200
"Mok-Kong Shen" <mok-kong.shen@t-online.de> escreveu na mensagem
news:3FF2064E.C352FF6B@t-online.de...
>
> /* 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 ... */
--- Alexis
- Next message: Mok-Kong Shen: "Re: Fast computation of parity"
- Previous message: Tom St Denis: "Re: Cipher whitenoise, David Wagner etc."
- In reply to: Mok-Kong Shen: "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
|
|