OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [m68k/] [memcpy.S] - Blame information for rev 855

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* a-memcpy.s -- memcpy, optimised for m68k asm
2
 *
3
 * Copyright (c) 2007 mocom software GmbH & Co KG)
4
 *
5
 * The authors hereby grant permission to use, copy, modify, distribute,
6
 * and license this software and its documentation for any purpose, provided
7
 * that existing copyright notices are retained in all copies and that this
8
 * notice is included verbatim in any distributions. No written agreement,
9
 * license, or royalty fee is required for any of the authorized uses.
10
 * Modifications to this software may be copyrighted by their authors
11
 * and need not follow the licensing terms described here, provided that
12
 * the new terms are clearly indicated on the first page of each file where
13
 * they apply.
14
 */
15
 
16
#include "m68kasm.h"
17
 
18
        .text
19
        .align  4
20
 
21
        .globl  SYM(memcpy)
22
        .type   SYM(memcpy), @function
23
 
24
/*   memcpy, optimised
25
 *
26
 *   strategy:
27
 *       - no argument testing (the original memcpy from the GNU lib does
28
 *         no checking either)
29
 *       - make sure the destination pointer (the write pointer) is long word
30
 *         aligned. This is the best you can do, because writing to unaligned
31
 *         addresses can be the most costfull thing you could do.
32
 *       - Once you have figured that out, we do a little loop unrolling
33
 *         to further improve speed.
34
 */
35
 
36
SYM(memcpy):
37
        move.l  4(sp),a0        | dest ptr
38
        move.l  8(sp),a1        | src ptr
39
        move.l  12(sp),d1       | len
40
        cmp.l   #8,d1           | if fewer than 8 bytes to transfer,
41
        blo     .Lresidue       | do not optimise
42
 
43
        /* align dest */
44
        move.l  a0,d0           | copy of dest
45
        neg.l   d0
46
        and.l   #3,d0           | look for the lower two only
47
        beq     2f              | is aligned?
48
        sub.l   d0,d1
49
        lsr.l   #1,d0           | word align needed?
50
        bcc     1f
51
        move.b  (a1)+,(a0)+
52
1:
53
        lsr.l   #1,d0           | long align needed?
54
        bcc     2f
55
        move.w  (a1)+,(a0)+
56
2:
57
 
58
        /* long word transfers */
59
        move.l  d1,d0
60
        and.l   #3,d1           | byte residue
61
        lsr.l   #3,d0
62
        bcc     1f              | carry set for 4-byte residue
63
        move.l  (a1)+,(a0)+
64
1:
65
        lsr.l   #1,d0           | number of 16-byte transfers
66
        bcc     .Lcopy          | carry set for 8-byte residue
67
        bra     .Lcopy8
68
 
69
1:
70
        move.l  (a1)+,(a0)+
71
        move.l  (a1)+,(a0)+
72
.Lcopy8:
73
        move.l  (a1)+,(a0)+
74
        move.l  (a1)+,(a0)+
75
.Lcopy:
76
#if !defined (__mcoldfire__)
77
        dbra    d0,1b
78
        sub.l   #0x10000,d0
79
#else
80
        subq.l  #1,d0
81
#endif
82
        bpl     1b
83
        bra     .Lresidue
84
 
85
1:
86
        move.b  (a1)+,(a0)+     | move residue bytes
87
 
88
.Lresidue:
89
#if !defined (__mcoldfire__)
90
        dbra    d1,1b           | loop until done
91
#else
92
        subq.l  #1,d1
93
        bpl     1b
94
#endif
95
        move.l  4(sp),d0        | return value
96
        rts

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.