VirtualBox

Changeset 7203 in vbox


Ignore:
Timestamp:
Feb 28, 2008 4:00:30 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28513
Message:

Fixed backwards copy, play it safe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/memmove.asm

    r7185 r7203  
    6060        ; Decide which direction to perform the copy in.
    6161        ;
     62%if 1 ; keep it simpe for now.
    6263        cmp     xDI, xSI
    63         jb      .forward
     64        jnb     .backward
    6465
    6566        ;
    66         ; Copy forward.
     67        ; Slow/simple forward copy.
    6768        ;
    68 .forward:
     69        cld
     70        rep movsb
     71        jmp .epilog
     72
     73%else ; disabled - it seems to work, but play safe for now.
     74        ;sub     xAX, xSI
     75        ;jnb     .backward
     76        cmp     xDI, xSI
     77        jnb     .backward
     78
     79        ;
     80        ; Fast forward copy.
     81        ;
     82.fast_forward:
    6983        cld
    7084%ifdef RT_ARCH_AMD64
     
    92106.forward_dont_move_byte:
    93107
     108%endif ; disabled
     109
    94110        ;
    95111        ; The epilog.
     
    107123        ret
    108124
    109 
    110125        ;
    111         ; Copy backward.
     126        ; Slow/simple backward copy.
    112127        ;
    113128ALIGNCODE(16)
    114129.backward:
     130        ;; @todo check if they overlap.
     131        lea     xDI, [xDI + xCX - 1]
     132        lea     xSI, [xSI + xCX - 1]
    115133        std
    116         add     xDI, xCX
    117         add     xSI, xCX
    118 %ifdef RT_ARCH_AMD64
    119         shr     rcx, 3
    120         rep movsq
    121 %else
    122         shr     ecx, 2
    123         rep movsd
    124 %endif
    125 
    126         ; The remaining bytes.
    127 %ifdef RT_ARCH_AMD64
    128         test    dl, 4
    129         jz      .backward_dont_move_dword
    130         movsd
    131 %endif
    132 .backward_dont_move_dword:
    133         test    dl, 2
    134         jz      .backward_dont_move_word
    135         movsw
    136 .backward_dont_move_word:
    137         test    dl, 1
    138         jz      .backward_dont_move_byte
    139         movsb
    140 .backward_dont_move_byte:
    141 
     134        rep movsb
    142135        cld
    143136        jmp .epilog
Note: See TracChangeset for help on using the changeset viewer.

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