|
|
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: * @(#)Kmodf.s 7.1 (Berkeley) 12/6/90 ! 37: */ ! 38: ! 39: #include "../tahoe/SYS.h" ! 40: #include "../math/fp.h" ! 41: ! 42: /* ! 43: * float Kmodf (value, iptr, hfs) ! 44: * float value, *iptr; ! 45: * int hfs; ! 46: * ! 47: * Modf returns the fractional part of "value", ! 48: * and stores the integer part indirectly through "iptr". ! 49: */ ! 50: .text ! 51: ENTRY(Kmodf, R8|R7|R6|R5|R4|R3|R2) ! 52: /* ! 53: * Some initializations: ! 54: */ ! 55: clrl r3 ! 56: movl 4(fp),r0 /* fetch operand to r0. */ ! 57: movl 8(fp),r1 ! 58: movl 12(fp),r6 /* fetch addr of int to r6. */ ! 59: /* ! 60: * get exponent ! 61: */ ! 62: andl3 $EXPMASK,r0,r2 /* r2 will hold the exponent. */ ! 63: shrl $EXPSHIFT,r2,r2 ! 64: subl2 $BIAS,r2 /* unbias it. */ ! 65: jleq allfrac /* it's int part is zero. */ ! 66: cmpl r2,$56 ! 67: jgeq allint /* it's fraction part is zero. */ ! 68: /* ! 69: * get fraction ! 70: */ ! 71: movl r0,r4 /* remember the original number. */ ! 72: movl r1,r5 ! 73: bbc $31,r0,positive /* if negative remember it. */ ! 74: incl r3 ! 75: positive: ! 76: /* clear the non fraction parts. */ ! 77: andl2 $(0!(EXPMASK | SIGNBIT)),r0 ! 78: /* add the hidden bit. */ ! 79: orl2 $(0!CLEARHID),r0 ! 80: ! 81: cmpl r2,$HID_POS /* see if there are bits to clear only in r0 */ ! 82: jgtr in_r1 /* some bytes in r1 */ ! 83: jeql onlyallr0 /* all r0 must be cleared. */ ! 84: mnegl r2,r7 /* r7 - loop counter. */ ! 85: movl $CLEARHID,r8 /* first bit to clear. */ ! 86: 1: ! 87: andl2 r8,r0 /* clear int. bits from fraction part. */ ! 88: shar $1,r8,r8 ! 89: aoblss $0,r7,1b ! 90: 1: ! 91: andl2 r8,r4 /* clear frac bits for int calculation: */ ! 92: shar $1,r8,r8 ! 93: cmpl $0xffffffff,r8 ! 94: jneq 1b ! 95: clrl r5 ! 96: jmp norm ! 97: ! 98: onlyallr0: ! 99: clrl r0 ! 100: clrl r5 ! 101: jmp norm ! 102: ! 103: in_r1: ! 104: clrl r0 ! 105: subl3 r2,$HID_POS,r7 ! 106: movl $0x7fffffff,r8 ! 107: 1: ! 108: andl2 r8,r1 ! 109: shar $1,r8,r8 ! 110: orl2 $0x80000000,r8 ! 111: aoblss $0,r7,1b ! 112: 1: ! 113: andl2 r8,r5 ! 114: shar $1,r8,r8 ! 115: cmpl $0xffffffff,r8 ! 116: jneq 1b ! 117: norm: ! 118: addl2 $BIAS,r2 /* fnorm expects it biased. */ ! 119: pushl 16(fp) /* hfs */ ! 120: callf $8,_Kfnorm /* normelize fraction part. */ ! 121: cmpl $0,r0 ! 122: jeql 1f ! 123: bbc $0,r3,1f ! 124: orl2 $0x80000000,r0 ! 125: 1: ! 126: movl r4,(r6) /* put int part in place. */ ! 127: movl r5,4(r6) ! 128: ret ! 129: ! 130: allint: ! 131: movl r0,(r6) /* copy the argument to the int addr. */ ! 132: movl r1,4(r6) ! 133: clrl r0 /* clear the fraction part. */ ! 134: clrl r1 ! 135: ret ! 136: ! 137: allfrac: ! 138: /* the fraction is ready in r0. */ ! 139: clrl (r6) /* zero the int part. */ ! 140: clrl 4(r6) ! 141: ret ! 142: ! 143: ret_zero: ! 144: clrl (r6) ! 145: clrl 4(r6) ! 146: clrl r0 ! 147: clrl r1 ! 148: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.