build the assumptions into the map
[unix-history] / usr / src / sys / tahoe / math / Kcvtfl.s
CommitLineData
9d1834ba 1/* Kcvtfl.s 1.3 86/01/05 */
77c2882f 2
9d1834ba
SL
3#include "../tahoemath/fp.h"
4#include "../tahoe/SYS.h"
77c2882f 5
2b252132
SL
6 .text
7ENTRY(Kcvtfl, R5|R4|R3|R2)
77c2882f
SL
8 clrl r1
9 clrl r4 # r4 - negative flag.
10 clrl r2 # r2 - exponent.
11 movl 4(fp),r0 # fetch operand.
12 movl r0,r5 # need another copy.
13 jeql retzero # return zero.
14 jgtr positive
15 mnegl r0,r0
16 jvs retmin # return minimum integer.
17 incl r4 # remember it was negative.
18 movl r0,r5 # remember the negated value.
19 #
20 #Compute exponent:
21 #
22positive:
23 ffs r0,r1
24 incl r1
25 addl2 r1,r2
26 shrl r1,r0,r0
27 jneq positive # look for more set bits.
28 #
29 #we have the exponent in r2.
30 #
31 movl r5,r0 # r0 will hold the resulting f.p. number.
32 #
33 #Shift the fraction part to its proper place:
34 #
35 subl3 r2,$HID_POS,r3
36 jlss shiftr # if less then zero we have to shift right.
37 shll r3,r0,r0 # else we shift left.
38 jmp shifted
39shiftr:
40 mnegl r3,r3
41 shrl r3,r0,r0
42shifted:
43 andl2 $CLEARHID,r0 # clear the hidden bit.
44 shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
45 orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it).
46 orl2 r2,r0 # combine exponent & fraction.
47 bbc $0,r4,sign_ok # do we have to set the sign bit?
48 orl2 $SIGNBIT,r0 # yes...
49sign_ok:
50 ret
51
52retzero:
53 clrl r0
54 ret
55
56retmin:
57 movl $0xd0000000,r0
58 ret