|
|
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: * @(#)Ksqrtf.s 7.1 (Berkeley) 12/6/90 ! 37: */ ! 38: ! 39: #include "../tahoe/SYS.h" ! 40: ! 41: .text ! 42: ENTRY(Ksqrtf, 0) ! 43: subl3 $76,fp,sp ! 44: tstl 4(fp) # if (arg <= 0.) { ! 45: jgtr L18 ! 46: jgeq L19 # if (arg < 0.) ! 47: L19: clrl r1 ! 48: clrl r0 ! 49: ret # return(0.);} ! 50: L18: ! 51: pushl 20(fp) # hfs ! 52: subl3 $72,fp,-(sp) ! 53: pushl 8(fp) ! 54: pushl 4(fp) ! 55: callf $20,_Kfrexpf ! 56: clrl -60+4(fp) ! 57: movl r0,-60(fp) # x = frexp(arg,&exp); ! 58: jbr L20 ! 59: L2000001: ! 60: pushl 20(fp) # hfs ! 61: ldd two ! 62: pushd ! 63: ldd -60(fp) ! 64: pushd ! 65: callf $24,_Kmuld # x * 2 ! 66: ldd r0 ! 67: std -60(fp) # x *= 2; ! 68: decl -72(fp) # exp--;} ! 69: L20: cmpd2 -60(fp),half # while(x < 0.5){ ! 70: jlss L2000001 ! 71: bitl $1,-72(fp) # if(exp & 1) { ! 72: jeql L24 ! 73: pushl 20(fp) # hfs ! 74: ldd two ! 75: pushd ! 76: ldd -60(fp) ! 77: pushd ! 78: callf $24,_Kmuld # x * 2 ! 79: ldd r0 ! 80: std -60(fp) # x *= 2; ! 81: decl -72(fp) # exp--;} ! 82: L24: pushl 20(fp) # hfs ! 83: ldd -60(fp) ! 84: pushd ! 85: ldd one ! 86: pushd ! 87: callf $24,_Kaddd # (1.0+x) ! 88: pushl 20(fp) # hfs ! 89: ldd r0 ! 90: pushd ! 91: ldd half ! 92: pushd ! 93: callf $24,_Kmuld ! 94: ldd r0 ! 95: std -68(fp) # temp=0.5*(1.0+x); ! 96: jbr L28 ! 97: L2000003: ! 98: pushl 20(fp) # hfs ! 99: ldd big ! 100: pushd ! 101: ldd -68(fp) ! 102: pushd ! 103: callf $24,_Kmuld # temp*(1L<<30) ! 104: ldd r0 ! 105: std -68(fp) # temp *=(1L<<30); ! 106: subl2 $60,-72(fp) # exp -= 60;} ! 107: L28: cmpl -72(fp),$60 # while(exp > 60){ ! 108: jleq L31 ! 109: jbr L2000003 ! 110: L2000005: ! 111: pushl 20(fp) # hfs ! 112: ldd big ! 113: pushd ! 114: ldd -68(fp) ! 115: pushd ! 116: callf $24,_Kdivd ! 117: ldd r0 ! 118: std -68(fp) # temp /= (1L<<30); ! 119: addl2 $60,-72(fp) # exp +=60;} ! 120: L31: cmpl -72(fp),$-60 # while(exp < -60) { ! 121: jlss L2000005 ! 122: tstl -72(fp) # if(exp >=0) ! 123: jlss L34 ! 124: divl3 $2,-72(fp),r0 ! 125: shll r0,$1,r0 ! 126: pushl 20(fp) # hfs ! 127: pushl $0 ! 128: pushl r0 ! 129: pushl $0 ! 130: pushl $0 ! 131: callf $24,_Kcvtld ! 132: pushl 20(fp) # hfs ! 133: ldd r0 ! 134: pushd ! 135: ldd -68(fp) ! 136: pushd ! 137: callf $24,_Kmuld # temp * (1L <<(exp/2)) ! 138: jbr L2000006 # temp *= 1L << (exp/2)); ! 139: L34: mnegl -72(fp),r0 # -exp ! 140: divl2 $2,r0 # -exp/2 ! 141: shll r0,$1,r0 ! 142: pushl 20(fp) # hfs ! 143: pushl $0 ! 144: pushl r0 ! 145: pushl $0 ! 146: pushl $0 ! 147: callf $24,_Kcvtld ! 148: pushl 20(fp) # hfs ! 149: ldd r0 ! 150: pushd ! 151: ldd -68(fp) ! 152: pushd ! 153: callf $24,_Kdivd # temp / (1L <<(-exp/2)) ! 154: L2000006: ! 155: ldd r0 ! 156: std -68(fp) # temp (*/)= 1L << (exp/2)); ! 157: clrl -76(fp) ! 158: L2000008: ! 159: pushl 20(fp) # hfs ! 160: ldd -68(fp) ! 161: pushd ! 162: ldd 4(fp) ! 163: pushd ! 164: callf $24,_Kdivd ! 165: pushl 20(fp) # hfs ! 166: ldd r0 ! 167: pushd ! 168: ldd -68(fp) ! 169: pushd ! 170: callf $24,_Kaddd ! 171: pushl 20(fp) # hfs ! 172: ldd r0 ! 173: pushd ! 174: ldd half ! 175: pushd ! 176: callf $24,_Kmuld ! 177: ldd r0 ! 178: std -68(fp) # temp=0.5*(temp+arg/temp); ! 179: aobleq $3,-76(fp),L2000008 ! 180: ldd -68(fp) ! 181: cvdf ! 182: stf r0 ! 183: ret ! 184: ! 185: .data ! 186: .align 2 ! 187: half: .long 0x40000000, 0x00000000 # .double .5 ! 188: two: .long 0x41000000, 0x00000000 # .double 2 ! 189: one: .long 0x40800000, 0x00000000 # .double 1 ! 190: big: .long 0x4F800000, 0x00000000 # .double (1<<30)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.