xref: /csrg-svn/lib/libm/vax/tan.s (revision 24729)
124573Szliu#
224573Szliu# Copyright (c) 1985 Regents of the University of California.
324573Szliu#
424573Szliu# Use and reproduction of this software are granted  in  accordance  with
524573Szliu# the terms and conditions specified in  the  Berkeley  Software  License
624573Szliu# Agreement (in particular, this entails acknowledgement of the programs'
724573Szliu# source, and inclusion of this notice) with the additional understanding
824573Szliu# that  all  recipients  should regard themselves as participants  in  an
924573Szliu# ongoing  research  project and hence should  feel  obligated  to report
1024573Szliu# their  experiences (good or bad) with these elementary function  codes,
1124573Szliu# using "sendbug 4bsd-bugs@BERKELEY", to the authors.
1224573Szliu#
13*24729Selefunt	.data
14*24729Selefunt	.align	2
15*24729Selefunt_sccsid:
16*24729Selefunt.asciz	"@(#)tan.s	1.1 (Berkeley) 8/21/85; 1.3 (ucb.elefunt) 09/12/85"
1724573Szliu
1824573Szliu#  This is the implementation of Peter Tang's double precision
1924573Szliu#  tangent for the VAX using Bob Corbett's argument reduction.
2024573Szliu#
2124573Szliu#  Notes:
2224573Szliu#       under 1,024,000 random arguments testing on [0,2*pi]
2324573Szliu#       tan() observed maximum error = 2.15 ulps
2424573Szliu#
2524573Szliu# double tan(arg)
2624573Szliu# double arg;
2724573Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang  &  B. Corbett
2824573Szliu# S. McDonald, April 4,  1985
2924573Szliu#
3024573Szliu	.globl	_tan
3124573Szliu	.text
3224573Szliu	.align	1
3324573Szliu
3424573Szliu_tan:	.word	0xffc		# save r2-r11
3524573Szliu	movq	4(ap),r0
3624573Szliu	bicw3	$0x807f,r0,r2
3724573Szliu	beql	1f		# if x is zero or reserved operand then return x
3824573Szliu#
3924573Szliu# Save the PSL's IV & FU bits on the stack.
4024573Szliu#
4124573Szliu	movpsl	r2
4224573Szliu	bicw3	$0xff9f,r2,-(sp)
4324573Szliu#
4424573Szliu#  Clear the IV & FU bits.
4524573Szliu#
4624573Szliu	bicpsw	$0x0060
4724573Szliu	jsb	libm$argred
4824573Szliu#
4924573Szliu#  At this point,
5024573Szliu#	   r0  contains the quadrant number, 0, 1, 2, or 3;
5124573Szliu#	r2/r1  contains the reduced argument as a D-format number;
5224573Szliu#  	   r3  contains a F-format extension to the reduced argument;
5324573Szliu#
5424573Szliu#  Save  r3/r0  so that we can call cosine after calling sine.
5524573Szliu#
5624573Szliu	movq	r2,-(sp)
5724573Szliu	movq	r0,-(sp)
5824573Szliu#
5924573Szliu#  Call sine.  r4 = 0  implies sine.
6024573Szliu#
6124573Szliu	movl	$0,r4
6224573Szliu	jsb	libm$sincos
6324573Szliu#
6424573Szliu#  Save  sin(x)  in  r11/r10 .
6524573Szliu#
6624573Szliu	movd	r0,r10
6724573Szliu#
6824573Szliu#  Call cosine.  r4 = 1  implies cosine.
6924573Szliu#
7024573Szliu	movq	(sp)+,r0
7124573Szliu	movq	(sp)+,r2
7224573Szliu	movl	$1,r4
7324573Szliu	jsb	libm$sincos
7424573Szliu	divd3	r0,r10,r0
7524573Szliu	bispsw	(sp)+
7624573Szliu1:	ret
77