1/* 2 * Copyright (c) 2015 ARM Ltd 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. The name of the company may not be used to endorse or promote 14 * products derived from this software without specific prior written 15 * permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <picolibc.h> 30 31#include "arm_asm.h" 32 33 .thumb 34 .syntax unified 35 .global memset 36 .type memset, %function 37 .p2align 1 38memset: 39 .fnstart 40 .cfi_sections .debug_frame 41 .cfi_startproc 42 prologue 4 6 push_ip=HAVE_PAC_LEAF 43 44 lsls r3, r0, #30 45 beq 10f 46 subs r4, r2, #1 47 cmp r2, #0 48 beq 9f 49 lsls r5, r1, #24 50 lsrs r5, r5, #24 51 movs r3, r0 52 movs r6, #3 53 b 2f 541: 55 subs r2, r4, #1 56 cmp r4, #0 57 beq 9f 58 movs r4, r2 592: 60 adds r3, r3, #1 61 subs r2, r3, #1 62 strb r5, [r2] 63 tst r3, r6 64 bne 1b 653: 66 cmp r4, #3 67 bls 7f 68 movs r5, #255 69 ands r5, r1 70 lsls r2, r5, #8 71 orrs r5, r2 72 lsls r2, r5, #16 73 orrs r5, r2 74 cmp r4, #15 75 bls 5f 76 movs r6, r4 77 subs r6, r6, #16 78 lsrs r6, r6, #4 79 adds r6, r6, #1 80 lsls r6, r6, #4 81 movs r2, r3 82 adds r3, r3, r6 834: 84 str r5, [r2] 85 str r5, [r2, #4] 86 str r5, [r2, #8] 87 str r5, [r2, #12] 88 adds r2, r2, #16 89 cmp r3, r2 90 bne 4b 91 movs r2, #15 92 ands r4, r2 93 cmp r4, #3 94 bls 7f 955: 96 subs r6, r4, #4 97 lsrs r6, r6, #2 98 adds r6, r6, #1 99 lsls r6, r6, #2 100 movs r2, r3 101 adds r3, r3, r6 1026: 103 stmia r2!, {r5} 104 cmp r3, r2 105 bne 6b 106 movs r2, #3 107 ands r4, r2 1087: 109 cmp r4, #0 110 beq 9f 111 lsls r1, r1, #24 112 lsrs r1, r1, #24 113 adds r4, r3, r4 1148: 115 strb r1, [r3] 116 adds r3, r3, #1 117 cmp r4, r3 118 bne 8b 1199: 120 .cfi_remember_state 121 epilogue 4 6 push_ip=HAVE_PAC_LEAF 122 .cfi_restore_state 12310: 124 movs r3, r0 125 movs r4, r2 126 b 3b 127 .cfi_endproc 128 .cantunwind 129 .fnend 130 .size memset, . - memset 131