DEFS.h needed for ASMSTR macro
[unix-history] / usr / src / lib / libc / mips / gen / ldexp.s
CommitLineData
8abee3ed
KB
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ralph Campbell.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12 ASMSTR("@(#)ldexp.s 5.1 (Berkeley) %G%")
13#endif /* LIBC_SCCS and not lint */
14
15#include "DEFS.h"
16
17 .sdata
18infinity:
19 .word 0x7ff00000 # IEEE infinity
20 .text
21
22/*
23 * double ldexp(val, exp)
24 * returns: val * (2**exp), for integer exp
25 */
26LEAF(ldexp)
27 .set noreorder
28 mfc1 t0, $f13
29 mov.d $f0, $f12
30 sll t1, t0, 1
31 srl t1, t1, 21
32 addu t1, t1, a2
33 blez t1, 3f
34 slti t2, t1, 2047
35 beq t2, zero, 2f
36 sll a2, a2, 20
37 addu t0, t0, a2
38 mtc1 t0, $f1
391:
40 j ra
41 nop
422:
43 lwc1 $f1, infinity
44 bgez t0, 1b
45 mtc1 zero, $f0
46 j ra
47 neg.d $f0, $f0
483:
49 blt t1, -51, 9f
50 mfc1 t5, $f13
51 li t2, 0x80000000
52 sll t5, t5, 11
53 blt t1, -30, 7f
54 or t5, t5, t2
55 srl t5, t5, 11
56 mfc1 t4, $f12
57 addiu t1, t1, -1
58 sll t3, t5, t1
59 srl t2, t4, t1
60 subu t1, zero, t1
61 srl t4, t4, t1
62 or t4, t4, t3
63 bgez t2, 6f
64 srl t5, t5, t1
65 addiu t4, t4, 1
66 sltiu t6, t4, 1
67 sll t2, t2, 1
68 bne t2, zero, 6f
69 addu t5, t5, t6
70 and t4, t4, ~1
716:
72 mtc1 t4, $f0
73 bgez t0, 1b
74 mtc1 t5, $f1
75 j ra
76 neg.d $f0, $f0
777:
78 mtc1 zero, $f1
79 addiu t1, t1, 20
80 sll t2, t5, t1
81 subu t1, zero, t1
82 bgez t2, 8f
83 srl t4, t5, t1
84 addiu t4, t4, 1
85 sltiu t6, t4, 1
86 sll t2, t2, 1
87 bne t2, zero, 8f
88 mtc1 t6, $f1
89 and t4, t4, ~1
908:
91 bgez t0, 1b
92 mtc1 t4, $f0
93 j ra
94 neg.d $f0, $f0
959:
96 mtc1 zero, $f0
97 bgez t0, 1b
98 mtc1 zero, $f1
99 j ra
100 neg.d $f0, $f0
101 .set reorder
102END(ldexp)