blob: 800898a2d2e326e3e4ea503adb3d5cd60d78eb93 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m32r/lib/memcpy.S
3 *
4 * Copyright (C) 2001 Hiroyuki Kondo, and Hirokazu Takata
5 * Copyright (C) 2004 Hirokazu Takata
6 *
7 * void *memcopy(void *dst, const void *src, int n);
8 *
9 * dst: r0
10 * src: r1
11 * n : r2
12 */
13/* $Id$ */
14
15
16 .text
17#include <linux/config.h>
18#include <linux/linkage.h>
19#include <asm/assembler.h>
20
21#ifdef CONFIG_ISA_DUAL_ISSUE
22
23 .text
24ENTRY(memcpy)
25memcopy:
26 mv r4, r0 || mv r7, r0
27 or r7, r1 || cmpz r2
28 jc r14 || cmpeq r0, r1 ; return if r2=0
29 jc r14 ; return if r0=r1
30
31 and3 r7, r7, #3
32 bnez r7, byte_copy
33 srl3 r3, r2, #2
34 and3 r2, r2, #3
35 beqz r3, byte_copy
36 addi r4, #-4
37word_copy:
38 ld r7, @r1+ || addi r3, #-1
39 st r7, @+r4 || cmpz r2
40 bnez r3, word_copy
41 addi r4, #4 || jc r14 ; return if r2=0
42#if defined(CONFIG_ISA_M32R2)
43byte_copy:
44 ldb r7, @r1 || addi r1, #1
45 addi r2, #-1 || stb r7, @r4+
46 bnez r2, byte_copy
47#elif defined(CONFIG_ISA_M32R)
48byte_copy:
49 ldb r7, @r1 || addi r1, #1
50 addi r2, #-1 || stb r7, @r4
51 addi r4, #1
52 bnez r2, byte_copy
53#else
54#error unknown isa configuration
55#endif
56end_memcopy:
57 jmp r14
58
59#else /* not CONFIG_ISA_DUAL_ISSUE */
60
61 .text
62ENTRY(memcpy)
63memcopy:
64 mv r4, r0
65 mv r7, r0
66 or r7, r1
67 beq r0, r1, end_memcopy
68 beqz r2, end_memcopy
69
70 and3 r7, r7, #3
71 bnez r7, byte_copy
72 srl3 r3, r2, #2
73 and3 r2, r2, #3
74 beqz r3, byte_copy
75 addi r4, #-4
76word_copy:
77 ld r7, @r1+
78 addi r3, #-1
79 st r7, @+r4
80 bnez r3, word_copy
81 beqz r2, end_memcopy
82 addi r4, #4
83byte_copy:
84 ldb r7, @r1
85 addi r1, #1
86 addi r2, #-1
87 stb r7, @r4
88 addi r4, #1
89 bnez r2, byte_copy
90end_memcopy:
91 jmp r14
92
93#endif /* not CONFIG_ISA_DUAL_ISSUE */
94
95 .end