Re: Count Leading Zeros (cntlzw)



Kostas wrote:
I wanted to use this function -which is part of the PowerPC assembly
language- in a x86 architecture (prefered an Athlon).
This function calculates the leading zeros of a word.
I need this function to be really fast, so i thought to ask the basm group
:)

How should it be best implemented in order to be best optimised?


As others mention that the 80x86 has the BSR.

But you wanted a fast function ;-)

If you are running on a AMD Athlon cpu you are pretty safe with BSR

But some of the intel cpu are pretty bad :-(

From http://www.azillionmonkeys.com/qed/pentopt.html

^^BSF and BSR are the poorest optimized instructions on the PPlain and PMMX

and

from http://www.codecomments.com/A86_Assembler/message203346.html

^^ 486  - fast
^^ Pent - terribly slow
^^ PIII - very fast
^^ P4   - slow

Regards
Lars
.



Relevant Pages

  • Count Leading Zeros (cntlzw)
    ... language- in a x86 architecture (prefered an Athlon). ... This function calculates the leading zeros of a word. ... Prev by Date: ...
    (borland.public.delphi.language.basm)
  • Re: Count Leading Zeros (cntlzw)
    ... Kostas ... > language- in a x86 architecture (prefered an Athlon). ... Prev by Date: ...
    (borland.public.delphi.language.basm)
  • Re: Count Leading Zeros (cntlzw)
    ... language- in a x86 architecture (prefered an Athlon). ... This function calculates the leading zeros of a word. ... mov cx,15 bsr ax,ax sub cx,ax mov ax,cx ...
    (borland.public.delphi.language.basm)
  • Re: Count Leading Zeros (cntlzw)
    ... > language- in a x86 architecture (prefered an Athlon). ... Reverse) functions ... Prev by Date: ...
    (borland.public.delphi.language.basm)