VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/memmove.asm@ 69219

Last change on this file since 69219 was 69219, checked in by vboxsync, 7 years ago

Runtime: scm cleanups

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.3 KB
Line 
1; $Id: memmove.asm 69219 2017-10-24 15:01:30Z vboxsync $
2;; @file
3; IPRT - No-CRT memmove - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2017 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27%include "iprt/asmdefs.mac"
28
29BEGINCODE
30
31;;
32; @param pvDst gcc: rdi msc: rcx x86:[esp+4]
33; @param pvSrc gcc: rsi msc: rdx x86:[esp+8]
34; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
35RT_NOCRT_BEGINPROC memmove
36 ; Prolog.
37%ifdef RT_ARCH_AMD64
38 %ifdef ASM_CALL64_MSC
39 mov r10, rdi ; save
40 mov r11, rsi ; save
41 mov rdi, rcx
42 mov rsi, rdx
43 mov rcx, r8
44 mov rdx, r8
45 %else
46 mov rcx, rdx
47 %endif
48 mov rax, rdi ; save the return value
49%else
50 push edi
51 push esi
52 mov edi, [esp + 04h + 8]
53 mov esi, [esp + 08h + 8]
54 mov ecx, [esp + 0ch + 8]
55 mov edx, ecx
56 mov eax, edi ; save the return value
57%endif
58
59 ;
60 ; Decide which direction to perform the copy in.
61 ;
62%if 1 ; keep it simple for now.
63 cmp xDI, xSI
64 jnb .backward
65
66 ;
67 ; Slow/simple forward copy.
68 ;
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:
83 cld
84%ifdef RT_ARCH_AMD64
85 shr rcx, 3
86 rep movsq
87%else
88 shr ecx, 2
89 rep movsd
90%endif
91
92 ; The remaining bytes.
93%ifdef RT_ARCH_AMD64
94 test dl, 4
95 jz .forward_dont_move_dword
96 movsd
97%endif
98.forward_dont_move_dword:
99 test dl, 2
100 jz .forward_dont_move_word
101 movsw
102.forward_dont_move_word:
103 test dl, 1
104 jz .forward_dont_move_byte
105 movsb
106.forward_dont_move_byte:
107
108%endif ; disabled
109
110 ;
111 ; The epilog.
112 ;
113.epilog:
114%ifdef RT_ARCH_AMD64
115 %ifdef ASM_CALL64_MSC
116 mov rdi, r10
117 mov rsi, r11
118 %endif
119%else
120 pop esi
121 pop edi
122%endif
123 ret
124
125 ;
126 ; Slow/simple backward copy.
127 ;
128ALIGNCODE(16)
129.backward:
130 ;; @todo check if they overlap.
131 lea xDI, [xDI + xCX - 1]
132 lea xSI, [xSI + xCX - 1]
133 std
134 rep movsb
135 cld
136 jmp .epilog
137ENDPROC RT_NOCRT(memmove)
138
Note: See TracBrowser for help on using the repository browser.

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