124570Szliu# Copyright (c) 1985 Regents of the University of California. 2*34125Sbostic# All rights reserved. 324570Szliu# 4*34125Sbostic# Redistribution and use in source and binary forms are permitted 5*34125Sbostic# provided that this notice is preserved and that due credit is given 6*34125Sbostic# to the University of California at Berkeley. The name of the University 7*34125Sbostic# may not be used to endorse or promote products derived from this 8*34125Sbostic# software without specific prior written permission. This software 9*34125Sbostic# is provided ``as is'' without express or implied warranty. 10*34125Sbostic# 11*34125Sbostic# All recipients should regard themselves as participants in an ongoing 12*34125Sbostic# research project and hence should feel obligated to report their 13*34125Sbostic# experiences (good or bad) with these elementary function codes, using 14*34125Sbostic# the sendbug(8) program, to the authors. 15*34125Sbostic# 16*34125Sbostic# @(#)sincos.s 5.2 (Berkeley) 04/29/88 17*34125Sbostic# 1824729Selefunt .data 1924729Selefunt .align 2 2024729Selefunt_sccsid: 21*34125Sbostic.asciz "@(#)sincos.s 1.1 (Berkeley) 8/21/85; 5.2 (ucb.elefunt) 04/29/88" 2224570Szliu 2324570Szliu# This is the implementation of Peter Tang's double precision 2424570Szliu# sine and cosine for the VAX using Bob Corbett's argument reduction. 2524570Szliu# 2624570Szliu# Notes: 2724570Szliu# under 1,024,000 random arguments testing on [0,2*pi] 2824570Szliu# sin() observed maximum error = 0.814 ulps 2924570Szliu# cos() observed maximum error = 0.792 ulps 3024570Szliu# 3124570Szliu# double sin(arg) 3224570Szliu# double arg; 3324570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 3424570Szliu# S. McDonald, April 4, 1985 3524570Szliu# 3624570Szliu .globl _sin 3724570Szliu .text 3824570Szliu .align 1 3924570Szliu 4024570Szliu_sin: .word 0xffc # save r2-r11 4124570Szliu movq 4(ap),r0 4224570Szliu bicw3 $0x807f,r0,r2 4324570Szliu beql 1f # if x is zero or reserved operand then return x 4424570Szliu# 4524570Szliu# Save the PSL's IV & FU bits on the stack. 4624570Szliu# 4724570Szliu movpsl r2 4824570Szliu bicw3 $0xff9f,r2,-(sp) 4924570Szliu# 5024570Szliu# Clear the IV & FU bits. 5124570Szliu# 5224570Szliu bicpsw $0x0060 5324570Szliu# 5424570Szliu# Entered by sine ; save 0 in r4 . 5524570Szliu# 5624570Szliu jsb libm$argred 5724570Szliu movl $0,r4 5824570Szliu jsb libm$sincos 5924570Szliu bispsw (sp)+ 6024570Szliu1: ret 6124570Szliu 6224570Szliu# 6324570Szliu# double cos(arg) 6424570Szliu# double arg; 6524570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 6624570Szliu# S. McDonald, April 4, 1985 6724570Szliu# 6824570Szliu .globl _cos 6924570Szliu .text 7024570Szliu .align 1 7124570Szliu 7224570Szliu_cos: .word 0xffc # save r2-r11 7324570Szliu movq 4(ap),r0 7424570Szliu bicw3 $0x7f,r0,r2 7524570Szliu cmpw $0x8000,r2 7624570Szliu beql 1f # if x is reserved operand then return x 7724570Szliu# 7824570Szliu# Save the PSL's IV & FU bits on the stack. 7924570Szliu# 8024570Szliu movpsl r2 8124570Szliu bicw3 $0xff9f,r2,-(sp) 8224570Szliu# 8324570Szliu# Clear the IV & FU bits. 8424570Szliu# 8524570Szliu bicpsw $0x0060 8624570Szliu# 8724570Szliu# Entered by cosine ; save 1 in r4 . 8824570Szliu# 8924570Szliu jsb libm$argred 9024570Szliu movl $1,r4 9124570Szliu jsb libm$sincos 9224570Szliu bispsw (sp)+ 9324570Szliu1: ret 94