|
|
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 the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: */ ! 17: ! 18: #if defined(LIBC_SCCS) && !defined(lint) ! 19: .asciz "@(#)ldexp.s 5.4 (Berkeley) 6/27/88" ! 20: #endif /* LIBC_SCCS and not lint */ ! 21: ! 22: /* ! 23: * double ldexp (value, exp) ! 24: * double value; ! 25: * int exp; ! 26: * ! 27: * Ldexp returns value*2**exp, if that result is in range. ! 28: * If underflow occurs, it returns zero. If overflow occurs, ! 29: * it returns a value of appropriate sign and largest ! 30: * possible magnitude. In case of either overflow or underflow, ! 31: * errno is set to ERANGE. Note that errno is not modified if ! 32: * no error occurs. ! 33: */ ! 34: ! 35: #include "DEFS.h" ! 36: #include <errno.h> ! 37: ! 38: .globl _errno ! 39: ! 40: ENTRY(ldexp, 0) ! 41: movd 4(ap),r0 /* fetch "value" */ ! 42: extzv $7,$8,r0,r2 /* r2 := biased exponent */ ! 43: jeql 1f /* if zero, done */ ! 44: ! 45: addl2 12(ap),r2 /* r2 := new biased exponent */ ! 46: jleq 2f /* if <= 0, underflow */ ! 47: cmpl r2,$256 /* otherwise check if too big */ ! 48: jgeq 3f /* jump if overflow */ ! 49: insv r2,$7,$8,r0 /* put exponent back in result */ ! 50: 1: ! 51: ret ! 52: 2: ! 53: clrd r0 ! 54: jbr 1f ! 55: 3: ! 56: movd huge,r0 /* largest possible floating magnitude */ ! 57: jbc $15,4(ap),1f /* jump if argument was positive */ ! 58: mnegd r0,r0 /* if arg < 0, make result negative */ ! 59: 1: ! 60: movl $ERANGE,_errno ! 61: ret ! 62: ! 63: .data ! 64: huge: .word 0x7fff /* the largest number that can */ ! 65: .word 0xffff /* be represented in a long floating */ ! 66: .word 0xffff /* number. This is given in hex in order */ ! 67: .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.