xref: /csrg-svn/lib/libm/vax/tan.s (revision 24573)
1*24573Szliu#
2*24573Szliu# Copyright (c) 1985 Regents of the University of California.
3*24573Szliu#
4*24573Szliu# Use and reproduction of this software are granted  in  accordance  with
5*24573Szliu# the terms and conditions specified in  the  Berkeley  Software  License
6*24573Szliu# Agreement (in particular, this entails acknowledgement of the programs'
7*24573Szliu# source, and inclusion of this notice) with the additional understanding
8*24573Szliu# that  all  recipients  should regard themselves as participants  in  an
9*24573Szliu# ongoing  research  project and hence should  feel  obligated  to report
10*24573Szliu# their  experiences (good or bad) with these elementary function  codes,
11*24573Szliu# using "sendbug 4bsd-bugs@BERKELEY", to the authors.
12*24573Szliu#
13*24573Szliu
14*24573Szliu# @(#)tan.s	1.1 (ELEFUNT) 09/06/85
15*24573Szliu
16*24573Szliu#  This is the implementation of Peter Tang's double precision
17*24573Szliu#  tangent for the VAX using Bob Corbett's argument reduction.
18*24573Szliu#
19*24573Szliu#  Notes:
20*24573Szliu#       under 1,024,000 random arguments testing on [0,2*pi]
21*24573Szliu#       tan() observed maximum error = 2.15 ulps
22*24573Szliu#
23*24573Szliu# double tan(arg)
24*24573Szliu# double arg;
25*24573Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang  &  B. Corbett
26*24573Szliu# S. McDonald, April 4,  1985
27*24573Szliu#
28*24573Szliu	.globl	_tan
29*24573Szliu	.text
30*24573Szliu	.align	1
31*24573Szliu
32*24573Szliu_tan:	.word	0xffc		# save r2-r11
33*24573Szliu	movq	4(ap),r0
34*24573Szliu	bicw3	$0x807f,r0,r2
35*24573Szliu	beql	1f		# if x is zero or reserved operand then return x
36*24573Szliu#
37*24573Szliu# Save the PSL's IV & FU bits on the stack.
38*24573Szliu#
39*24573Szliu	movpsl	r2
40*24573Szliu	bicw3	$0xff9f,r2,-(sp)
41*24573Szliu#
42*24573Szliu#  Clear the IV & FU bits.
43*24573Szliu#
44*24573Szliu	bicpsw	$0x0060
45*24573Szliu	jsb	libm$argred
46*24573Szliu#
47*24573Szliu#  At this point,
48*24573Szliu#	   r0  contains the quadrant number, 0, 1, 2, or 3;
49*24573Szliu#	r2/r1  contains the reduced argument as a D-format number;
50*24573Szliu#  	   r3  contains a F-format extension to the reduced argument;
51*24573Szliu#
52*24573Szliu#  Save  r3/r0  so that we can call cosine after calling sine.
53*24573Szliu#
54*24573Szliu	movq	r2,-(sp)
55*24573Szliu	movq	r0,-(sp)
56*24573Szliu#
57*24573Szliu#  Call sine.  r4 = 0  implies sine.
58*24573Szliu#
59*24573Szliu	movl	$0,r4
60*24573Szliu	jsb	libm$sincos
61*24573Szliu#
62*24573Szliu#  Save  sin(x)  in  r11/r10 .
63*24573Szliu#
64*24573Szliu	movd	r0,r10
65*24573Szliu#
66*24573Szliu#  Call cosine.  r4 = 1  implies cosine.
67*24573Szliu#
68*24573Szliu	movq	(sp)+,r0
69*24573Szliu	movq	(sp)+,r2
70*24573Szliu	movl	$1,r4
71*24573Szliu	jsb	libm$sincos
72*24573Szliu	divd3	r0,r10,r0
73*24573Szliu	bispsw	(sp)+
74*24573Szliu1:	ret
75