xref: /original-bsd/old/libm/liboldnm/tan.s (revision 0fc6f013)
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#	@(#)tan.s	5.1 (Berkeley) 05/08/85
7#
8#
9# double tan(arg)
10# double arg;
11#method: range reduction to [0,pi/4] followed by polynomial
12# approximation:  Hart&Cheney TAN 4285 D=19.74
13.globl	_tan
14.text
15.align	1
16_tan:
17	.word	0x07c0
18	bispsw	$0xe0
19	clrl	r10	# sign flag, !=0 negate result
20	movd	4(ap),r0
21	jgeq	c1
22	xorw2	$0x8000,r10
23	mnegd	r0,r0
24c1:
25	emodd	fopi,fopix,r0,r2,r6
26	bicl2	$~3,r2
27	caseb	r2,$0,$3
28a0:	.word	a1-a0,a2-a0,a3-a0,a4-a0
29a2:	subd3	r6,$0d1.0e+0,r6
30	jbr	b1
31a3: xorw2	$0x8000,r10
32b1:	bsbb	rtan
33	jneq	b2	# tests final result cmptd in rtan
34	movd	funy,r0
35	jbr	b3
36b2:	divd3	r0,$0d1.0e+0,r0
37b3:	xorw2	r10,r0	# negate result if flag != 0
38	ret
39a4:	subd3	r6,$0d1.0e+0,r6
40	xorw2	$0x8000,r10
41a1:	bsbb	rtan
42	xorw2	r10,r0
43	ret
44rtan:
45	muld3	r6,r6,r8
46	polyd	r8,$4,pcoef
47	muld2	r0,r6
48	polyd	r8,$3,qcoef
49	divd3	r0,r6,r0
50	rsb
51.data
52.align	2
53funy:	.double	0d1.7e+38
54pcoef:
55	.double 0d0.33866386426771720960e-4
56	.double 0d0.34225543872410034353e-1
57	.double 0d-0.15506856534832663769e+2
58	.double 0d0.10559709017149531936e+4
59	.double 0d-0.13068202647548256682e+5
60qcoef:
61	.double 0d1.0e+0
62	.double 0d-0.15550331640317099669e+3
63	.double 0d0.47657513629164836989e+4
64	.double 0d-0.16638952389471190018e+5
65fopi:
66	.double 0d1.27323954473516268e+0
67fopix: .byte 0x29
68