1 /* the ti-x embed operation system
3 * it is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * it is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with it; If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>
16 * Copyright (C) 2009, Ruki All rights reserved.
17 * Home: <a href="http://www.xxx.org">http://www.xxx.org</a>
25 /* ////////////////////////////////////////////////////////////
30 /* ////////////////////////////////////////////////////////////
31 * internal implemetion
37 1: subs r2, r2, #4 // 1 do we have enough
38 blt 5f // 1 bytes to align with?
40 strltb r1, [r0], #1 // 1
41 strleb r1, [r0], #1 // 1
42 strb r1, [r0], #1 // 1
43 add r2, r2, r3 // 1 (r2 = r2 - (4 - r3))
45 /* the pointer is now aligned and the length is adjusted. Try doing the
50 TI_ASM_EXPORT(__memset)
51 ands r3, r0, #3 // 1 unaligned?
54 // we know that the pointer in r0 is aligned to a word boundary.
55 orr r1, r1, r1, lsl #8
56 orr r1, r1, r1, lsl #16
61 /* we need an extra register for this loop
62 * - save the return address and use the LR
69 stmgeia r0!, {r1, r3, ip, lr} // 64 bytes at a time.
70 stmgeia r0!, {r1, r3, ip, lr}
71 stmgeia r0!, {r1, r3, ip, lr}
72 stmgeia r0!, {r1, r3, ip, lr}
74 ldmeqfd sp!, {pc} // Now < 64 bytes to go.
76 /* no need to correct the count
77 * we're only testing bits from now on
80 stmneia r0!, {r1, r3, ip, lr}
81 stmneia r0!, {r1, r3, ip, lr}
83 stmneia r0!, {r1, r3, ip, lr}
91 /* when we get here, we've got less than 4 bytes to zero.
92 * We may have an unaligned pointer as well.