~ubuntu-branches/ubuntu/utopic/avr-libc/utopic

« back to all changes in this revision

Viewing changes to libc/pmstring/memcpy_P.S

  • Committer: Package Import Robot
  • Author(s): Hakan Ardo
  • Date: 2014-06-03 14:25:22 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20140603142522-76ia7366969f7jc2
Tags: 1:1.8.0+Atmel3.4.4-1
* New upstream release from Atmel-AVR-GNU-Toolchain v3.4.4
  (http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-
  Toolchain/3.4.4/) (closes: #740391, #739953, #695514, #719635)
* Moved manpages to the 3avr section of /usr/share/man
* Added avr-man manpage (closes: #733939)
* Added build-arch and build-indep targets
* Moved build to binary-indep target
* Increased standards version to 3.9.5
* Added ${misc:Depends} dependency
* Applied upstream fix to make pgmspace.h ansi compatible (closes:
  #675759)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002, 2005, 2006, 2007 Marek Michalkiewicz
2
 
   All rights reserved.
3
 
 
4
 
   Redistribution and use in source and binary forms, with or without
5
 
   modification, are permitted provided that the following conditions are met:
6
 
 
7
 
   * Redistributions of source code must retain the above copyright
8
 
     notice, this list of conditions and the following disclaimer.
9
 
   * Redistributions in binary form must reproduce the above copyright
10
 
     notice, this list of conditions and the following disclaimer in
11
 
     the documentation and/or other materials provided with the
12
 
     distribution.
13
 
   * Neither the name of the copyright holders nor the names of
14
 
     contributors may be used to endorse or promote products derived
15
 
     from this software without specific prior written permission.
16
 
 
17
 
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
 
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 
  POSSIBILITY OF SUCH DAMAGE. */
28
 
 
29
 
/* $Id: memcpy_P.S 2191 2010-11-05 13:45:57Z arcanum $ */
30
 
 
31
 
/** \file */
32
 
/** \ingroup avr_pgmspace
33
 
    \fn void *memcpy_P(void *dest, PGM_VOID_P src, size_t n)
34
 
 
35
 
    The memcpy_P() function is similar to memcpy(), except the src string
36
 
    resides in program space.
37
 
 
38
 
    \returns The memcpy_P() function returns a pointer to dest.  */
39
 
 
40
 
 
41
 
#if !defined(__AVR_TINY__)
42
 
 
43
 
#if !defined(__DOXYGEN__)
44
 
 
45
 
#include "macros.inc"
46
 
 
47
 
#define dest_hi r25
48
 
#define dest_lo r24
49
 
#define src_hi r23
50
 
#define src_lo r22
51
 
#define len_hi r21
52
 
#define len_lo r20
53
 
 
54
 
        ASSEMBLY_CLIB_SECTION
55
 
        .global _U(memcpy_P)
56
 
        .type   _U(memcpy_P), @function
57
 
_U(memcpy_P):
58
 
        X_movw  ZL, src_lo
59
 
        X_movw  XL, dest_lo
60
 
#if OPTIMIZE_SPEED
61
 
; 17 words, (14 + len * 9 - (len & 1)) cycles
62
 
        sbrs    len_lo, 0
63
 
        rjmp    .L_memcpy_P_start
64
 
        rjmp    .L_memcpy_P_odd
65
 
.L_memcpy_P_loop:
66
 
        X_lpm   r0, Z+
67
 
        st      X+, r0
68
 
.L_memcpy_P_odd:
69
 
        X_lpm   r0, Z+
70
 
        st      X+, r0
71
 
.L_memcpy_P_start:
72
 
        subi    len_lo, lo8(2)
73
 
        sbci    len_hi, hi8(2)
74
 
#else
75
 
; 12 words, (13 + len * 11) cycles
76
 
        rjmp    .L_memcpy_P_start
77
 
.L_memcpy_P_loop:
78
 
        X_lpm   r0, Z+
79
 
        st      X+, r0
80
 
.L_memcpy_P_start:
81
 
        subi    len_lo, lo8(1)
82
 
        sbci    len_hi, hi8(1)
83
 
#endif
84
 
        brcc    .L_memcpy_P_loop
85
 
; return dest (unchanged)
86
 
        ret
87
 
.L_memcpy_P_end:
88
 
        .size   _U(memcpy_P), .L_memcpy_P_end - _U(memcpy_P)
89
 
 
90
 
#endif /* not __DOXYGEN__ */
91
 
 
92
 
#endif /* !defined(__AVR_TINY__) */