|
|
1.1 root 1:
2: #include <machine/fp.h>
3:
4:
5: /* here we count from 0 not from 1 as in fp.h */
6: #define HIDDEN 23
7:
8: .text
9: .globl Xmuld
10: _muld:
11: Xmuld: .word 0xffc
12: clrl r3 /* r3 - sign: 0 for positive,1 for negative. */
13: movl 4(fp),r0
14: jgeq 1f
15: movl $1,r3
16: 1: movl 12(fp),r2
17: jgeq 2f
18: bbc $0,r3,1f /* seconed operand is negative. */
19: clrl r3 /* if first was negative, make result positive. */
20: jmp 2f
21: 1: movl $1,r3 /* if first was positive, make result negative. */
22: 2: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */
23: jeql is_res1
24: shrl $EXPSHIFT,r0,r0
25: subl2 $BIASP1,r0
26: andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */
27: jeql is_res2
28: shrl $EXPSHIFT,r2,r2
29: subl2 $BIASP1,r2
30: addl2 r0,r2 /* add the exponents. */
31: addl2 $(BIASP1+2),r2
32: jleq underflow
33: cmpl r2,$258 /* normalization can make the exp. smaller. */
34: jgeq overflow
35: /*
36: * We have the sign in r3,the exponent in r2,now is the time to
37: * perform the multiplication...
38: */
39: /* fetch first fraction: (r0,r1) */
40: andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0
41: orl2 $(0!CLEARHID),r0
42: movl 8(fp),r1
43: shlq $7,r0,r0 /* leave the sign bit cleared. */
44:
45: /* fetch seconed fraction: (r4,r5) */
46: andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4
47: orl2 $(0!CLEARHID),r4
48: movl 16(fp),r5
49: shlq $7,r4,r4 /* leave the sign bit cleared. */
50:
51: /* in the following lp1 stands for least significant part of operand 1,
52: * lp2 for least significant part of operand 2,
53: * mp1 for most significant part of operand 1,
54: * mp2 for most significant part of operand 2.
55: */
56:
57: clrl r6
58: shrl $1,r1,r1 /* clear the sign bit of the lp1. */
59: jeql 1f
60: emul r1,r4,$0,r6 /* r6,r7 <-- lp1*mp2 */
61: shlq $1,r6,r6 /* to compensate for the shift we did to clear the sign bit. */
62: 1: shrl $1,r5,r5 /* clear the sign bit of the lp2. */
63: jeql 1f
64: emul r0,r5,$0,r8 /* r8,r9 <-- mp1*lp2 */
65: shlq $1,r8,r8
66: addl2 r9,r7 /* r6,r7 <-- the sum of the products. */
67: adwc r8,r6
68: 1: emul r0,r4,$0,r0 /* r0,r1 <-- mp1*mp2 */
69: addl2 r6,r1 /* add the most sig. part of the sum. */
70: adwc $0,r0
71: movl r0,r4 /* to see how much we realy need to shift. */
72: movl $6,r5 /* r5 - shift counter. */
73: shrl $7,r4,r4 /* dummy shift. */
74: 1: bbs $HIDDEN,r4,realshift
75: shll $1,r4,r4
76: decl r2 /* update exponent. */
77: jeql underflow
78: decl r5 /* update shift counter. */
79: jmp 1b
80: realshift:
81: shrq r5,r0,r0
82: bbc $0,r1,shiftmore
83: incl r1 /* rounding. */
84: shiftmore:
85: shrq $1,r0,r0
86: comb:
87: andl2 $CLEARHID,r0
88: shll $EXPSHIFT,r2,r4
89: orl2 r4,r0
90: cmpl r2,$256
91: jlss 1f
92: callf $4,fpover
93: sign:
94: 1: bbc $0,r3,done
95: orl2 $SIGNBIT,r0
96: done: ret
97:
98:
99:
100: is_res1:
101: bbc $31,4(fp),retzero
102: callf $4,fpresop
103: ret
104: is_res2:
105: bbc $31,12(fp),retzero
106: callf $4,fpresop
107: ret
108: retzero:
109: clrl r0
110: clrl r1
111: ret
112: overflow:
113: callf $4,fpover
114: jmp sign
115: underflow:
116: callf $4,fpunder
117: ret
118:
119:
120:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.