1*61318Sbostic# Copyright (c) 1985, 1993 2*61318Sbostic# The Regents of the University of California. All rights reserved. 324570Szliu# 445308Sbostic# %sccs.include.redist.sh% 534125Sbostic# 6*61318Sbostic# @(#)sincos.s 8.1 (Berkeley) 06/04/93 734125Sbostic# 824729Selefunt .data 924729Selefunt .align 2 1024729Selefunt_sccsid: 11*61318Sbostic.asciz "@(#)sincos.s 1.1 (Berkeley) 8/21/85; 8.1 (ucb.elefunt) 06/04/93" 1224570Szliu 1324570Szliu# This is the implementation of Peter Tang's double precision 1424570Szliu# sine and cosine for the VAX using Bob Corbett's argument reduction. 1524570Szliu# 1624570Szliu# Notes: 1724570Szliu# under 1,024,000 random arguments testing on [0,2*pi] 1824570Szliu# sin() observed maximum error = 0.814 ulps 1924570Szliu# cos() observed maximum error = 0.792 ulps 2024570Szliu# 2124570Szliu# double sin(arg) 2224570Szliu# double arg; 2324570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 2424570Szliu# S. McDonald, April 4, 1985 2524570Szliu# 2624570Szliu .globl _sin 2724570Szliu .text 2824570Szliu .align 1 2924570Szliu 3024570Szliu_sin: .word 0xffc # save r2-r11 3124570Szliu movq 4(ap),r0 3224570Szliu bicw3 $0x807f,r0,r2 3324570Szliu beql 1f # if x is zero or reserved operand then return x 3424570Szliu# 3524570Szliu# Save the PSL's IV & FU bits on the stack. 3624570Szliu# 3724570Szliu movpsl r2 3824570Szliu bicw3 $0xff9f,r2,-(sp) 3924570Szliu# 4024570Szliu# Clear the IV & FU bits. 4124570Szliu# 4224570Szliu bicpsw $0x0060 4324570Szliu# 4424570Szliu# Entered by sine ; save 0 in r4 . 4524570Szliu# 4624570Szliu jsb libm$argred 4724570Szliu movl $0,r4 4824570Szliu jsb libm$sincos 4924570Szliu bispsw (sp)+ 5024570Szliu1: ret 5124570Szliu 5224570Szliu# 5324570Szliu# double cos(arg) 5424570Szliu# double arg; 5524570Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 5624570Szliu# S. McDonald, April 4, 1985 5724570Szliu# 5824570Szliu .globl _cos 5924570Szliu .text 6024570Szliu .align 1 6124570Szliu 6224570Szliu_cos: .word 0xffc # save r2-r11 6324570Szliu movq 4(ap),r0 6424570Szliu bicw3 $0x7f,r0,r2 6524570Szliu cmpw $0x8000,r2 6624570Szliu beql 1f # if x is reserved operand then return x 6724570Szliu# 6824570Szliu# Save the PSL's IV & FU bits on the stack. 6924570Szliu# 7024570Szliu movpsl r2 7124570Szliu bicw3 $0xff9f,r2,-(sp) 7224570Szliu# 7324570Szliu# Clear the IV & FU bits. 7424570Szliu# 7524570Szliu bicpsw $0x0060 7624570Szliu# 7724570Szliu# Entered by cosine ; save 1 in r4 . 7824570Szliu# 7924570Szliu jsb libm$argred 8024570Szliu movl $1,r4 8124570Szliu jsb libm$sincos 8224570Szliu bispsw (sp)+ 8324570Szliu1: ret 84