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