1 | ; $Id: memcpy.asm 81282 2019-10-15 08:20:24Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; IPRT - No-CRT memcpy - 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 |
|
---|
29 | BEGINCODE
|
---|
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
|
---|
35 | %ifdef IN_RING0_DRV_ON_DARWIN
|
---|
36 | global NAME(memcpy):private_extern
|
---|
37 | NAME(memcpy):
|
---|
38 | %else
|
---|
39 | RT_NOCRT_BEGINPROC memcpy
|
---|
40 | %endif
|
---|
41 | cld
|
---|
42 |
|
---|
43 | ; Do the bulk of the work.
|
---|
44 | %ifdef RT_ARCH_AMD64
|
---|
45 | %ifdef ASM_CALL64_MSC
|
---|
46 | mov r10, rdi ; save
|
---|
47 | mov r11, rsi ; save
|
---|
48 | mov rdi, rcx
|
---|
49 | mov rsi, rdx
|
---|
50 | mov rcx, r8
|
---|
51 | mov rdx, r8
|
---|
52 | %else
|
---|
53 | mov rcx, rdx
|
---|
54 | %endif
|
---|
55 | mov rax, rdi ; save the return value
|
---|
56 | shr rcx, 3
|
---|
57 | rep movsq
|
---|
58 | %else
|
---|
59 | push edi
|
---|
60 | push esi
|
---|
61 |
|
---|
62 | %ifdef ASM_CALL32_WATCOM
|
---|
63 | mov edi, eax
|
---|
64 | mov esi, edx
|
---|
65 | mov ecx, ebx
|
---|
66 | mov edx, ebx
|
---|
67 | %else
|
---|
68 | mov ecx, [esp + 0ch + 8]
|
---|
69 | mov edi, [esp + 04h + 8]
|
---|
70 | mov esi, [esp + 08h + 8]
|
---|
71 | mov edx, ecx
|
---|
72 | mov eax, edi ; save the return value
|
---|
73 | %endif
|
---|
74 | shr ecx, 2
|
---|
75 | rep movsd
|
---|
76 | %endif
|
---|
77 |
|
---|
78 | ; The remaining bytes.
|
---|
79 | %ifdef RT_ARCH_AMD64
|
---|
80 | test dl, 4
|
---|
81 | jz .dont_move_dword
|
---|
82 | movsd
|
---|
83 | %endif
|
---|
84 | .dont_move_dword:
|
---|
85 | test dl, 2
|
---|
86 | jz .dont_move_word
|
---|
87 | movsw
|
---|
88 | .dont_move_word:
|
---|
89 | test dl, 1
|
---|
90 | jz .dont_move_byte
|
---|
91 | movsb
|
---|
92 | .dont_move_byte:
|
---|
93 |
|
---|
94 | %ifdef RT_ARCH_AMD64
|
---|
95 | %ifdef ASM_CALL64_MSC
|
---|
96 | mov rdi, r10
|
---|
97 | mov rsi, r11
|
---|
98 | %endif
|
---|
99 | %else
|
---|
100 | pop esi
|
---|
101 | pop edi
|
---|
102 | %endif
|
---|
103 | ret
|
---|
104 | ENDPROC RT_NOCRT(memcpy)
|
---|
105 |
|
---|