VirtualBox

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

Last change on this file since 78398 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.5 KB
Line 
1; $Id: memmove.asm 76553 2019-01-01 01:45:53Z vboxsync $
2;; @file
3; IPRT - No-CRT memmove - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2019 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] wcall: eax
33; @param pvSrc gcc: rsi msc: rdx x86:[esp+8] wcall: edx
34; @param cb gcc: rdx msc: r8 x86:[esp+0ch] wcall: ebx
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 %ifdef ASM_CALL32_WATCOM
53 mov edi, eax
54 mov esi, edx
55 mov ecx, ebx
56 mov edx, ebx
57 %else
58 mov edi, [esp + 04h + 8]
59 mov esi, [esp + 08h + 8]
60 mov ecx, [esp + 0ch + 8]
61 mov edx, ecx
62 mov eax, edi ; save the return value
63 %endif
64%endif
65
66 ;
67 ; Decide which direction to perform the copy in.
68 ;
69%if 1 ; keep it simple for now.
70 cmp xDI, xSI
71 jnb .backward
72
73 ;
74 ; Slow/simple forward copy.
75 ;
76 cld
77 rep movsb
78 jmp .epilog
79
80%else ; disabled - it seems to work, but play safe for now.
81 ;sub xAX, xSI
82 ;jnb .backward
83 cmp xDI, xSI
84 jnb .backward
85
86 ;
87 ; Fast forward copy.
88 ;
89.fast_forward:
90 cld
91%ifdef RT_ARCH_AMD64
92 shr rcx, 3
93 rep movsq
94%else
95 shr ecx, 2
96 rep movsd
97%endif
98
99 ; The remaining bytes.
100%ifdef RT_ARCH_AMD64
101 test dl, 4
102 jz .forward_dont_move_dword
103 movsd
104%endif
105.forward_dont_move_dword:
106 test dl, 2
107 jz .forward_dont_move_word
108 movsw
109.forward_dont_move_word:
110 test dl, 1
111 jz .forward_dont_move_byte
112 movsb
113.forward_dont_move_byte:
114
115%endif ; disabled
116
117 ;
118 ; The epilog.
119 ;
120.epilog:
121%ifdef RT_ARCH_AMD64
122 %ifdef ASM_CALL64_MSC
123 mov rdi, r10
124 mov rsi, r11
125 %endif
126%else
127 pop esi
128 pop edi
129%endif
130 ret
131
132 ;
133 ; Slow/simple backward copy.
134 ;
135ALIGNCODE(16)
136.backward:
137 ;; @todo check if they overlap.
138 lea xDI, [xDI + xCX - 1]
139 lea xSI, [xSI + xCX - 1]
140 std
141 rep movsb
142 cld
143 jmp .epilog
144ENDPROC RT_NOCRT(memmove)
145
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