Changeset 58753 in vbox for trunk/src/VBox/Runtime/common/asm/ASMBitFirstSet.asm
- Timestamp:
- Nov 18, 2015 8:47:23 PM (9 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/asm/ASMBitFirstSet.asm
r58746 r58753 34 34 35 35 ;; 36 ; Finds the first clearbit in a bitmap.36 ; Finds the first set bit in a bitmap. 37 37 ; 38 38 ; @returns (32/64:eax, 16:ax+dx) Index of the first zero bit. 39 ; @returns (32/64:eax, 16:ax+dx) -1 if no clearbit was found.39 ; @returns (32/64:eax, 16:ax+dx) -1 if no set bit was found. 40 40 ; @param msc:rcx gcc:rdi pvBitmap Pointer to the bitmap. 41 41 ; @param msc:edx gcc:rsi cBits The number of bits in the bitmap. Multiple of 32. 42 42 ; 43 BEGINPROC_EXPORTED ASMBitFirst Clear43 BEGINPROC_EXPORTED ASMBitFirstSet 44 44 ; 45 45 ; if (cBits) … … 81 81 shr ecx, 5 ; number of dwords to scan. 82 82 mov xDX, xDI ; xDX = saved pvBitmap 83 mov eax, 0ffffffffh84 repe scasd ; Scan for the first dword with any clear bit.83 xor eax, eax 84 repe scasd ; Scan for the first dword with any bit set. 85 85 je .failed_restore 86 86 … … 89 89 %if ARCH_BITS == 16 90 90 movzx edi, di 91 xoreax, [es:xDI] ; eax = NOT [rdi]91 mov eax, [es:xDI] ; eax = NOT [rdi] 92 92 %else 93 xoreax, [edi] ; eax = NOT [rdi]93 mov eax, [edi] ; eax = NOT [rdi] 94 94 %endif 95 jz .failed_restore ; race paranoia96 95 sub xDI, xDX 97 96 shl edi, 3 ; calc bit offset. 98 97 99 mov ecx, 0ffffffffh100 98 bsf ecx, eax 99 jz .failed_restore ; race paranoia 101 100 add ecx, edi 102 101 mov eax, ecx … … 105 104 pop xDI 106 105 %if ARCH_BITS == 16 106 mov edx, eax 107 shr edx, 16 107 108 leave 108 109 %endif … … 114 115 .failed_restore: 115 116 pop xDI 116 %if ARCH_BITS == 16117 mov edx, eax118 shr edx, 16119 leave120 %endif121 ret122 123 117 .failed: 124 118 %if ARCH_BITS != 16 … … 130 124 %endif 131 125 ret 132 ENDPROC ASMBitFirst Clear126 ENDPROC ASMBitFirstSet 133 127
Note:
See TracChangeset
for help on using the changeset viewer.