VirtualBox

Changeset 58758 in vbox


Ignore:
Timestamp:
Nov 19, 2015 1:00:30 AM (9 years ago)
Author:
vboxsync
Message:

IPRT: Implemented ASMBitNextClear in assembly.

Location:
trunk/src/VBox/Runtime
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r58757 r58758  
    182182        common/asm/ASMBitFirstClear.asm \
    183183        common/asm/ASMBitFirstSet.asm \
     184        common/asm/ASMBitNextClear.asm \
    184185        common/asm/ASMBitNextSet.asm \
    185186        common/asm/ASMMultU32ByU32DivByU32.asm \
  • trunk/src/VBox/Runtime/common/asm/ASMBitNextClear.asm

    r58757 r58758  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMBitNextSet().
     3; IPRT - ASMBitNextClear().
    44;
    55
     
    3434
    3535;;
    36 ; Finds the first set bit in a bitmap.
     36; Finds the first clear bit in a bitmap.
    3737;
    3838; @returns (32/64:eax, 16:ax+dx)   Index of the first zero bit.
    39 ; @returns (32/64:eax, 16:ax+dx)  -1 if no set bit was found.
     39; @returns (32/64:eax, 16:ax+dx)  -1 if no clear bit was found.
    4040; @param   msc:rcx gcc:rdi pvBitmap    Pointer to the bitmap.
    4141; @param   msc:edx gcc:rsi cBits       The number of bits in the bitmap. Multiple of 32.
     
    4545;          it started out with the ASMBit* API, so that's why we still have it.
    4646;
    47 BEGINPROC_EXPORTED ASMBitNextSet
     47BEGINPROC_EXPORTED ASMBitNextClear
    4848%if ARCH_BITS == 16
    4949        push    bp
     
    8686
    8787%if ARCH_BITS == 16
    88         mov     edx, [es:di]            ; edx = current dword
     88        mov     edx, [es:di]
    8989%else
    90         mov     edx, [xDI]              ; edx = current dword
     90        mov     edx, [xDI]
    9191%endif
     92        not     edx                     ; edx = inverted current dword
    9293        shr     edx, cl                 ; Shift out bits that we have searched.
    9394        jz      .next_dword             ; If zero, nothing to find. Go rep scasd.
    9495        shl     edx, cl                 ; Shift it back so bsf will return the right index.
    9596
    96         bsf     edx, edx                ; edx=index of first set bit
     97        bsf     edx, edx                ; edx=index of first clear bit
    9798
    9899        shl     eax, 3                  ; Turn eax back into a bit offset of the current dword.
     
    139140
    140141        ; Do the scanning.
    141         xor     eax, eax
     142        mov     eax, 0ffffffffh
    142143        repe scasd
    143144        je      .return_failure
     
    147148%if ARCH_BITS == 16
    148149        movzx   edi, di
    149         mov     eax, [es:xDI]
     150        xor     eax, [es:xDI]
    150151%else
    151         mov     eax, [xDI]
     152        xor     eax, [xDI]
    152153%endif
    153154        bsf     eax, eax
     
    170171        mov     eax, 0ffffffffh
    171172        jmp     .return
    172 ENDPROC ASMBitNextSet
     173ENDPROC ASMBitNextClear
    173174
    174175
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette