summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-07-25 11:16:03 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-07-25 11:16:03 +0000
commit5a0cb68e43eacc98d275baef08296f154f3ae6dd (patch)
tree07e93ecd803fc76b2605d0610a5c19d584d13623 /firmware/target/arm
parent9051afa8a061152941ed4cf99e0ceb9bc4a3caf1 (diff)
downloadrockbox-5a0cb68e43eacc98d275baef08296f154f3ae6dd.tar.gz
rockbox-5a0cb68e43eacc98d275baef08296f154f3ae6dd.zip
Moved some assembly optimizations to the target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10318 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rwxr-xr-xfirmware/target/arm/memset-arm.S96
1 files changed, 96 insertions, 0 deletions
diff --git a/firmware/target/arm/memset-arm.S b/firmware/target/arm/memset-arm.S
new file mode 100755
index 0000000000..b3faafcb37
--- /dev/null
+++ b/firmware/target/arm/memset-arm.S
@@ -0,0 +1,96 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21 .section .icode,"ax",%progbits
22
23 .align 2
24
25/* The following code is based on code found in Linux kernel version 2.6.15.3
26 * linux/arch/arm/lib/memset.S
27 *
28 * Copyright (C) 1995-2000 Russell King
29 */
30
31/* This code will align a pointer for memset, if needed */
321: cmp r2, #4 @ 1 do we have enough
33 blt 5f @ 1 bytes to align with?
34 cmp r3, #2 @ 1
35 strgtb r1, [r0, #-1]! @ 1
36 strgeb r1, [r0, #-1]! @ 1
37 strb r1, [r0, #-1]! @ 1
38 sub r2, r2, r3 @ 1 r2 = r2 - r3
39 b 2f
40
41 .global memset
42 .type memset,%function
43memset:
44 add r0, r0, r2 @ we'll write backwards in memory
45 ands r3, r0, #3 @ 1 unaligned?
46 bne 1b @ 1
472:
48/*
49 * we know that the pointer in r0 is aligned to a word boundary.
50 */
51 orr r1, r1, r1, lsl #8
52 orr r1, r1, r1, lsl #16
53 mov r3, r1
54 cmp r2, #16
55 blt 5f
56/*
57 * We need an extra register for this loop - save the return address and
58 * use the LR
59 */
60 str lr, [sp, #-4]!
61 mov ip, r1
62 mov lr, r1
63
643: subs r2, r2, #64
65 stmgedb r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
66 stmgedb r0!, {r1, r3, ip, lr}
67 stmgedb r0!, {r1, r3, ip, lr}
68 stmgedb r0!, {r1, r3, ip, lr}
69 bgt 3b
70 ldmeqfd sp!, {pc} @ Now <64 bytes to go.
71/*
72 * No need to correct the count; we're only testing bits from now on
73 */
74 tst r2, #32
75 stmnedb r0!, {r1, r3, ip, lr}
76 stmnedb r0!, {r1, r3, ip, lr}
77 tst r2, #16
78 stmnedb r0!, {r1, r3, ip, lr}
79 ldr lr, [sp], #4
80
815: tst r2, #8
82 stmnedb r0!, {r1, r3}
83 tst r2, #4
84 strne r1, [r0, #-4]!
85/*
86 * When we get here, we've got less than 4 bytes to zero. We
87 * may have an unaligned pointer as well.
88 */
896: tst r2, #2
90 strneb r1, [r0, #-1]!
91 strneb r1, [r0, #-1]!
92 tst r2, #1
93 strneb r1, [r0, #-1]!
94 mov pc, lr
95end:
96 .size memset,.end-memset