source: bootcd/isolinux/syslinux-6.03/com32/lib/memcpy.S @ 26ffad7

Last change on this file since 26ffad7 was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[e16e8f2]1/* ----------------------------------------------------------------------- *
2 *
3 *   Copyright 2008 H. Peter Anvin - All Rights Reserved
4 *
5 *   Permission is hereby granted, free of charge, to any person
6 *   obtaining a copy of this software and associated documentation
7 *   files (the "Software"), to deal in the Software without
8 *   restriction, including without limitation the rights to use,
9 *   copy, modify, merge, publish, distribute, sublicense, and/or
10 *   sell copies of the Software, and to permit persons to whom
11 *   the Software is furnished to do so, subject to the following
12 *   conditions:
13 *
14 *   The above copyright notice and this permission notice shall
15 *   be included in all copies or substantial portions of the Software.
16 *
17 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 *   OTHER DEALINGS IN THE SOFTWARE.
25 *
26 * ----------------------------------------------------------------------- */
27
28/*
29 * memcpy.S
30 *
31 * Reasonably efficient memcpy, using aligned transfers at least
32 * for the destination operand.
33 */
34
35        .text
36        .globl  memcpy
37        .type   memcpy, @function
38memcpy:
39        movl    0xc(%esp),%ecx
40        movl    0x8(%esp),%edx
41        movl    0x4(%esp),%eax
42
43        jecxz   1f
44
45        pushl   %esi
46        pushl   %edi
47        pushl   %eax            /* Return value */
48
49        movl    %eax,%edi
50        movl    %edx,%esi
51
52        /* Initial alignment */
53        movl    %edi,%edx
54        shrl    $1,%edx
55        jnc     11f
56        movsb
57        decl    %ecx
5811:
59        movb    %cl,%al
60        cmpl    $2,%ecx
61        jb      13f
62
63        shrl    $1,%edx
64        jnc     12f
65        movsw
66        subl    $2,%ecx
6712:
68        /* Bulk transfer */
69        movb    %cl,%al
70        shrl    $2,%ecx
71        rep; movsl
72
73        /* Final alignment */
74        testb   $2,%al
75        jz      14f
76        movsw
7713:
7814:
79        testb   $1,%al
80        jz      15f
81        movsb
8215:
83
84        popl    %eax            /* Return value */
85        popl    %edi
86        popl    %esi
871:
88        ret
89
90        .size   memcpy, .-memcpy
Note: See TracBrowser for help on using the repository browser.