1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)ldexp.s	2.3 (Berkeley) 6/12/88\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: /*
  13:  * double
  14:  * ldexp (value, exp)
  15:  *	double value;
  16:  *	int exp;
  17:  *
  18:  * Ldexp returns value*2**exp, if that result is in range.
  19:  * If underflow occurs, it returns zero.  If overflow occurs,
  20:  * it returns a value of appropriate sign and largest
  21:  * possible magnitude.  In case of either overflow or underflow,
  22:  * errno is set to ERANGE.  Note that errno is not modified if
  23:  * no error occurs.  Note also that the code assumes that both
  24:  * FIV and FIU are disabled in the floating point processor:
  25:  * FIV disabled prevents a trap from ocurring on floating overflow;
  26:  * FIU disabled cause a floating zero to be generated on floating underflow.
  27:  */
  28: 
  29: #include "DEFS.h"
  30: 
  31: ERANGE  = 34.                   / can't include <errno.h> because of the
  32: .comm   _errno,2                /   comments on each line ... (sigh)
  33: 
  34: .data
  35: huge:   077777; 0177777; 0177777; 0177777
  36: .text
  37: 
  38: ENTRY(ldexp)
  39:         movf    2(sp),fr0       / fr0 = value
  40:         cfcc
  41:         beq     2f              / done if zero
  42:         movei   fr0,r0          / r0 = log2(value)
  43:         add     10.(sp),r0      / add exp to log2(value) and stuff result
  44:         movie   r0,fr0          /   back as new exponent for fr0
  45:         cfcc                    / Overflow?
  46:         bvc     2f
  47:         movf    huge,fr0        / yes, fr0 = (value < 0.0) ? -huge : huge;
  48:         bpl     1f
  49:         negf    fr0
  50: 1:
  51:         mov     $ERANGE,_errno  /   and errno = ERANGE
  52: 2:
  53:         rts     pc

Defined functions

ERANGE defined in line 31; used 1 times
  • in line 51

Defined variables

_errno defined in line 32; used 890 times
huge defined in line 35; used 1 times
  • in line 47
Last modified: 1988-07-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4360
Valid CSS Valid XHTML 1.0 Strict