1/*- 2 * Copyright (c) 1985 The 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 * %sccs.include.redist.c% 9 * 10 * @(#)Kdivd.s 7.1 (Berkeley) 12/06/90 11 */ 12 13#include "../math/fp.h" 14#include "../math/Kfp.h" 15#include "../tahoe/SYS.h" 16 17#define HIDDEN 23 # here we count from 0 not from 1 as in fp.h 18 19 .text 20ENTRY(Kdivd, R9|R8|R7|R6|R5|R4|R3|R2) 21 clrl r3 # r3 - sign: 0 for positive,1 for negative. 22 movl 4(fp),r0 23 jgeq 1f 24 movl $1,r3 251: movl 12(fp),r2 26 jgeq 2f 27 bbc $0,r3,1f # seconed operand is negative. 28 clrl r3 # if first was negative, make result positive. 29 jmp 2f 301: movl $1,r3 # if first was positive, make result negative. 312: andl2 $EXPMASK,r0 # compute first 'pure'exponent. 32 jeql retz 33 shrl $EXPSHIFT,r0,r0 34 subl2 $BIAS,r0 35 andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. 36 jeql retz2 37 shrl $EXPSHIFT,r2,r2 38 subl2 $BIAS,r2 39 subl3 r2,r0,r2 # subtruct the exponents. 40 addl2 $BIAS,r2 41 jleq underf 42 # normalization can make the exp. smaller. 43 # 44 # We have the sign in r3,the exponent in r2,now is the time to 45 # perform the division... 46 # 47 # fetch dividend. (r4,r5) 48 andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r4 49 orl2 $(0!CLEARHID),r4 50 movl 8(fp),r5 51 52 # fetch divisor : (r6,r7) 53 andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 54 orl2 $(0!CLEARHID),r6 55 movl 16(fp),r7 56 57 movl $0,r0 # init r0,r1 to be zeros 58 movl $0,r1 59 movl $(0!CLEARHID),r8# r8 first bit to set (if). 60 shll $1,r8,r8 # to have one more bit,because we might 61 # have to shift left to normelize. 62 movl $0,r9 63 642: 65 subl2 r7,r5 66 sbwc r6,r4 67 jgeq 1f 68 addl2 r7,r5 69 adwc r6,r4 70 shlq $1,r4,r4 71 shrq $1,r8,r8 72 jeql over 73 jmp 2b 741: 75 orl2 r8,r0 76 orl2 r9,r1 77 shlq $1,r4,r4 78 shrq $1,r8,r8 79 jneq 2b 80 81over: 82 pushl 20(fp) 83 callf $8,_Kfnorm 84sign: 851: bbc $0,r3,done 86 orl2 $SIGNBIT,r0 87done: ret 88 89retz: 90 clrl r0 91 clrl r1 92 ret 93 94retz2: bbc $31,12(fp),z_div 95 clrl r0 96 clrl r1 97 ret 98underf: 99 orl2 $HFS_UNDF,*20(fp) 100 ret 101z_div: 102 orl2 $HFS_DIVZ,*20(fp) 103 ret 104