xref: /csrg-svn/old/libm/liboldnm/cbrt.s (revision 20008)
1*20008Sdist#
2*20008Sdist# Copyright (c) 1980 Regents of the University of California.
3*20008Sdist# All rights reserved.  The Berkeley software License Agreement
4*20008Sdist# specifies the terms and conditions for redistribution.
5*20008Sdist#
6*20008Sdist#	@(#)cbrt.s	5.1 (Berkeley) 05/08/85
7*20008Sdist#
8*20008Sdist#
919995Sdist# double cbrt(arg)
1019995Sdist# double arg
1119995Sdist# no error exits
1219995Sdist#method: range reduction to [1/8,1], poly appox, newtons method
1319995Sdist# J F Jarvis, August 10,1978
1419995Sdist.globl	_cbrt
1519995Sdist.text
1619995Sdist.align	1
1719995Sdist_cbrt:
1819995Sdist	.word	0x00c0
1919995Sdist	bispsw	$0xe0
2019995Sdist	clrl	r3
2119995Sdist	movd	4(ap),r4
2219995Sdist	jgtr	range
2319995Sdist	jeql	retz
2419995Sdist	mnegd	r4,r4	# |arg| in r0,r1
2519995Sdist	movl	$0x100,r3	# sign bit of result
2619995Sdistrange:
2719995Sdist	extzv	$7,$8,r4,r6
2819995Sdist	insv	$128,$7,$8,r4	# 0.5<= frac: r4,r5 <1.0
2919995Sdist	clrl	r7
3019995Sdist	ediv	$3,r6,r6,r7	# r6= expnt/3; r7= expnt%3
3119995Sdist	addb2	$86,r6
3219995Sdist	bisl2	r3,r6	# sign,exponent of result
3319995Sdist	polyf	r4,$3,pcoef	# initial estimate is Hart&Cheney CBRT 0642
3419995Sdist						# D=4.1
3519995Sdist	muld3	r0,r0,r2	# Newtons method, iteration 1, H&C 6.1.10
3619995Sdist	divd3	r2,r4,r2
3719995Sdist	subd3	r2,r0,r2
3819995Sdist	muld2	third,r2
3919995Sdist	subd2	r2,r0	# D=8.2
4019995Sdist	muld3	r0,r0,r2	# iteration 2
4119995Sdist	divd3	r2,r4,r2
4219995Sdist	subd3	r2,r0,r2
4319995Sdist	muld2	third,r2
4419995Sdist	subd2	r2,r0
4519995Sdist	muld2	hc[r7],r0	# set range
4619995Sdist	insv	r6,$7,$9,r0	# set sign,exponent
4719995Sdist	ret
4819995Sdistretz:
4919995Sdist	clrd	r0
5019995Sdist	ret
5119995Sdist.data
5219995Sdist.align	2
5319995Sdistthird: .double 0d0.33333333333333333333e+0
5419995Sdisthc:
5519995Sdist	.double 0d1.25992104989487316476e+0
5619995Sdist	.double 0d1.58740105196819947475e+0
5719995Sdist	.double	0d1.0e+0
5819995Sdistpcoef:
5919995Sdist	.float 0f0.1467073818e+0
6019995Sdist	.float 0f-0.5173964673e+0
6119995Sdist	.float 0f0.9319858515e+0
6219995Sdist	.float 0f0.4387762363e+0
63