comparison src/libsys/bzero.S @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
1 /*
2 * This ARM implementation of bzero() has been derived from:
3 *
4 * linux/arch/arm/lib/memzero.S
5 *
6 * Copyright (C) 1995-2000 Russell King
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13 .text
14 .code 32
15 .globl bzero
16
17 /*
18 * Align the pointer in r0. r3 contains the number of bytes that we are
19 * mis-aligned by, and r1 is the number of bytes. If r1 < 4, then we
20 * don't bother; we use byte stores instead.
21 */
22 1: subs r1, r1, #4 @ 1 do we have enough
23 blt 5f @ 1 bytes to align with?
24 cmp r3, #2 @ 1
25 strltb r2, [r0], #1 @ 1
26 strleb r2, [r0], #1 @ 1
27 strb r2, [r0], #1 @ 1
28 add r1, r1, r3 @ 1 (r1 = r1 - (4 - r3))
29 /*
30 * The pointer is now aligned and the length is adjusted. Try doing the
31 * bzero again.
32 */
33
34 bzero:
35 mov r2, #0 @ 1
36 ands r3, r0, #3 @ 1 unaligned?
37 bne 1b @ 1
38 /*
39 * r3 = 0, and we know that the pointer in r0 is aligned to a word boundary.
40 */
41 3: subs r1, r1, #4
42 strge r2, [r0], #4
43 bgt 3b @ 1
44 bxeq lr @ 1/2 quick exit
45 /*
46 * No need to correct the count; we're only testing bits from now on
47 *
48 * When we get here, we've got less than 4 bytes to zero. We
49 * may have an unaligned pointer as well.
50 */
51 5: tst r1, #2 @ 1 2 bytes or more?
52 strneb r2, [r0], #1 @ 1
53 strneb r2, [r0], #1 @ 1
54 tst r1, #1 @ 1 a byte left over
55 strneb r2, [r0], #1 @ 1
56 bx lr @ 1