1/* 2 * Copyright (c) 1986, 1993 3 * The Regents of the University of California. 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 11#if defined(SYSLIBC_SCCS) && !defined(lint) 12 .asciz "@(#)mulf.s 8.1 (Berkeley) 06/04/93" 13#endif /* SYSLIBC_SCCS and not lint */ 14 15#include <tahoemath/fp.h> 16#include "DEFS.h" 17 18#define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */ 19 20XENTRY(mulf, R2|R3|R4|R5|R6|R7|R8|R9) 21 clrl r3 /* r3 - sign: 0 for positive,1 for negative. */ 22 movl 4(fp),r0 23 jgeq 1f 24 movl $1,r3 251: movl 12(fp),r2 26 jgeq 2f 27 bbc $0,r3,1f /* seconed operand is negative. */ 28 clrl r3 /* if first was negative, make result positive. */ 29 jmp 2f 301: movl $1,r3 /* if first was positive, make result negative. */ 312: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */ 32 jeql is_res1 33 shrl $EXPSHIFT,r0,r0 34 subl2 $BIASP1,r0 35 andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */ 36 jeql is_res2 37 shrl $EXPSHIFT,r2,r2 38 subl2 $BIASP1,r2 39 addl2 r0,r2 /* add the exponents. */ 40 addl2 $(BIASP1+2),r2 41 jleq underflow 42 cmpl r2,$258 /* normalization can make the exp. smaller. */ 43 jgeq overflow 44 /* 45 * We have the sign in r3,the exponent in r2,now is the time to 46 * perform the multiplication... 47 */ 48 /* fetch first fraction: (r0) */ 49 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 50 orl2 $(0!CLEARHID),r0 51 shll $7,r0,r0 /* leave the sign bit cleared. */ 52 53 /* fetch seconed fraction: (r4) */ 54 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4 55 orl2 $(0!CLEARHID),r4 56 shll $7,r4,r4 /* leave the sign bit cleared. */ 57 58 59 emul r4,r0,$0,r0 60 movl r0,r4 /* to see how much we realy need to shift. */ 61 movl $6,r5 /* r5 - shift counter. */ 62 shrl $7,r4,r4 /* dummy shift. */ 631: bbs $HIDDEN,r4,realshift 64 shll $1,r4,r4 65 decl r2 /* update exponent. */ 66 jeql underflow 67 decl r5 /* update shift counter. */ 68 jmp 1b 69realshift: 70 shrl r5,r0,r0 71 bbc $0,r1,shiftmore 72 incl r1 /* rounding. */ 73shiftmore: 74 shrl $1,r0,r0 75comb: 76 andl2 $CLEARHID,r0 77 shll $EXPSHIFT,r2,r4 78 orl2 r4,r0 79 cmpl r2,$256 80 jlss 1f 81 callf $4,sfpover 82sign: 831: bbc $0,r3,done 84 orl2 $SIGNBIT,r0 85done: ret 86 87 88 89is_res1: 90 bbc $31,4(fp),retzero 91 callf $4,sfpresop 92 ret 93is_res2: 94 bbc $31,12(fp),retzero 95 callf $4,sfpresop 96 ret 97 retzero: 98 clrl r0 99 ret 100 overflow: 101 callf $4,sfpover 102 jmp sign 103 underflow: 104 callf $4,sfpunder 105 ret 106 107 108 109