|
|
1.1 ! root 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: * Redistribution and use in source and binary forms, with or without ! 9: * modification, are permitted provided that the following conditions ! 10: * are met: ! 11: * 1. Redistributions of source code must retain the above copyright ! 12: * notice, this list of conditions and the following disclaimer. ! 13: * 2. Redistributions in binary form must reproduce the above copyright ! 14: * notice, this list of conditions and the following disclaimer in the ! 15: * documentation and/or other materials provided with the distribution. ! 16: * 3. All advertising materials mentioning features or use of this software ! 17: * must display the following acknowledgement: ! 18: * This product includes software developed by the University of ! 19: * California, Berkeley and its contributors. ! 20: * 4. Neither the name of the University nor the names of its contributors ! 21: * may be used to endorse or promote products derived from this software ! 22: * without specific prior written permission. ! 23: * ! 24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 34: * SUCH DAMAGE. ! 35: * ! 36: * @(#)Kdivf.s 7.1 (Berkeley) 12/6/90 ! 37: */ ! 38: ! 39: #include "../math/fp.h" ! 40: #include "../math/Kfp.h" ! 41: #include "../tahoe/SYS.h" ! 42: ! 43: #define HIDDEN 23 # here we count from 0 not from 1 as in fp.h ! 44: ! 45: .text ! 46: ENTRY(Kdivf, R9|R8|R7|R6|R5|R4|R3|R2) ! 47: clrl r1 ! 48: clrl r3 # r3 - sign: 0 for positive,1 for negative. ! 49: movl 4(fp),r0 ! 50: jgeq 1f ! 51: movl $1,r3 ! 52: 1: movl 12(fp),r2 ! 53: jgeq 2f ! 54: bbc $0,r3,1f # seconed operand is negative. ! 55: clrl r3 # if first was negative, make result positive. ! 56: jmp 2f ! 57: 1: movl $1,r3 # if first was positive, make result negative. ! 58: 2: andl2 $EXPMASK,r0 # compute first 'pure'exponent. ! 59: jeql retz ! 60: shrl $EXPSHIFT,r0,r0 ! 61: subl2 $BIAS,r0 ! 62: andl2 $EXPMASK,r2 # compute seconed 'pure'exponent. ! 63: jeql retz2 ! 64: shrl $EXPSHIFT,r2,r2 ! 65: subl2 $BIAS,r2 ! 66: subl3 r2,r0,r2 # subtruct the exponents. ! 67: addl2 $BIAS,r2 ! 68: jleq underf ! 69: # normalization can make the exp. smaller. ! 70: # ! 71: # We have the sign in r3,the exponent in r2,now is the time to ! 72: # perform the division... ! 73: # ! 74: # fetch dividend. (r0) ! 75: andl3 $(0!(EXPMASK | SIGNBIT)),4(fp),r0 ! 76: orl2 $(0!CLEARHID),r0 ! 77: clrl r1 ! 78: ! 79: # fetch divisor : (r6) ! 80: andl3 $(0!(EXPMASK | SIGNBIT)),12(fp),r6 ! 81: orl2 $(0!CLEARHID),r6 ! 82: ! 83: shll $2,r6,r6 # make the divisor bigger so we will not ! 84: # get overflow at the divission. ! 85: ediv r6,r0,r0,r7 # quo to r0, rem to r7 ! 86: subl2 $6,r2 # to compensate for: normalization (-24), ! 87: # ediv (+32), shifting r6 (-2). ! 88: ! 89: over: ! 90: pushl 20(fp) ! 91: callf $8,_Kfnorm # we can use fnorm because we have data ! 92: # at r1 as well.(sfnorm takes care only ! 93: # of r0). ! 94: sign: ! 95: 1: bbc $0,r3,done ! 96: orl2 $SIGNBIT,r0 ! 97: done: ret ! 98: ! 99: retz: ! 100: clrl r0 ! 101: ret ! 102: ! 103: retz2: bbc $31,12(fp),z_div ! 104: clrl r0 ! 105: ret ! 106: ! 107: underf: ! 108: orl2 $HFS_UNDF,*20(fp) ! 109: ret ! 110: z_div: ! 111: orl2 $HFS_DIVZ,*20(fp) ! 112: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.