xref: /original-bsd/lib/libm/vax/tan.s (revision 2301fdfb)
1# Copyright (c) 1985 Regents of the University of California.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms are permitted
5# provided that the above copyright notice and this paragraph are
6# duplicated in all such forms and that any documentation,
7# advertising materials, and other materials related to such
8# distribution and use acknowledge that the software was developed
9# by the University of California, Berkeley.  The name of the
10# University may not be used to endorse or promote products derived
11# from this software without specific prior written permission.
12# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15#
16# All recipients should regard themselves as participants in an ongoing
17# research project and hence should feel obligated to report their
18# experiences (good or bad) with these elementary function codes, using
19# the sendbug(8) program, to the authors.
20#
21#	@(#)tan.s	5.3 (Berkeley) 06/30/88
22#
23	.data
24	.align	2
25_sccsid:
26.asciz	"@(#)tan.s	1.1 (Berkeley) 8/21/85; 5.3 (ucb.elefunt) 06/30/88"
27
28#  This is the implementation of Peter Tang's double precision
29#  tangent for the VAX using Bob Corbett's argument reduction.
30#
31#  Notes:
32#       under 1,024,000 random arguments testing on [0,2*pi]
33#       tan() observed maximum error = 2.15 ulps
34#
35# double tan(arg)
36# double arg;
37# method: true range reduction to [-pi/4,pi/4], P. Tang  &  B. Corbett
38# S. McDonald, April 4,  1985
39#
40	.globl	_tan
41	.text
42	.align	1
43
44_tan:	.word	0xffc		# save r2-r11
45	movq	4(ap),r0
46	bicw3	$0x807f,r0,r2
47	beql	1f		# if x is zero or reserved operand then return x
48#
49# Save the PSL's IV & FU bits on the stack.
50#
51	movpsl	r2
52	bicw3	$0xff9f,r2,-(sp)
53#
54#  Clear the IV & FU bits.
55#
56	bicpsw	$0x0060
57	jsb	libm$argred
58#
59#  At this point,
60#	   r0  contains the quadrant number, 0, 1, 2, or 3;
61#	r2/r1  contains the reduced argument as a D-format number;
62#  	   r3  contains a F-format extension to the reduced argument;
63#
64#  Save  r3/r0  so that we can call cosine after calling sine.
65#
66	movq	r2,-(sp)
67	movq	r0,-(sp)
68#
69#  Call sine.  r4 = 0  implies sine.
70#
71	movl	$0,r4
72	jsb	libm$sincos
73#
74#  Save  sin(x)  in  r11/r10 .
75#
76	movd	r0,r10
77#
78#  Call cosine.  r4 = 1  implies cosine.
79#
80	movq	(sp)+,r0
81	movq	(sp)+,r2
82	movl	$1,r4
83	jsb	libm$sincos
84	divd3	r0,r10,r0
85	bispsw	(sp)+
861:	ret
87