| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: random.S,v 1.4 2009/01/06 01:24:56 pooka Exp $ */ | | 1 | /* $NetBSD: random.S,v 1.5 2013/07/18 12:16:40 matt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1990,1993 The Regents of the University of California. | | 4 | * Copyright (c) 1990,1993 The Regents of the University of California. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that: (1) source code distributions | | 8 | * modification, are permitted provided that: (1) source code distributions |
9 | * retain the above copyright notice and this paragraph in its entirety, (2) | | 9 | * retain the above copyright notice and this paragraph in its entirety, (2) |
10 | * distributions including binary code include the above copyright notice and | | 10 | * distributions including binary code include the above copyright notice and |
11 | * this paragraph in its entirety in the documentation or other materials | | 11 | * this paragraph in its entirety in the documentation or other materials |
12 | * provided with the distribution, and (3) all advertising materials mentioning | | 12 | * provided with the distribution, and (3) all advertising materials mentioning |
13 | * features or use of this software display the following acknowledgement: | | 13 | * features or use of this software display the following acknowledgement: |
14 | * ``This product includes software developed by the University of California, | | 14 | * ``This product includes software developed by the University of California, |
| @@ -38,32 +38,24 @@ | | | @@ -38,32 +38,24 @@ |
38 | * seed = ((p + q) & (2^31 - 1)) + 1 | | 38 | * seed = ((p + q) & (2^31 - 1)) + 1 |
39 | * return (seed); | | 39 | * return (seed); |
40 | * | | 40 | * |
41 | * The result is in (0,2^31), e.g., it's always positive. | | 41 | * The result is in (0,2^31), e.g., it's always positive. |
42 | */ | | 42 | */ |
43 | #include <machine/asm.h> | | 43 | #include <machine/asm.h> |
44 | | | 44 | |
45 | .data | | 45 | .data |
46 | ASLOCAL(randseed) | | 46 | ASLOCAL(randseed) |
47 | .long 1 | | 47 | .long 1 |
48 | | | 48 | |
49 | ENTRY(random) | | 49 | ENTRY(random) |
50 | movl #16807, %d0 | | 50 | movl #16807, %d0 |
51 | #ifdef PIC | | 51 | LEA_LCL(_ASM_LABEL(randseed),%a0) |
52 | lea %pc@(_GLOBAL_OFFSET_TABLE_@GOTPC), %a0 | | 52 | mulsl (%a0), %d1:%d0 |
53 | movl _ASM_LABEL(randseed)@GOT(%a0), %d2 | | | |
54 | mulsl (%d2), %d1:%d0 | | | |
55 | #else | | | |
56 | mulsl _ASM_LABEL(randseed), %d1:%d0 | | | |
57 | #endif | | | |
58 | lsll #1, %d0 | | 53 | lsll #1, %d0 |
59 | roxll #2, %d1 | | 54 | roxll #2, %d1 |
60 | addl %d1, %d0 | | 55 | addl %d1, %d0 |
61 | moveql #1, %d1 | | 56 | moveql #1, %d1 |
62 | addxl %d1, %d0 | | 57 | addxl %d1, %d0 |
63 | lsrl #1, %d0 | | 58 | lsrl #1, %d0 |
64 | #ifdef PIC | | 59 | movl %d0, (%a0) |
65 | movl %d0, (%d2) | | | |
66 | #else | | | |
67 | movl %d0, _ASM_LABEL(randseed) | | | |
68 | #endif | | | |
69 | rts | | 60 | rts |
| | | 61 | END(random) |