1# Copyright (c) 1985 Regents of the University of California. 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms are permitted 5# provided that this notice is preserved and that due credit is given 6# to the University of California at Berkeley. The name of the University 7# may not be used to endorse or promote products derived from this 8# software without specific prior written permission. This software 9# is provided ``as is'' without express or implied warranty. 10# 11# All recipients should regard themselves as participants in an ongoing 12# research project and hence should feel obligated to report their 13# experiences (good or bad) with these elementary function codes, using 14# the sendbug(8) program, to the authors. 15# 16# @(#)sincos.s 5.2 (Berkeley) 04/29/88 17# 18 .data 19 .align 2 20_sccsid: 21.asciz "@(#)sincos.s 1.1 (Berkeley) 8/21/85; 5.2 (ucb.elefunt) 04/29/88" 22 23# This is the implementation of Peter Tang's double precision 24# sine and cosine for the VAX using Bob Corbett's argument reduction. 25# 26# Notes: 27# under 1,024,000 random arguments testing on [0,2*pi] 28# sin() observed maximum error = 0.814 ulps 29# cos() observed maximum error = 0.792 ulps 30# 31# double sin(arg) 32# double arg; 33# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 34# S. McDonald, April 4, 1985 35# 36 .globl _sin 37 .text 38 .align 1 39 40_sin: .word 0xffc # save r2-r11 41 movq 4(ap),r0 42 bicw3 $0x807f,r0,r2 43 beql 1f # if x is zero or reserved operand then return x 44# 45# Save the PSL's IV & FU bits on the stack. 46# 47 movpsl r2 48 bicw3 $0xff9f,r2,-(sp) 49# 50# Clear the IV & FU bits. 51# 52 bicpsw $0x0060 53# 54# Entered by sine ; save 0 in r4 . 55# 56 jsb libm$argred 57 movl $0,r4 58 jsb libm$sincos 59 bispsw (sp)+ 601: ret 61 62# 63# double cos(arg) 64# double arg; 65# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 66# S. McDonald, April 4, 1985 67# 68 .globl _cos 69 .text 70 .align 1 71 72_cos: .word 0xffc # save r2-r11 73 movq 4(ap),r0 74 bicw3 $0x7f,r0,r2 75 cmpw $0x8000,r2 76 beql 1f # if x is reserved operand then return x 77# 78# Save the PSL's IV & FU bits on the stack. 79# 80 movpsl r2 81 bicw3 $0xff9f,r2,-(sp) 82# 83# Clear the IV & FU bits. 84# 85 bicpsw $0x0060 86# 87# Entered by cosine ; save 1 in r4 . 88# 89 jsb libm$argred 90 movl $1,r4 91 jsb libm$sincos 92 bispsw (sp)+ 931: ret 94