1/* Copyright (c) 2019  SiFive Inc. All rights reserved.
2
3   This copyrighted material is made available to anyone wishing to use,
4   modify, copy, or redistribute it subject to the terms and conditions
5   of the FreeBSD License.   This program is distributed in the hope that
6   it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7   including the implied warranties of MERCHANTABILITY or FITNESS FOR
8   A PARTICULAR PURPOSE.  A copy of this license is available at
9   http://www.opensource.org/licenses.
10*/
11
12#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
13.section .text.memmove
14.global memmove
15.type	memmove, @function
16memmove:
17  beqz a2, 2f
18
19  mv t1, a0
20  li a3, 1
21  bgtu  a1, a0, 1f
22
23  li a3, -1
24  addi  a4, a2 , -1
25  add t1, t1, a4
26  add a1, a1, a4
27
281:
29  lb t2, 0(a1)
30  sb t2, 0(t1)
31  add   a2, a2, -1
32  add   t1, t1, a3
33  add   a1, a1, a3
34  bnez a2, 1b
35
362:
37  ret
38
39  .size	memmove, .-memmove
40#endif
41