1/* Set a block of memory to some byte value. 2 For SPARC v7. 3 Copyright (C) 1996-2021 Free Software Foundation, Inc. 4 This file is part of the GNU C Library. 5 6 The GNU C Library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 The GNU C Library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with the GNU C Library; if not, see 18 <https://www.gnu.org/licenses/>. */ 19 20#include <sysdep.h> 21 22 /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */ 23#define ZERO_BIG_BLOCK(base, offset, source) \ 24 std source, [base + offset + 0x00]; \ 25 std source, [base + offset + 0x08]; \ 26 std source, [base + offset + 0x10]; \ 27 std source, [base + offset + 0x18]; \ 28 std source, [base + offset + 0x20]; \ 29 std source, [base + offset + 0x28]; \ 30 std source, [base + offset + 0x30]; \ 31 std source, [base + offset + 0x38]; 32 33#define ZERO_LAST_BLOCKS(base, offset, source) \ 34 std source, [base - offset - 0x38]; \ 35 std source, [base - offset - 0x30]; \ 36 std source, [base - offset - 0x28]; \ 37 std source, [base - offset - 0x20]; \ 38 std source, [base - offset - 0x18]; \ 39 std source, [base - offset - 0x10]; \ 40 std source, [base - offset - 0x08]; \ 41 std source, [base - offset - 0x00]; 42 43 .text 44 .align 4 45ENTRY(__bzero) 46 b 1f 47 mov %g0, %g3 48 493: cmp %o2, 3 50 be 2f 51 stb %g3, [%o0] 52 53 cmp %o2, 2 54 be 2f 55 stb %g3, [%o0 + 0x01] 56 57 stb %g3, [%o0 + 0x02] 582: sub %o2, 4, %o2 59 add %o1, %o2, %o1 60 b 4f 61 sub %o0, %o2, %o0 62END(__bzero) 63 64ENTRY(memset) 65 and %o1, 0xff, %g3 66 sll %g3, 8, %g2 67 or %g3, %g2, %g3 68 sll %g3, 16, %g2 69 or %g3, %g2, %g3 70 orcc %o2, %g0, %o1 711: cmp %o1, 7 72 bleu 7f 73 mov %o0, %g1 74 75 andcc %o0, 3, %o2 76 bne 3b 774: andcc %o0, 4, %g0 78 79 be 2f 80 mov %g3, %g2 81 82 st %g3, [%o0] 83 sub %o1, 4, %o1 84 add %o0, 4, %o0 852: andcc %o1, 0xffffff80, %o3 86 be 9f 87 andcc %o1, 0x78, %o2 884: ZERO_BIG_BLOCK (%o0, 0x00, %g2) 89 subcc %o3, 128, %o3 90 ZERO_BIG_BLOCK (%o0, 0x40, %g2) 91 bne 4b 92 add %o0, 128, %o0 93 94 orcc %o2, %g0, %g0 959: be 6f 96 andcc %o1, 7, %o1 97 98 mov %o7, %g4 99101: call 100f 100 srl %o2, 1, %o3 101 mov %g4, %o7 102 jmpl %o4 + (20f + 64 - 101b), %g0 103 add %o0, %o2, %o0 104 105100: retl 106 sub %o7, %o3, %o4 107 10820: ZERO_LAST_BLOCKS(%o0, 0x48, %g2) 109 ZERO_LAST_BLOCKS(%o0, 0x08, %g2) 110 1116: be 8f 112 andcc %o1, 4, %g0 113 be 1f 114 andcc %o1, 2, %g0 115 st %g3, [%o0] 116 add %o0, 4, %o0 1171: be 1f 118 andcc %o1, 1, %g0 119 sth %g3, [%o0] 120 add %o0, 2, %o0 1211: bne,a 8f 122 stb %g3, [%o0] 1238: retl 124 mov %g1, %o0 1257: orcc %o1, 0, %g0 126 be 0f 127 subcc %o1, 1, %o1 128 stb %g3, [%o0] 129 be 0f 130 subcc %o1, 1, %o1 131 stb %g3, [%o0 + 1] 132 be 0f 133 subcc %o1, 1, %o1 134 stb %g3, [%o0 + 2] 135 be 0f 136 subcc %o1, 1, %o1 137 stb %g3, [%o0 + 3] 138 be 0f 139 subcc %o1, 1, %o1 140 stb %g3, [%o0 + 4] 141 be 0f 142 subcc %o1, 1, %o1 143 stb %g3, [%o0 + 5] 144 be 0f 145 subcc %o1, 1, %o1 146 stb %g3, [%o0 + 6] 1470: retl 148 nop 149END(memset) 150libc_hidden_builtin_def (memset) 151 152weak_alias (__bzero, bzero) 153