124573Szliu# Copyright (c) 1985 Regents of the University of California. 2*34125Sbostic# All rights reserved. 324573Szliu# 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# @(#)tan.s 5.2 (Berkeley) 04/29/88 17*34125Sbostic# 1824729Selefunt .data 1924729Selefunt .align 2 2024729Selefunt_sccsid: 21*34125Sbostic.asciz "@(#)tan.s 1.1 (Berkeley) 8/21/85; 5.2 (ucb.elefunt) 04/29/88" 2224573Szliu 2324573Szliu# This is the implementation of Peter Tang's double precision 2424573Szliu# tangent for the VAX using Bob Corbett's argument reduction. 2524573Szliu# 2624573Szliu# Notes: 2724573Szliu# under 1,024,000 random arguments testing on [0,2*pi] 2824573Szliu# tan() observed maximum error = 2.15 ulps 2924573Szliu# 3024573Szliu# double tan(arg) 3124573Szliu# double arg; 3224573Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 3324573Szliu# S. McDonald, April 4, 1985 3424573Szliu# 3524573Szliu .globl _tan 3624573Szliu .text 3724573Szliu .align 1 3824573Szliu 3924573Szliu_tan: .word 0xffc # save r2-r11 4024573Szliu movq 4(ap),r0 4124573Szliu bicw3 $0x807f,r0,r2 4224573Szliu beql 1f # if x is zero or reserved operand then return x 4324573Szliu# 4424573Szliu# Save the PSL's IV & FU bits on the stack. 4524573Szliu# 4624573Szliu movpsl r2 4724573Szliu bicw3 $0xff9f,r2,-(sp) 4824573Szliu# 4924573Szliu# Clear the IV & FU bits. 5024573Szliu# 5124573Szliu bicpsw $0x0060 5224573Szliu jsb libm$argred 5324573Szliu# 5424573Szliu# At this point, 5524573Szliu# r0 contains the quadrant number, 0, 1, 2, or 3; 5624573Szliu# r2/r1 contains the reduced argument as a D-format number; 5724573Szliu# r3 contains a F-format extension to the reduced argument; 5824573Szliu# 5924573Szliu# Save r3/r0 so that we can call cosine after calling sine. 6024573Szliu# 6124573Szliu movq r2,-(sp) 6224573Szliu movq r0,-(sp) 6324573Szliu# 6424573Szliu# Call sine. r4 = 0 implies sine. 6524573Szliu# 6624573Szliu movl $0,r4 6724573Szliu jsb libm$sincos 6824573Szliu# 6924573Szliu# Save sin(x) in r11/r10 . 7024573Szliu# 7124573Szliu movd r0,r10 7224573Szliu# 7324573Szliu# Call cosine. r4 = 1 implies cosine. 7424573Szliu# 7524573Szliu movq (sp)+,r0 7624573Szliu movq (sp)+,r2 7724573Szliu movl $1,r4 7824573Szliu jsb libm$sincos 7924573Szliu divd3 r0,r10,r0 8024573Szliu bispsw (sp)+ 8124573Szliu1: ret 82