blob: 0c9a51fcdea1819c1d21503384f03c5f9879bac5 [file] [log] [blame]
Yoshinori Satoa71a29d2015-01-28 02:48:15 +09001;;; memcpy.S
2
3#include <asm/linkage.h>
4
5#if defined(CONFIG_CPU_H8300H)
6 .h8300h
7#endif
8#if defined(CONFIG_CPU_H8S)
9 .h8300s
10#endif
11 .text
12.global memcpy
13
14;;; void *memcpy(void *to, void *from, size_t n)
15memcpy:
16 mov.l er2,er2
17 bne 1f
18 rts
191:
20 ;; address check
21 bld #0,r0l
22 bxor #0,r1l
23 bcs 4f
24 mov.l er4,@-sp
25 mov.l er0,@-sp
26 btst #0,r0l
27 beq 1f
28 ;; (aligned even) odd address
29 mov.b @er1,r3l
30 mov.b r3l,@er0
31 adds #1,er1
32 adds #1,er0
33 dec.l #1,er2
34 beq 3f
351:
36 ;; n < sizeof(unsigned long) check
37 sub.l er4,er4
38 adds #4,er4 ; loop count check value
39 cmp.l er4,er2
40 blo 2f
41 ;; unsigned long copy
421:
43 mov.l @er1,er3
44 mov.l er3,@er0
45 adds #4,er0
46 adds #4,er1
47 subs #4,er2
48 cmp.l er4,er2
49 bcc 1b
50 ;; rest
512:
52 mov.l er2,er2
53 beq 3f
541:
55 mov.b @er1,r3l
56 mov.b r3l,@er0
57 adds #1,er1
58 adds #1,er0
59 dec.l #1,er2
60 bne 1b
613:
62 mov.l @sp+,er0
63 mov.l @sp+,er4
64 rts
65
66 ;; odd <- even / even <- odd
674:
68 mov.l er4,er3
69 mov.l er2,er4
70 mov.l er5,er2
71 mov.l er1,er5
72 mov.l er6,er1
73 mov.l er0,er6
741:
75 eepmov.w
76 mov.w r4,r4
77 bne 1b
78 dec.w #1,e4
79 bpl 1b
80 mov.l er1,er6
81 mov.l er2,er5
82 mov.l er3,er4
83 rts
84
85 .end