11.10Sriastrad/* $NetBSD: n_sincos.S,v 1.10 2024/05/06 15:33:04 riastradh Exp $ */ 21.1Sragge/* 31.1Sragge * Copyright (c) 1985, 1993 41.1Sragge * The Regents of the University of California. All rights reserved. 51.1Sragge * 61.1Sragge * Redistribution and use in source and binary forms, with or without 71.1Sragge * modification, are permitted provided that the following conditions 81.1Sragge * are met: 91.1Sragge * 1. Redistributions of source code must retain the above copyright 101.1Sragge * notice, this list of conditions and the following disclaimer. 111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright 121.1Sragge * notice, this list of conditions and the following disclaimer in the 131.1Sragge * documentation and/or other materials provided with the distribution. 141.8Sagc * 3. Neither the name of the University nor the names of its contributors 151.1Sragge * may be used to endorse or promote products derived from this software 161.1Sragge * without specific prior written permission. 171.1Sragge * 181.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 191.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211.1Sragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 221.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281.1Sragge * SUCH DAMAGE. 291.1Sragge * 301.1Sragge * @(#)sincos.s 8.1 (Berkeley) 6/4/93 311.1Sragge */ 321.1Sragge 331.1Sragge/* 341.3Ssimonb * This is the implementation of Peter Tang's double precision 351.1Sragge * sine and cosine for the VAX using Bob Corbett's argument reduction. 361.3Ssimonb * 371.1Sragge * Notes: 381.3Ssimonb * under 1,024,000 random arguments testing on [0,2*pi] 391.1Sragge * sin() observed maximum error = 0.814 ulps 401.1Sragge * cos() observed maximum error = 0.792 ulps 411.1Sragge * 421.1Sragge * double sin(arg) 431.1Sragge * double arg; 441.1Sragge * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 451.1Sragge * S. McDonald, April 4, 1985 461.1Sragge */ 471.2Smatt#include <machine/asm.h> 481.4Smatt 491.10SriastradWEAK_ALIAS(sinf, _sinf) 501.10SriastradENTRY(_sinf, 0) 511.7Smatt cvtfd 4(%ap),-(%sp) 521.10Sriastrad calls $2,_C_LABEL(_sin) 531.7Smatt cvtdf %r0,%r0 541.6Smatt ret 551.10SriastradEND(_sinf) 561.6Smatt 571.10SriastradWEAK_ALIAS(sinl, _sinl) 581.10SriastradSTRONG_ALIAS(_sinl, _sin) 591.9Smartin 601.10SriastradWEAK_ALIAS(sin, _sin) 611.10SriastradENTRY(_sin, 0xfc0) 621.5Smatt movq 4(%ap),%r0 631.5Smatt bicw3 $0x807f,%r0,%r2 641.1Sragge beql 1f # if x is zero or reserved operand then return x 651.1Sragge/* 661.1Sragge * Save the PSL's IV & FU bits on the stack. 671.1Sragge */ 681.5Smatt movpsl %r2 691.5Smatt bicw3 $0xff9f,%r2,-(%sp) 701.1Sragge/* 711.1Sragge * Clear the IV & FU bits. 721.1Sragge */ 731.1Sragge bicpsw $0x0060 741.1Sragge/* 751.5Smatt * Entered by sine ; save 0 in %r4 . 761.1Sragge */ 771.4Smatt jsb _C_LABEL(__libm_argred)+2 781.5Smatt movl $0,%r4 791.4Smatt jsb _C_LABEL(__libm_sincos)+2 801.5Smatt bispsw (%sp)+ 811.1Sragge1: ret 821.10SriastradEND(_sin) 831.1Sragge 841.1Sragge/* 851.1Sragge * double cos(arg) 861.1Sragge * double arg; 871.1Sragge * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 881.1Sragge * S. McDonald, April 4, 1985 891.1Sragge */ 901.6Smatt 911.10SriastradWEAK_ALIAS(cosf, _cosf) 921.10SriastradENTRY(_cosf, 0) 931.7Smatt cvtfd 4(%ap),-(%sp) 941.10Sriastrad calls $2,_C_LABEL(_cos) 951.7Smatt cvtdf %r0,%r0 961.6Smatt ret 971.10SriastradEND(_cosf) 981.4Smatt 991.10SriastradWEAK_ALIAS(cosl, _cosl) 1001.10SriastradSTRONG_ALIAS(_cosl, _cos) 1011.9Smartin 1021.10SriastradWEAK_ALIAS(cos, _cos) 1031.10SriastradENTRY(_cos, 0x0fc0) 1041.5Smatt movq 4(%ap),%r0 1051.5Smatt bicw3 $0x7f,%r0,%r2 1061.5Smatt cmpw $0x8000,%r2 1071.1Sragge beql 1f # if x is reserved operand then return x 1081.1Sragge/* 1091.1Sragge * Save the PSL's IV & FU bits on the stack. 1101.1Sragge */ 1111.5Smatt movpsl %r2 1121.5Smatt bicw3 $0xff9f,%r2,-(%sp) 1131.1Sragge/* 1141.1Sragge * Clear the IV & FU bits. 1151.1Sragge */ 1161.1Sragge bicpsw $0x0060 1171.1Sragge/* 1181.5Smatt * Entered by cosine ; save 1 in %r4 . 1191.1Sragge */ 1201.4Smatt jsb _C_LABEL(__libm_argred)+2 1211.5Smatt movl $1,%r4 1221.4Smatt jsb _C_LABEL(__libm_sincos)+2 1231.5Smatt bispsw (%sp)+ 1241.1Sragge1: ret 1251.10SriastradEND(_cos) 126