Deleted Added
full compact
fixunsdfsi.S (86535) fixunsdfsi.S (92053)
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *

--- 35 unchanged lines hidden (view full) ---

44 .asciz "@(#)fixunsdfsi.s 8.1 (Berkeley) 6/4/93"
45#else
46 RCSID("$NetBSD: fixunsdfsi.S,v 1.3 2000/07/25 04:26:12 mycroft Exp $")
47#endif
48#endif /* LIBC_SCCS and not lint */
49
50#if defined(SYSLIBC_RCS) && !defined(lint)
51 .text
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *

--- 35 unchanged lines hidden (view full) ---

44 .asciz "@(#)fixunsdfsi.s 8.1 (Berkeley) 6/4/93"
45#else
46 RCSID("$NetBSD: fixunsdfsi.S,v 1.3 2000/07/25 04:26:12 mycroft Exp $")
47#endif
48#endif /* LIBC_SCCS and not lint */
49
50#if defined(SYSLIBC_RCS) && !defined(lint)
51 .text
52 .asciz "$FreeBSD: head/lib/libc/sparc64/gen/fixunsdfsi.S 86535 2001-11-18 04:40:30Z jake $"
52 .asciz "$FreeBSD: head/lib/libc/sparc64/gen/fixunsdfsi.S 92053 2002-03-11 03:10:55Z tmm $"
53#endif /* SYSLIBC_RCS and not lint */
54
55/*
56 * Convert double to unsigned integer (for gcc).
57 *
58 * I have made the output for NaN agree with the Sun compiler, not
59 * that it really matters, by using `fbul,a'.
60 */
61
62
63 .align 8
64.Lbig:
65 .word 0x43e00000 ! .double 2^63
66 .word 0 ! (who me, not trust the assembler?)
67
68/*
69 * Same as above but to unsigned long
70 */
71ENTRY(__dtoul)
53#endif /* SYSLIBC_RCS and not lint */
54
55/*
56 * Convert double to unsigned integer (for gcc).
57 *
58 * I have made the output for NaN agree with the Sun compiler, not
59 * that it really matters, by using `fbul,a'.
60 */
61
62
63 .align 8
64.Lbig:
65 .word 0x43e00000 ! .double 2^63
66 .word 0 ! (who me, not trust the assembler?)
67
68/*
69 * Same as above but to unsigned long
70 */
71ENTRY(__dtoul)
72 PIC_PROLOGUE(%o4, %o5)
72 sub %sp, 16, %sp
73 sub %sp, 16, %sp
73 std %f2, [%sp + 64 + SPOFF + 8]
74 sethi %hi(.Lbig), %g1
75 ldd [%g1 + %lo(.Lbig)], %f2
74 std %f2, [%sp + CCFSZ + SPOFF + 8]
75 SET(.Lbig, %o5, %o3)
76 ldd [%o3], %f2
76 fcmped %f0, %f2 ! d < 2^63, or NaN, or -Inf?
77 fcmped %f0, %f2 ! d < 2^63, or NaN, or -Inf?
77 nop ! (fpop2 delay)
78 fbul,a 1f ! if so, use fdtoi to convert to int
78 fbul,a 1f ! if so, use fdtox to convert to long
79 fdtox %f0, %f0 ! (this includes negatives!)
80
79 fdtox %f0, %f0 ! (this includes negatives!)
80
81 ! d does not fit in an int, so subtract 2^63, convert,
81 ! d does not fit in a long, so subtract 2^63, convert,
82 ! and add 2^63 again (sigh). Just hope the intermediate
83 ! fits (if not, the result is undefined anyway).
84
85 fsubd %f0, %f2, %f0 ! d -= 2^63
82 ! and add 2^63 again (sigh). Just hope the intermediate
83 ! fits (if not, the result is undefined anyway).
84
85 fsubd %f0, %f2, %f0 ! d -= 2^63
86 fdtox %f0, %f0 ! convert to int
87 std %f0, [%sp + 64 + SPOFF] ! move into return reg
88 ldx [%sp + 64 + SPOFF], %o0
86 fdtox %f0, %f0 ! convert to long
87 std %f0, [%sp + CCFSZ + SPOFF] ! move into return reg
88 ldx [%sp + CCFSZ + SPOFF], %o0
89 sethi %hi(0x80000000), %o1
90 sllx %o1, 32, %o1
91 add %o0, %o1, %o0 ! add 2^63
89 sethi %hi(0x80000000), %o1
90 sllx %o1, 32, %o1
91 add %o0, %o1, %o0 ! add 2^63
92 ldd [%sp + 64 + SPOFF + 8], %f2
92 ldd [%sp + CCFSZ + SPOFF + 8], %f2
93 retl
94 add %sp, 16, %sp
95
961:
93 retl
94 add %sp, 16, %sp
95
961:
97 std %f0, [%sp + 64 + SPOFF] ! return result
98 ldx [%sp + 64 + SPOFF], %o0
99 ldd [%sp + 64 + SPOFF + 8], %f2
97 std %f0, [%sp + CCFSZ + SPOFF] ! return result
98 ldx [%sp + CCFSZ + SPOFF], %o0
99 ldd [%sp + CCFSZ + SPOFF + 8], %f2
100 retl
101 add %sp, 16, %sp
102END(__dtoul)
100 retl
101 add %sp, 16, %sp
102END(__dtoul)