|
|
1.1 root 1: #ifdef LIBC_SCCS
2: .asciz "@(#)mulf.s 1.1 (Berkeley/CCI) 7/2/86"
3: #endif LIBC_SCCS
4:
5: #include <tahoemath/fp.h>
6: #include "DEFS.h"
7:
8: #define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */
9:
10: XENTRY(mulf, R2|R3|R4|R5|R6|R7|R8|R9)
11: clrl r3 /* r3 - sign: 0 for positive,1 for negative. */
12: movl 4(fp),r0
13: jgeq 1f
14: movl $1,r3
15: 1: movl 12(fp),r2
16: jgeq 2f
17: bbc $0,r3,1f /* seconed operand is negative. */
18: clrl r3 /* if first was negative, make result positive. */
19: jmp 2f
20: 1: movl $1,r3 /* if first was positive, make result negative. */
21: 2: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */
22: jeql is_res1
23: shrl $EXPSHIFT,r0,r0
24: subl2 $BIASP1,r0
25: andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */
26: jeql is_res2
27: shrl $EXPSHIFT,r2,r2
28: subl2 $BIASP1,r2
29: addl2 r0,r2 /* add the exponents. */
30: addl2 $(BIASP1+2),r2
31: jleq underflow
32: cmpl r2,$258 /* normalization can make the exp. smaller. */
33: jgeq overflow
34: /*
35: * We have the sign in r3,the exponent in r2,now is the time to
36: * perform the multiplication...
37: */
38: /* fetch first fraction: (r0) */
39: andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0
40: orl2 $(0!CLEARHID),r0
41: shll $7,r0,r0 /* leave the sign bit cleared. */
42:
43: /* fetch seconed fraction: (r4) */
44: andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4
45: orl2 $(0!CLEARHID),r4
46: shll $7,r4,r4 /* leave the sign bit cleared. */
47:
48:
49: emul r4,r0,$0,r0
50: movl r0,r4 /* to see how much we realy need to shift. */
51: movl $6,r5 /* r5 - shift counter. */
52: shrl $7,r4,r4 /* dummy shift. */
53: 1: bbs $HIDDEN,r4,realshift
54: shll $1,r4,r4
55: decl r2 /* update exponent. */
56: jeql underflow
57: decl r5 /* update shift counter. */
58: jmp 1b
59: realshift:
60: shrl r5,r0,r0
61: bbc $0,r1,shiftmore
62: incl r1 /* rounding. */
63: shiftmore:
64: shrl $1,r0,r0
65: comb:
66: andl2 $CLEARHID,r0
67: shll $EXPSHIFT,r2,r4
68: orl2 r4,r0
69: cmpl r2,$256
70: jlss 1f
71: callf $4,sfpover
72: sign:
73: 1: bbc $0,r3,done
74: orl2 $SIGNBIT,r0
75: done: ret
76:
77:
78:
79: is_res1:
80: bbc $31,4(fp),retzero
81: callf $4,sfpresop
82: ret
83: is_res2:
84: bbc $31,12(fp),retzero
85: callf $4,sfpresop
86: ret
87: retzero:
88: clrl r0
89: ret
90: overflow:
91: callf $4,sfpover
92: jmp sign
93: underflow:
94: callf $4,sfpunder
95: ret
96:
97:
98:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.