1/*- 2 * Copyright (c) 1985 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)Kmulf.s 7.1 (Berkeley) 12/06/90 11 */ 12 13#include "../math/fp.h" 14#include "../math/Kfp.h" 15#include "../tahoe/SYS.h" 16 17#define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */ 18 19/* 20 * _Kmulf(acc_most,acc_least,op_most,op_least,hfs) 21 */ 22 .text 23ENTRY(Kmulf, R5|R4|R3|R2) 24 clrl r3 /* r3 - sign: 0 for positive,1 for negative. */ 25 movl 4(fp),r0 26 jgeq 1f 27 movl $1,r3 281: movl 12(fp),r2 29 jgeq 2f 30 bbc $0,r3,1f /* seconed operand is negative. */ 31 clrl r3 /* if first was negative, make result positive. */ 32 jmp 2f 331: movl $1,r3 /* if first was positive, make result negative. */ 342: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */ 35 jeql retzero 36 shrl $EXPSHIFT,r0,r0 37 subl2 $BIASP1,r0 38 andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */ 39 jeql retzero 40 shrl $EXPSHIFT,r2,r2 41 subl2 $BIASP1,r2 42 addl2 r0,r2 /* add the exponents. */ 43 addl2 $(BIASP1+2),r2 44 jleq underflow 45 cmpl r2,$258 /* normalization can make the exp. smaller. */ 46 jgeq overflow 47 /* 48 * We have the sign in r3,the exponent in r2,now is the time to 49 * perform the multiplication... 50 */ 51 /* fetch first fraction: (r0) */ 52 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 53 orl2 $(0!CLEARHID),r0 54 shll $7,r0,r0 /* leave the sign bit cleared. */ 55 56 /* fetch seconed fraction: (r4) */ 57 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4 58 orl2 $(0!CLEARHID),r4 59 shll $7,r4,r4 /* leave the sign bit cleared. */ 60 61 62 emul r4,r0,$0,r0 63 movl r0,r4 /* to see how much we realy need to shift. */ 64 movl $6,r5 /* r5 - shift counter. */ 65 shrl $7,r4,r4 /* dummy shift. */ 661: bbs $HIDDEN,r4,realshift 67 shll $1,r4,r4 68 decl r2 /* update exponent. */ 69 jeql underflow 70 decl r5 /* update shift counter. */ 71 jmp 1b 72realshift: 73 shrl r5,r0,r0 74 bbc $0,r1,shiftmore 75 incl r1 /* rounding. */ 76shiftmore: 77 shrl $1,r0,r0 78comb: 79 andl2 $CLEARHID,r0 80 shll $EXPSHIFT,r2,r4 81 orl2 r4,r0 82 cmpl r2,$256 83 jlss 1f 84 orl2 $HFS_OVF,*20(fp) 85sign: 861: bbc $0,r3,done 87 orl2 $SIGNBIT,r0 88done: ret 89 90 91 92 retzero: 93 clrl r0 94 ret 95 overflow: 96 orl2 $HFS_OVF,*20(fp) 97 jmp sign 98 underflow: 99 orl2 $HFS_UNDF,*20(fp) 100 ret 101 102 103 104