1 2#include "fp.h" 3#include "fp_in_krnl.h" 4 5 6 # here we count from 0 not from 1 as in fp.h 7#define HIDDEN 23 8 9 .text 10 .globl _Kdivd # _Kdivd(acc_most,acc_least,op_most,op_least,hfs) 11_Kdivd: .word 0xffc 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. (r4,r5) 39 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r4 40 orl2 $(0!CLEARHID),r4 41 movl 8(fp),r5 42 43 # fetch divisor : (r6,r7) 44 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 45 orl2 $(0!CLEARHID),r6 46 movl 16(fp),r7 47 48 movl $0,r0 # init r0,r1 to be zeros 49 movl $0,r1 50 movl $(0!CLEARHID),r8# r8 first bit to set (if). 51 shll $1,r8,r8 # to have one more bit,because we might 52 # have to shift left to normelize. 53 movl $0,r9 54 552: 56 subl2 r7,r5 57 sbwc r6,r4 58 jgeq 1f 59 addl2 r7,r5 60 adwc r6,r4 61 shlq $1,r4,r4 62 shrq $1,r8,r8 63 jeql over 64 jmp 2b 651: 66 orl2 r8,r0 67 orl2 r9,r1 68 shlq $1,r4,r4 69 shrq $1,r8,r8 70 jneq 2b 71 72over: 73 pushl 20(fp) 74 callf $8,Kfnorm 75sign: 761: bbc $0,r3,done 77 orl2 $SIGNBIT,r0 78done: ret 79 80retz: 81 clrl r0 82 clrl r1 83 ret 84 85retz2: bbc $31,12(fp),z_div 86 clrl r0 87 clrl r1 88 ret 89underf: 90 orl2 $HFS_UNDF,*20(fp) 91 ret 92z_div: 93 orl2 $HFS_DIVZ,*20(fp) 94 ret 95