don't copyright the sed script
[unix-history] / usr / src / lib / libm / vax / tan.s
CommitLineData
925e4449 1# Copyright (c) 1985 Regents of the University of California.
fe5be67b
KB
2# All rights reserved.
3#
2bc65d90 4# %sccs.include.redist.sh%
fe5be67b 5#
2bc65d90 6# @(#)tan.s 5.4 (Berkeley) %G%
925e4449 7#
7c0a3811
GK
8 .data
9 .align 2
10_sccsid:
2bc65d90 11.asciz "@(#)tan.s 1.1 (Berkeley) 8/21/85; 5.4 (ucb.elefunt) %G%"
925e4449
ZAL
12
13# This is the implementation of Peter Tang's double precision
14# tangent for the VAX using Bob Corbett's argument reduction.
15#
16# Notes:
17# under 1,024,000 random arguments testing on [0,2*pi]
18# tan() observed maximum error = 2.15 ulps
19#
20# double tan(arg)
21# double arg;
22# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett
23# S. McDonald, April 4, 1985
24#
25 .globl _tan
26 .text
27 .align 1
28
29_tan: .word 0xffc # save r2-r11
30 movq 4(ap),r0
31 bicw3 $0x807f,r0,r2
32 beql 1f # if x is zero or reserved operand then return x
33#
34# Save the PSL's IV & FU bits on the stack.
35#
36 movpsl r2
37 bicw3 $0xff9f,r2,-(sp)
38#
39# Clear the IV & FU bits.
40#
41 bicpsw $0x0060
42 jsb libm$argred
43#
44# At this point,
45# r0 contains the quadrant number, 0, 1, 2, or 3;
46# r2/r1 contains the reduced argument as a D-format number;
47# r3 contains a F-format extension to the reduced argument;
48#
49# Save r3/r0 so that we can call cosine after calling sine.
50#
51 movq r2,-(sp)
52 movq r0,-(sp)
53#
54# Call sine. r4 = 0 implies sine.
55#
56 movl $0,r4
57 jsb libm$sincos
58#
59# Save sin(x) in r11/r10 .
60#
61 movd r0,r10
62#
63# Call cosine. r4 = 1 implies cosine.
64#
65 movq (sp)+,r0
66 movq (sp)+,r2
67 movl $1,r4
68 jsb libm$sincos
69 divd3 r0,r10,r0
70 bispsw (sp)+
711: ret