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