1: # 2: # Copyright (c) 1980 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: # @(#)log.s 5.1 (Berkeley) 5/8/85 7: # 8: # 9: # double log(arg) ; natural logarithm 10: # double log10(arg); base 10 log 11: # double arg 12: # if(arg<=0){ errno=EDOM; return(-1.7e+38); } 13: # nat. log computed from Hart&Cheney LOGE 2706 D=22.1 14: # J F Jarvis August 3, 1978 15: .set EDOM,33 16: .globl _log 17: .globl _log10 18: .globl _errno 19: .text 20: .align 1 21: _log10: 22: .word 0x0 23: bispsw $0xe0 24: movd 4(ap),-(sp) 25: calls $2,_log 26: muld2 log10e,r0 27: ret 28: .align 1 29: _log: 30: .word 0x07c0 31: bispsw $0xe0 32: movd 4(ap),r0 33: jgtr range 34: movl $EDOM,_errno 35: movd $0d-1.7e+38,r0 # machine dept max neg 36: ret 37: range: 38: extzv $7,$8,r0,r10 # r10 = exp(arg)+128 39: insv $128,$7,$8,r0 # r0,r1: 0.5<=frac(arg)<1.0 40: cmpd r0,sqrt2d2 41: jgeq comp 42: insv $129,$7,$8,r0 # frac *= 2 43: decl r10 # exp -= 1 44: comp: 45: subl2 $128,r10 # signed exp for scaled arg 46: subd3 $0d1.0e+0,r0,r6 # Hart&cheney LOGE 2706 47: addd2 $0d1.0e+0,r0 48: divd2 r0,r6 # r6,r7= (frac-1)/(frac+1) 49: muld3 r6,r6,r8 50: polyd r8,$3,pcoef 51: muld2 r0,r6 52: polyd r8,$4,qcoef 53: divd3 r0,r6,r0 54: cvtld r10,r2 55: muld2 log2,r2 # r2,r3= loge(2**exp) 56: addd2 r2,r0 57: ret 58: .data 59: .align 2 60: pcoef: 61: .double 0d-0.24550691103445385056e+2 62: .double 0d0.23616053565907671809e+3 63: .double 0d-0.54904361859132995001e+3 64: .double 0d0.35621151669903912407e+3 65: qcoef: 66: .double 0d0.10e+1 67: .double 0d-0.35526251110400238735e+2 68: .double 0d0.19375591463035879517e+3 69: .double 0d-0.33389039541217149928e+3 70: .double 0d0.17810575834951956204e+3 71: log10e: 72: .double 0d0.43429448190325182765e+0 73: sqrt2d2: 74: .double 0d0.70710678118654752440e+0 75: log2: 76: .double 0d0.69314718055994530941e+0