1: #ifdef LIBC_SCCS
   2:         .asciz  "@(#)ldexp.s	5.2 (Berkeley) 3/9/86"
   3: #endif LIBC_SCCS
   4: 
   5: /*
   6:  * double ldexp (value, exp)
   7:  * double value;
   8:  * int exp;
   9:  *
  10:  * Ldexp returns value*2**exp, if that result is in range.
  11:  * If underflow occurs, it returns zero.  If overflow occurs,
  12:  * it returns a value of appropriate sign and largest
  13:  * possible magnitude.  In case of either overflow or underflow,
  14:  * errno is set to ERANGE.  Note that errno is not modified if
  15:  * no error occurs.
  16:  */
  17: 
  18: #include "DEFS.h"
  19: #include <errno.h>
  20: 
  21:         .globl  _errno
  22: 
  23: ENTRY(ldexp, 0)
  24:         movd    4(ap),r0        /* fetch "value" */
  25:         extzv   $7,$8,r0,r2     /* r2 := biased exponent */
  26:         jeql    1f              /* if zero, done */
  27: 
  28:         addl2   12(ap),r2       /* r2 := new biased exponent */
  29:         jleq    2f              /* if <= 0, underflow */
  30:         cmpl    r2,$256         /* otherwise check if too big */
  31:         jgeq    3f              /* jump if overflow */
  32:         insv    r2,$7,$8,r0     /* put exponent back in result */
  33: 1:
  34:         ret
  35: 2:
  36:         clrd    r0
  37:         jbr     1f
  38: 3:
  39:         movd    huge,r0         /* largest possible floating magnitude */
  40:         jbc     $15,4(ap),1f    /* jump if argument was positive */
  41:         mnegd   r0,r0           /* if arg < 0, make result negative */
  42: 1:
  43:         movl    $ERANGE,_errno
  44:         ret
  45: 
  46:         .data
  47: huge:   .word   0x7fff          /* the largest number that can */
  48:         .word   0xffff          /*   be represented in a long floating */
  49:         .word   0xffff          /*   number.  This is given in hex in order */
  50:         .word   0xffff          /*   to avoid floating conversions */

Defined functions

Defined variables

huge defined in line 47; used 1 times
  • in line 39
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 583
Valid CSS Valid XHTML 1.0 Strict