Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / device / lib / stm8-large / memcpy.s
blob42e2c6a1e1f684edcc2eb1b9d88466c9bb3a0983
1 ;--------------------------------------------------------------------------
2 ; memcpy.s
4 ; Copyright (C) 2018, Benedikt Freisen
5 ; Copyright (C) 2021, Philipp Klaus Krause
7 ; This library is free software; you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by the
9 ; Free Software Foundation; either version 2, or (at your option) any
10 ; later version.
12 ; This library is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with this library; see the file COPYING. If not, write to the
19 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 ; MA 02110-1301, USA.
22 ; As a special exception, if you link this library with other files,
23 ; some of which are compiled with SDCC, to produce an executable,
24 ; this library does not by itself cause the resulting executable to
25 ; be covered by the GNU General Public License. This exception does
26 ; not however invalidate any other reasons why the executable file
27 ; might be covered by the GNU General Public License.
28 ;--------------------------------------------------------------------------
30 ; This memcpy() implementation has been optimized for speed using 4x loop
31 ; unrolling and index relative addressing.
33 ; void *memcpy(void *dest, const void *src, size_t n);
35 .globl ___memcpy
36 .globl _memcpy
38 .area CODE
40 ___memcpy:
41 _memcpy:
42 pushw x
44 ldw y, (6, sp)
46 srl (8, sp)
47 rrc (9, sp)
48 jrnc n_x0
49 ld a, (y)
50 ld (x), a
51 incw y
52 incw x
53 n_x0:
54 srl (8, sp)
55 rrc (9, sp)
56 jrnc n_00
57 ld a, (y)
58 ld (x), a
59 incw y
60 incw x
61 ld a, (y)
62 ld (x), a
63 incw y
64 incw x
65 n_00:
66 tnz (9, sp)
67 jrne loop_ent
68 dec (8, sp)
69 jrmi end
70 jra loop_ent
72 loop:
73 addw y, #4
74 addw x, #4
75 loop_ent:
76 ld a, (y)
77 ld (x), a
78 ld a, (1, y)
79 ld (1, x), a
80 ld a, (2, y)
81 ld (2, x), a
82 ld a, (3, y)
83 ld (3, x), a
85 dec (9, sp)
86 jrne loop
87 dec (8, sp)
88 jrpl loop
90 end:
91 popw x
92 retf