Faster TlsAlloc() or zero_bit_scan

Dietrich Teickner dietrich_teickner at
Thu Feb 10 11:59:21 CST 2005


I have a suggestion for a faster implementation of the zero_bit_scan in
RtlFindClearBits	[NTDLL.@]
(rlbitmap.c) for e.g. TlsAlloc()
The main is the usage of the instruction 'bsf  eax, eax'

This I have implemented in the new experimental odinxp-tree for finding 
the first zero_bit in the first 'bytecount' bytes of the bitmap addr.


	public _search_zero_bit
;int CDECL search_zero_bit(int bytecount, void *addr);
_search_zero_bit proc near
     push esi
     push edx

     mov  esi, [esp+16]
     mov  edx, [esp+12]
     inc  edx
     add  esi, 4
     mov  eax, -1
     dec  edx
;not found
     jz   short found
     xor  eax, dword ptr [esi - 4]
     jz   loop
     bsf  eax, eax
     jz   short loop
     sub  esi, 4
     sub  esi, [esp+16]
     shl  esi, 5-2
     add  eax, esi

     pop  edx
     pop  esi
_search_zero_bit endp

More information about the wine-devel mailing list