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 "@(#)divf.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(divf, R2|R3|R4|R5|R6|R7|R8|R9) 21 clrl r1 22 clrl r3 # r3 - sign: 0 for positive,1 for negative. 23 movl 4(fp),r0 24 jgeq 1f 25 movl $1,r3 261: movl 12(fp),r2 27 jgeq 2f 28 bbc $0,r3,1f # seconed operand is negative. 29 clrl r3 # if first was negative, make result positive. 30 jmp 2f 311: movl $1,r3 # if first was positive, make result negative. 322: andl2 $EXPMASK,r0 # compute first 'pure'exponent. 33 jeql is_res1 34 shrl $EXPSHIFT,r0,r0 35 subl2 $BIAS,r0 36 andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. 37 jeql is_res2 38 shrl $EXPSHIFT,r2,r2 39 subl2 $BIAS,r2 40 subl3 r2,r0,r2 # subtruct the exponents. 41 addl2 $BIAS,r2 42 jleq underf 43 # normalization can make the exp. smaller. 44 # 45 # We have the sign in r3,the exponent in r2,now is the time to 46 # perform the division... 47 # 48 # fetch dividend. (r0) 49 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 50 orl2 $(0!CLEARHID),r0 51 clrl r1 52 53 # fetch divisor : (r6) 54 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 55 orl2 $(0!CLEARHID),r6 56 57 shll $2,r6,r6 # make the divisor bigger so we will not 58 # get overflow at the divission. 59 ediv r6,r0,r0,r7 # quo to r0, rem to r7 60 subl2 $6,r2 # to compensate for: normalization (-24), 61 # ediv (+32), shifting r6 (-2). 62 63over: 64 callf $4,fnorm # we can use fnorm because we have data 65 # at r1 as well.(sfnorm takes care only 66 # of r0). 67sign: 681: bbc $0,r3,done 69 orl2 $SIGNBIT,r0 70done: ret 71 72is_res1: 73 bbc $31,4(fp),retz 74 callf $4,sfpresop 75 ret 76is_res2: 77 bbc $31,12(fp),z_div 78 callf $4,sfpresop 79 ret 80retz: 81 clrl r0 82 ret 83underf: 84 callf $4,sfpunder 85 ret 86z_div: 87 callf $4,sfpzdiv 88 ret 89