1/* Kdivf.s 1.3 86/01/05 */ 2 3#include "../tahoemath/fp.h" 4#include "../tahoemath/Kfp.h" 5#include "../tahoe/SYS.h" 6 7#define HIDDEN 23 # here we count from 0 not from 1 as in fp.h 8 9 .text 10ENTRY(Kdivf, R9|R8|R7|R6|R5|R4|R3|R2) 11 clrl r1 12 clrl r3 # r3 - sign: 0 for positive,1 for negative. 13 movl 4(fp),r0 14 jgeq 1f 15 movl $1,r3 161: movl 12(fp),r2 17 jgeq 2f 18 bbc $0,r3,1f # seconed operand is negative. 19 clrl r3 # if first was negative, make result positive. 20 jmp 2f 211: movl $1,r3 # if first was positive, make result negative. 222: andl2 $EXPMASK,r0 # compute first 'pure'exponent. 23 jeql retz 24 shrl $EXPSHIFT,r0,r0 25 subl2 $BIAS,r0 26 andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. 27 jeql retz2 28 shrl $EXPSHIFT,r2,r2 29 subl2 $BIAS,r2 30 subl3 r2,r0,r2 # subtruct the exponents. 31 addl2 $BIAS,r2 32 jleq underf 33 # normalization can make the exp. smaller. 34 # 35 # We have the sign in r3,the exponent in r2,now is the time to 36 # perform the division... 37 # 38 # fetch dividend. (r0) 39 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 40 orl2 $(0!CLEARHID),r0 41 clrl r1 42 43 # fetch divisor : (r6) 44 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 45 orl2 $(0!CLEARHID),r6 46 47 shll $2,r6,r6 # make the divisor bigger so we will not 48 # get overflow at the divission. 49 ediv r6,r0,r0,r7 # quo to r0, rem to r7 50 subl2 $6,r2 # to compensate for: normalization (-24), 51 # ediv (+32), shifting r6 (-2). 52 53over: 54 pushl 20(fp) 55 callf $8,_Kfnorm # we can use fnorm because we have data 56 # at r1 as well.(sfnorm takes care only 57 # of r0). 58sign: 591: bbc $0,r3,done 60 orl2 $SIGNBIT,r0 61done: ret 62 63retz: 64 clrl r0 65 ret 66 67retz2: bbc $31,12(fp),z_div 68 clrl r0 69 ret 70 71underf: 72 orl2 $HFS_UNDF,*20(fp) 73 ret 74z_div: 75 orl2 $HFS_DIVZ,*20(fp) 76 ret 77