|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #if defined(LIBC_SCCS) && !defined(lint) ! 21: .asciz "@(#)ldexp.s 5.6 (Berkeley) 6/1/90" ! 22: #endif /* LIBC_SCCS and not lint */ ! 23: ! 24: /* ! 25: * double ldexp (value, exp) ! 26: * double value; ! 27: * int exp; ! 28: * ! 29: * Ldexp returns value*2**exp, if that result is in range. ! 30: * If underflow occurs, it returns zero. If overflow occurs, ! 31: * it returns a value of appropriate sign and largest ! 32: * possible magnitude. In case of either overflow or underflow, ! 33: * errno is set to ERANGE. Note that errno is not modified if ! 34: * no error occurs. ! 35: */ ! 36: ! 37: #include "DEFS.h" ! 38: ! 39: /* ! 40: * don't include errno.h, ANSI C says it defines errno. ! 41: * ! 42: * #include <errno.h> ! 43: */ ! 44: #define ERANGE 34 ! 45: ! 46: .globl _errno ! 47: ! 48: ENTRY(ldexp, 0) ! 49: movd 4(ap),r0 /* fetch "value" */ ! 50: extzv $7,$8,r0,r2 /* r2 := biased exponent */ ! 51: jeql 1f /* if zero, done */ ! 52: ! 53: addl2 12(ap),r2 /* r2 := new biased exponent */ ! 54: jleq 2f /* if <= 0, underflow */ ! 55: cmpl r2,$256 /* otherwise check if too big */ ! 56: jgeq 3f /* jump if overflow */ ! 57: insv r2,$7,$8,r0 /* put exponent back in result */ ! 58: 1: ! 59: ret ! 60: 2: ! 61: clrd r0 ! 62: jbr 1f ! 63: 3: ! 64: movd huge,r0 /* largest possible floating magnitude */ ! 65: jbc $15,4(ap),1f /* jump if argument was positive */ ! 66: mnegd r0,r0 /* if arg < 0, make result negative */ ! 67: 1: ! 68: movl $ERANGE,_errno ! 69: ret ! 70: ! 71: .data ! 72: huge: .word 0x7fff /* the largest number that can */ ! 73: .word 0xffff /* be represented in a long floating */ ! 74: .word 0xffff /* number. This is given in hex in order */ ! 75: .word 0xffff /* to avoid floating conversions */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.