redo include files for kernel reorg
[unix-history] / usr / src / sys / tahoe / math / Kmulf.s
CommitLineData
a6730a00 1/* Kmulf.s 1.4 90/12/04 */
5245a337 2
a6730a00
KB
3#include "../math/fp.h"
4#include "../math/Kfp.h"
9d1834ba 5#include "../tahoe/SYS.h"
5245a337 6
2b252132 7#define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */
5245a337 8
2b252132
SL
9/*
10 * _Kmulf(acc_most,acc_least,op_most,op_least,hfs)
11 */
5245a337 12 .text
2b252132 13ENTRY(Kmulf, R5|R4|R3|R2)
5245a337
SL
14 clrl r3 /* r3 - sign: 0 for positive,1 for negative. */
15 movl 4(fp),r0
16 jgeq 1f
17 movl $1,r3
181: movl 12(fp),r2
19 jgeq 2f
20 bbc $0,r3,1f /* seconed operand is negative. */
21 clrl r3 /* if first was negative, make result positive. */
22 jmp 2f
231: movl $1,r3 /* if first was positive, make result negative. */
242: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */
25 jeql retzero
26 shrl $EXPSHIFT,r0,r0
27 subl2 $BIASP1,r0
28 andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */
29 jeql retzero
30 shrl $EXPSHIFT,r2,r2
31 subl2 $BIASP1,r2
32 addl2 r0,r2 /* add the exponents. */
33 addl2 $(BIASP1+2),r2
34 jleq underflow
35 cmpl r2,$258 /* normalization can make the exp. smaller. */
36 jgeq overflow
37 /*
38 * We have the sign in r3,the exponent in r2,now is the time to
39 * perform the multiplication...
40 */
41 /* fetch first fraction: (r0) */
42 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0
43 orl2 $(0!CLEARHID),r0
44 shll $7,r0,r0 /* leave the sign bit cleared. */
45
46 /* fetch seconed fraction: (r4) */
47 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4
48 orl2 $(0!CLEARHID),r4
49 shll $7,r4,r4 /* leave the sign bit cleared. */
50
51
52 emul r4,r0,$0,r0
53 movl r0,r4 /* to see how much we realy need to shift. */
54 movl $6,r5 /* r5 - shift counter. */
55 shrl $7,r4,r4 /* dummy shift. */
561: bbs $HIDDEN,r4,realshift
57 shll $1,r4,r4
58 decl r2 /* update exponent. */
59 jeql underflow
60 decl r5 /* update shift counter. */
61 jmp 1b
62realshift:
63 shrl r5,r0,r0
64 bbc $0,r1,shiftmore
65 incl r1 /* rounding. */
66shiftmore:
67 shrl $1,r0,r0
68comb:
69 andl2 $CLEARHID,r0
70 shll $EXPSHIFT,r2,r4
71 orl2 r4,r0
72 cmpl r2,$256
73 jlss 1f
74 orl2 $HFS_OVF,*20(fp)
75sign:
761: bbc $0,r3,done
77 orl2 $SIGNBIT,r0
78done: ret
79
80
81
82 retzero:
83 clrl r0
84 ret
85 overflow:
86 orl2 $HFS_OVF,*20(fp)
87 jmp sign
88 underflow:
89 orl2 $HFS_UNDF,*20(fp)
90 ret
91
92
93