136829Sbostic/* 2*61181Sbostic * Copyright (c) 1986, 1993 3*61181Sbostic * The Regents of the University of California. All rights reserved. 436829Sbostic * 536829Sbostic * This code is derived from software contributed to Berkeley by 636829Sbostic * Computer Consoles Inc. 736829Sbostic * 842637Sbostic * %sccs.include.redist.c% 936829Sbostic */ 1029517Ssam 1136829Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint) 12*61181Sbostic .asciz "@(#)mulf.s 8.1 (Berkeley) 06/04/93" 1336829Sbostic#endif /* SYSLIBC_SCCS and not lint */ 1436829Sbostic 1529517Ssam#include <tahoemath/fp.h> 1629517Ssam#include "DEFS.h" 1729517Ssam 1829517Ssam#define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */ 1929517Ssam 2029517SsamXENTRY(mulf, R2|R3|R4|R5|R6|R7|R8|R9) 2129517Ssam clrl r3 /* r3 - sign: 0 for positive,1 for negative. */ 2229517Ssam movl 4(fp),r0 2329517Ssam jgeq 1f 2429517Ssam movl $1,r3 2529517Ssam1: movl 12(fp),r2 2629517Ssam jgeq 2f 2729517Ssam bbc $0,r3,1f /* seconed operand is negative. */ 2829517Ssam clrl r3 /* if first was negative, make result positive. */ 2929517Ssam jmp 2f 3029517Ssam1: movl $1,r3 /* if first was positive, make result negative. */ 3129517Ssam2: andl2 $EXPMASK,r0 /* compute first 'pure'exponent. */ 3229517Ssam jeql is_res1 3329517Ssam shrl $EXPSHIFT,r0,r0 3429517Ssam subl2 $BIASP1,r0 3529517Ssam andl2 $EXPMASK,r2 /* compute seconed 'pure'exponent. */ 3629517Ssam jeql is_res2 3729517Ssam shrl $EXPSHIFT,r2,r2 3829517Ssam subl2 $BIASP1,r2 3929517Ssam addl2 r0,r2 /* add the exponents. */ 4029517Ssam addl2 $(BIASP1+2),r2 4129517Ssam jleq underflow 4229517Ssam cmpl r2,$258 /* normalization can make the exp. smaller. */ 4329517Ssam jgeq overflow 4429517Ssam /* 4529517Ssam * We have the sign in r3,the exponent in r2,now is the time to 4629517Ssam * perform the multiplication... 4729517Ssam */ 4829517Ssam /* fetch first fraction: (r0) */ 4929517Ssam andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 5029517Ssam orl2 $(0!CLEARHID),r0 5129517Ssam shll $7,r0,r0 /* leave the sign bit cleared. */ 5229517Ssam 5329517Ssam /* fetch seconed fraction: (r4) */ 5429517Ssam andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r4 5529517Ssam orl2 $(0!CLEARHID),r4 5629517Ssam shll $7,r4,r4 /* leave the sign bit cleared. */ 5729517Ssam 5829517Ssam 5929517Ssam emul r4,r0,$0,r0 6029517Ssam movl r0,r4 /* to see how much we realy need to shift. */ 6129517Ssam movl $6,r5 /* r5 - shift counter. */ 6229517Ssam shrl $7,r4,r4 /* dummy shift. */ 6329517Ssam1: bbs $HIDDEN,r4,realshift 6429517Ssam shll $1,r4,r4 6529517Ssam decl r2 /* update exponent. */ 6629517Ssam jeql underflow 6729517Ssam decl r5 /* update shift counter. */ 6829517Ssam jmp 1b 6929517Ssamrealshift: 7029517Ssam shrl r5,r0,r0 7129517Ssam bbc $0,r1,shiftmore 7229517Ssam incl r1 /* rounding. */ 7329517Ssamshiftmore: 7429517Ssam shrl $1,r0,r0 7529517Ssamcomb: 7629517Ssam andl2 $CLEARHID,r0 7729517Ssam shll $EXPSHIFT,r2,r4 7829517Ssam orl2 r4,r0 7929517Ssam cmpl r2,$256 8029517Ssam jlss 1f 8129517Ssam callf $4,sfpover 8229517Ssamsign: 8329517Ssam1: bbc $0,r3,done 8429517Ssam orl2 $SIGNBIT,r0 8529517Ssamdone: ret 8629517Ssam 8729517Ssam 8829517Ssam 8929517Ssamis_res1: 9029517Ssam bbc $31,4(fp),retzero 9129517Ssam callf $4,sfpresop 9229517Ssam ret 9329517Ssamis_res2: 9429517Ssam bbc $31,12(fp),retzero 9529517Ssam callf $4,sfpresop 9629517Ssam ret 9729517Ssam retzero: 9829517Ssam clrl r0 9929517Ssam ret 10029517Ssam overflow: 10129517Ssam callf $4,sfpover 10229517Ssam jmp sign 10329517Ssam underflow: 10429517Ssam callf $4,sfpunder 10529517Ssam ret 10629517Ssam 10729517Ssam 10829517Ssam 109