xref: /csrg-svn/lib/libm/vax/sincos.s (revision 24729)
124570Szliu#
224570Szliu# Copyright (c) 1985 Regents of the University of California.
324570Szliu#
424570Szliu# Use and reproduction of this software are granted  in  accordance  with
524570Szliu# the terms and conditions specified in  the  Berkeley  Software  License
624570Szliu# Agreement (in particular, this entails acknowledgement of the programs'
724570Szliu# source, and inclusion of this notice) with the additional understanding
824570Szliu# that  all  recipients  should regard themselves as participants  in  an
924570Szliu# ongoing  research  project and hence should  feel  obligated  to report
1024570Szliu# their  experiences (good or bad) with these elementary function  codes,
1124570Szliu# using "sendbug 4bsd-bugs@BERKELEY", to the authors.
1224570Szliu#
13*24729Selefunt	.data
14*24729Selefunt	.align	2
15*24729Selefunt_sccsid:
16*24729Selefunt.asciz	"@(#)sincos.s	1.1 (Berkeley) 8/21/85; 1.3 (ucb.elefunt) 09/12/85"
1724570Szliu
1824570Szliu#  This is the implementation of Peter Tang's double precision
1924570Szliu#  sine and cosine for the VAX using Bob Corbett's argument reduction.
2024570Szliu#
2124570Szliu#  Notes:
2224570Szliu#       under 1,024,000 random arguments testing on [0,2*pi]
2324570Szliu#       sin() observed maximum error = 0.814 ulps
2424570Szliu#       cos() observed maximum error = 0.792 ulps
2524570Szliu#
2624570Szliu# double sin(arg)
2724570Szliu# double arg;
2824570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang  &  B. Corbett
2924570Szliu# S. McDonald, April 4,  1985
3024570Szliu#
3124570Szliu	.globl	_sin
3224570Szliu	.text
3324570Szliu	.align	1
3424570Szliu
3524570Szliu_sin:	.word	0xffc		# save r2-r11
3624570Szliu	movq	4(ap),r0
3724570Szliu	bicw3	$0x807f,r0,r2
3824570Szliu	beql	1f		# if x is zero or reserved operand then return x
3924570Szliu#
4024570Szliu# Save the PSL's IV & FU bits on the stack.
4124570Szliu#
4224570Szliu	movpsl	r2
4324570Szliu	bicw3	$0xff9f,r2,-(sp)
4424570Szliu#
4524570Szliu# Clear the IV & FU bits.
4624570Szliu#
4724570Szliu	bicpsw	$0x0060
4824570Szliu#
4924570Szliu#  Entered by  sine    ; save  0  in  r4 .
5024570Szliu#
5124570Szliu	jsb	libm$argred
5224570Szliu	movl	$0,r4
5324570Szliu	jsb	libm$sincos
5424570Szliu	bispsw	(sp)+
5524570Szliu1:	ret
5624570Szliu
5724570Szliu#
5824570Szliu# double cos(arg)
5924570Szliu# double arg;
6024570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang  &  B. Corbett
6124570Szliu# S. McDonald, April 4,  1985
6224570Szliu#
6324570Szliu	.globl	_cos
6424570Szliu	.text
6524570Szliu	.align	1
6624570Szliu
6724570Szliu_cos:	.word	0xffc		# save r2-r11
6824570Szliu	movq	4(ap),r0
6924570Szliu	bicw3	$0x7f,r0,r2
7024570Szliu	cmpw	$0x8000,r2
7124570Szliu	beql	1f		# if x is reserved operand then return x
7224570Szliu#
7324570Szliu# Save the PSL's IV & FU bits on the stack.
7424570Szliu#
7524570Szliu	movpsl	r2
7624570Szliu	bicw3	$0xff9f,r2,-(sp)
7724570Szliu#
7824570Szliu# Clear the IV & FU bits.
7924570Szliu#
8024570Szliu	bicpsw	$0x0060
8124570Szliu#
8224570Szliu#  Entered by  cosine  ; save  1  in  r4 .
8324570Szliu#
8424570Szliu	jsb	libm$argred
8524570Szliu	movl	$1,r4
8624570Szliu	jsb	libm$sincos
8724570Szliu	bispsw	(sp)+
8824570Szliu1:	ret
89