1/* 2 * Copyright (c) 1986 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 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the University of California, Berkeley. The name of the 14 * University may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 */ 20 21#if defined(SYSLIBC_SCCS) && !defined(lint) 22 .asciz "@(#)divf.s 1.2 (Berkeley) 02/17/89" 23#endif /* SYSLIBC_SCCS and not lint */ 24 25#include <tahoemath/fp.h> 26#include "DEFS.h" 27 28#define HIDDEN 23 /* here we count from 0 not from 1 as in fp.h */ 29 30XENTRY(divf, R2|R3|R4|R5|R6|R7|R8|R9) 31 clrl r1 32 clrl r3 # r3 - sign: 0 for positive,1 for negative. 33 movl 4(fp),r0 34 jgeq 1f 35 movl $1,r3 361: movl 12(fp),r2 37 jgeq 2f 38 bbc $0,r3,1f # seconed operand is negative. 39 clrl r3 # if first was negative, make result positive. 40 jmp 2f 411: movl $1,r3 # if first was positive, make result negative. 422: andl2 $EXPMASK,r0 # compute first 'pure'exponent. 43 jeql is_res1 44 shrl $EXPSHIFT,r0,r0 45 subl2 $BIAS,r0 46 andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. 47 jeql is_res2 48 shrl $EXPSHIFT,r2,r2 49 subl2 $BIAS,r2 50 subl3 r2,r0,r2 # subtruct the exponents. 51 addl2 $BIAS,r2 52 jleq underf 53 # normalization can make the exp. smaller. 54 # 55 # We have the sign in r3,the exponent in r2,now is the time to 56 # perform the division... 57 # 58 # fetch dividend. (r0) 59 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 60 orl2 $(0!CLEARHID),r0 61 clrl r1 62 63 # fetch divisor : (r6) 64 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 65 orl2 $(0!CLEARHID),r6 66 67 shll $2,r6,r6 # make the divisor bigger so we will not 68 # get overflow at the divission. 69 ediv r6,r0,r0,r7 # quo to r0, rem to r7 70 subl2 $6,r2 # to compensate for: normalization (-24), 71 # ediv (+32), shifting r6 (-2). 72 73over: 74 callf $4,fnorm # we can use fnorm because we have data 75 # at r1 as well.(sfnorm takes care only 76 # of r0). 77sign: 781: bbc $0,r3,done 79 orl2 $SIGNBIT,r0 80done: ret 81 82is_res1: 83 bbc $31,4(fp),retz 84 callf $4,sfpresop 85 ret 86is_res2: 87 bbc $31,12(fp),z_div 88 callf $4,sfpresop 89 ret 90retz: 91 clrl r0 92 ret 93underf: 94 callf $4,sfpunder 95 ret 96z_div: 97 callf $4,sfpzdiv 98 ret 99