Re: Count Leading Zeros (cntlzw)
- From: Lars <lbg_@xxxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 20:17:18 +0200
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?
Thanks in advance Kostas
My proposal
function cntlzw(const x: word): word; asm cmp AX, 0 jnz @@BSF mov AX, 16 ret
@@BSF: mov cx,15 bsr ax,ax sub cx,ax mov ax,cx end;
Regards Lars G .
- References:
- Count Leading Zeros (cntlzw)
- From: Kostas
- Count Leading Zeros (cntlzw)
- Prev by Date: Re: Count Leading Zeros (cntlzw)
- Next by Date: Re: QC Report on Swap Function
- Previous by thread: Re: Count Leading Zeros (cntlzw)
- Next by thread: Re: Count Leading Zeros (cntlzw)
- Index(es):
Relevant Pages
|