|
|
1.1 root 1:
2: #include "fp.h"
3: #include "fp_in_krnl.h"
4:
5:
6: /* here we count from 0 not from 1 as in fp.h */
7: #define HIDDEN 23
8:
9: .text
10: .globl _Kmuld # _Kmuld(acc_most,acc_least,op_most,op_least,hfs)
11: _Kmuld: .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 retzero
24: shrl $EXPSHIFT,r0,r0
25: subl2 $BIASP1,r0
26: andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */
27: jeql retzero
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: shrq $1,r0,r0
83: comb:
84: andl2 $CLEARHID,r0
85: shll $EXPSHIFT,r2,r4
86: orl2 r4,r0
87: cmpl r2,$256
88: jlss 1f
89: orl2 $HFS_OVF,*20(fp)
90: sign:
1.1.1.2 ! root 91: 1: bbc $0,r3,1f
1.1 root 92: orl2 $SIGNBIT,r0
1.1.1.2 ! root 93: /*
! 94: * 3/31/86 - Check if rounding is needed. If the accumulator least is
! 95: * 0xfffffff0-0xffffffff and the lower half of the accumulator most is
! 96: * 0xffff, then rounding could have significance and should be done.
! 97: */
! 98: 1: andl3 $0xfffffff0,r1,r2
! 99: cmpl $0xfffffff0,r2
! 100: jneq done
! 101: andl3 $0xffff,r0,r2
! 102: cmpl $0xffff,r2
! 103: jneq done
! 104: clrl r1
! 105: incl r0
1.1 root 106: done: ret
107:
108:
109:
110: retzero:
111: clrl r0
112: clrl r1
113: ret
114: overflow:
115: orl2 $HFS_OVF,*20(fp)
1.1.1.2 ! root 116: movl $0x7fffffff,r0
! 117: bbc $0,r3,1f
! 118: orl2 $SIGNBIT,r0
! 119: 1: mnegl $1,r1
1.1 root 120: ret
121: underflow:
122: orl2 $HFS_UNDF,*20(fp)
1.1.1.2 ! root 123: movl $0x800000,r0
! 124: bbc $0,r3,1f
! 125: orl2 $SIGNBIT,r0
! 126: 1: clrl r1
1.1 root 127: ret
128:
129:
130:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.