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