|
|
1.1 root 1: #ifdef LIBC_SCCS
2: .asciz "@(#)cvtld.s 1.1 (Berkeley/CCI) 7/2/86"
3: #endif LIBC_SCCS
4:
5: #include <tahoemath/fp.h>
6: #include "DEFS.h"
7:
8: XENTRY(cvtld, R2|R3|R4|R5)
9: #
10: #Some initializations:
11: #
12: clrl r4 # r4 - negative flag.
13: clrl r2 # r2 - exponent.
14: movl 4(fp),r0 # fetch operand.
15: movl r0,r5 # need another copy.
16: jeql retzero # return zero.
17: jgtr positive
18: mnegl r0,r0
19: jvs retmin # return minimum integer.
20: incl r4 # remember it was negative.
21: movl r0,r5 # remember the negated value.
22: #
23: #Compute exponent:
24: #
25: positive:
26: ffs r0,r1
27: incl r1
28: addl2 r1,r2
29: shrl r1,r0,r0
30: jneq positive # look for more set bits.
31: #
32: #we have the exponent in r2.
33: #
34: movl r5,r0 # r0,r1 will hold the resulting f.p. number.
35: clrl r1
36: #
37: #Shift the fraction part to its proper place:
38: #
39: subl3 r2,$HID_POS,r3
40: jlss shiftr # if less then zero we have to shift right.
41: shll r3,r0,r0 # else we shift left.
42: jmp shifted
43: shiftr:
44: mnegl r3,r3
45: shrq r3,r0,r0
46: shifted:
47: andl2 $CLEARHID,r0 # clear the hidden bit.
48: shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
49: orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it).
50: orl2 r2,r0 # combine exponent & fraction.
51: bbc $0,r4,sign_ok # do we have to set the sign bit?
52: orl2 $SIGNBIT,r0 # yes...
53: sign_ok:
54: ret
55:
56: retzero:
57: clrl r0
58: clrl r1
59: ret
60:
61: retmin:
62: movl $0xd0000000,r0
63: clrl r1
64: ret
65:
66:
67:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.