1*45761Sbostic/*- 2*45761Sbostic * Copyright (c) 1985 The Regents of the University of California. 3*45761Sbostic * All rights reserved. 4*45761Sbostic * 5*45761Sbostic * This code is derived from software contributed to Berkeley by 6*45761Sbostic * Computer Consoles Inc. 7*45761Sbostic * 8*45761Sbostic * %sccs.include.redist.c% 9*45761Sbostic * 10*45761Sbostic * @(#)Kdivd.s 7.1 (Berkeley) 12/06/90 11*45761Sbostic */ 1224119Ssam 1345701Sbostic#include "../math/fp.h" 1445701Sbostic#include "../math/Kfp.h" 1525693Ssam#include "../tahoe/SYS.h" 1624119Ssam 1725664Ssam#define HIDDEN 23 # here we count from 0 not from 1 as in fp.h 1824119Ssam 1924119Ssam .text 2025664SsamENTRY(Kdivd, R9|R8|R7|R6|R5|R4|R3|R2) 2124119Ssam clrl r3 # r3 - sign: 0 for positive,1 for negative. 2224119Ssam movl 4(fp),r0 2324119Ssam jgeq 1f 2424119Ssam movl $1,r3 2524119Ssam1: movl 12(fp),r2 2624119Ssam jgeq 2f 2724119Ssam bbc $0,r3,1f # seconed operand is negative. 2824119Ssam clrl r3 # if first was negative, make result positive. 2924119Ssam jmp 2f 3024119Ssam1: movl $1,r3 # if first was positive, make result negative. 3124119Ssam2: andl2 $EXPMASK,r0 # compute first 'pure'exponent. 3224119Ssam jeql retz 3324119Ssam shrl $EXPSHIFT,r0,r0 3424119Ssam subl2 $BIAS,r0 3524119Ssam andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. 3624119Ssam jeql retz2 3724119Ssam shrl $EXPSHIFT,r2,r2 3824119Ssam subl2 $BIAS,r2 3924119Ssam subl3 r2,r0,r2 # subtruct the exponents. 4024119Ssam addl2 $BIAS,r2 4124119Ssam jleq underf 4224119Ssam # normalization can make the exp. smaller. 4324119Ssam # 4424119Ssam # We have the sign in r3,the exponent in r2,now is the time to 4524119Ssam # perform the division... 4624119Ssam # 4724119Ssam # fetch dividend. (r4,r5) 4824119Ssam andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r4 4924119Ssam orl2 $(0!CLEARHID),r4 5024119Ssam movl 8(fp),r5 5124119Ssam 5224119Ssam # fetch divisor : (r6,r7) 5324119Ssam andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 5424119Ssam orl2 $(0!CLEARHID),r6 5524119Ssam movl 16(fp),r7 5624119Ssam 5724119Ssam movl $0,r0 # init r0,r1 to be zeros 5824119Ssam movl $0,r1 5924119Ssam movl $(0!CLEARHID),r8# r8 first bit to set (if). 6024119Ssam shll $1,r8,r8 # to have one more bit,because we might 6124119Ssam # have to shift left to normelize. 6224119Ssam movl $0,r9 6324119Ssam 6424119Ssam2: 6524119Ssam subl2 r7,r5 6624119Ssam sbwc r6,r4 6724119Ssam jgeq 1f 6824119Ssam addl2 r7,r5 6924119Ssam adwc r6,r4 7024119Ssam shlq $1,r4,r4 7124119Ssam shrq $1,r8,r8 7224119Ssam jeql over 7324119Ssam jmp 2b 7424119Ssam1: 7524119Ssam orl2 r8,r0 7624119Ssam orl2 r9,r1 7724119Ssam shlq $1,r4,r4 7824119Ssam shrq $1,r8,r8 7924119Ssam jneq 2b 8024119Ssam 8124119Ssamover: 8224119Ssam pushl 20(fp) 8325664Ssam callf $8,_Kfnorm 8424119Ssamsign: 8524119Ssam1: bbc $0,r3,done 8624119Ssam orl2 $SIGNBIT,r0 8724119Ssamdone: ret 8824119Ssam 8924119Ssamretz: 9024119Ssam clrl r0 9124119Ssam clrl r1 9224119Ssam ret 9324119Ssam 9424119Ssamretz2: bbc $31,12(fp),z_div 9524119Ssam clrl r0 9624119Ssam clrl r1 9724119Ssam ret 9824119Ssamunderf: 9924119Ssam orl2 $HFS_UNDF,*20(fp) 10024119Ssam ret 10124119Ssamz_div: 10224119Ssam orl2 $HFS_DIVZ,*20(fp) 10324119Ssam ret 104