VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/mempcpy.asm@ 96563

Last change on this file since 96563 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.0 KB
Line 
1; $Id: mempcpy.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; IPRT - No-CRT mempcpy - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2022 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37%include "iprt/asmdefs.mac"
38
39BEGINCODE
40
41;;
42; @param pvDst gcc: rdi msc: rcx x86:[esp+4] wcall: eax
43; @param pvSrc gcc: rsi msc: rdx x86:[esp+8] wcall: edx
44; @param cb gcc: rdx msc: r8 x86:[esp+0ch] wcall: ebx
45RT_NOCRT_BEGINPROC mempcpy
46 cld ; paranoia
47
48 ; Do the bulk of the work.
49%ifdef RT_ARCH_AMD64
50 %ifdef ASM_CALL64_MSC
51 mov r10, rdi ; save
52 mov r11, rsi ; save
53 mov rdi, rcx
54 mov rsi, rdx
55 mov rcx, r8
56 mov rdx, r8
57 %else
58 mov rcx, rdx
59 %endif
60 shr rcx, 3
61 rep movsq
62%else
63 %ifdef ASM_CALL32_WATCOM
64 xchg eax, edi ; saving edi in eax and loading it
65 push esi
66 mov esi, edx
67 mov ecx, ebx
68 mov edx, ebx
69 %else
70 mov eax, edi ; saving edi in eax
71 push esi
72 mov ecx, [esp + 0ch + 4]
73 mov edi, [esp + 04h + 4]
74 mov esi, [esp + 08h + 4]
75 mov edx, ecx
76 %endif
77 shr ecx, 2
78 rep movsd
79%endif
80
81 ; The remaining bytes.
82%ifdef RT_ARCH_AMD64
83 test dl, 4
84 jz .dont_move_dword
85 movsd
86%endif
87.dont_move_dword:
88 test dl, 2
89 jz .dont_move_word
90 movsw
91.dont_move_word:
92 test dl, 1
93 jz .dont_move_byte
94 movsb
95.dont_move_byte:
96
97 ; restore & return
98%ifdef RT_ARCH_AMD64
99 mov rax, rdi
100 %ifdef ASM_CALL64_MSC
101 mov rsi, r11
102 mov rdi, r10
103 %endif
104%else
105 pop esi
106 xchg eax, edi
107%endif
108 ret
109ENDPROC RT_NOCRT(mempcpy)
110
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