1*61318Sbostic# Copyright (c) 1985, 1993 2*61318Sbostic# The Regents of the University of California. All rights reserved. 324573Szliu# 445308Sbostic# %sccs.include.redist.sh% 534125Sbostic# 6*61318Sbostic# @(#)tan.s 8.1 (Berkeley) 06/04/93 734125Sbostic# 824729Selefunt .data 924729Selefunt .align 2 1024729Selefunt_sccsid: 11*61318Sbostic.asciz "@(#)tan.s 1.1 (Berkeley) 8/21/85; 8.1 (ucb.elefunt) 06/04/93" 1224573Szliu 1324573Szliu# This is the implementation of Peter Tang's double precision 1424573Szliu# tangent for the VAX using Bob Corbett's argument reduction. 1524573Szliu# 1624573Szliu# Notes: 1724573Szliu# under 1,024,000 random arguments testing on [0,2*pi] 1824573Szliu# tan() observed maximum error = 2.15 ulps 1924573Szliu# 2024573Szliu# double tan(arg) 2124573Szliu# double arg; 2224573Szliu# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett 2324573Szliu# S. McDonald, April 4, 1985 2424573Szliu# 2524573Szliu .globl _tan 2624573Szliu .text 2724573Szliu .align 1 2824573Szliu 2924573Szliu_tan: .word 0xffc # save r2-r11 3024573Szliu movq 4(ap),r0 3124573Szliu bicw3 $0x807f,r0,r2 3224573Szliu beql 1f # if x is zero or reserved operand then return x 3324573Szliu# 3424573Szliu# Save the PSL's IV & FU bits on the stack. 3524573Szliu# 3624573Szliu movpsl r2 3724573Szliu bicw3 $0xff9f,r2,-(sp) 3824573Szliu# 3924573Szliu# Clear the IV & FU bits. 4024573Szliu# 4124573Szliu bicpsw $0x0060 4224573Szliu jsb libm$argred 4324573Szliu# 4424573Szliu# At this point, 4524573Szliu# r0 contains the quadrant number, 0, 1, 2, or 3; 4624573Szliu# r2/r1 contains the reduced argument as a D-format number; 4724573Szliu# r3 contains a F-format extension to the reduced argument; 4824573Szliu# 4924573Szliu# Save r3/r0 so that we can call cosine after calling sine. 5024573Szliu# 5124573Szliu movq r2,-(sp) 5224573Szliu movq r0,-(sp) 5324573Szliu# 5424573Szliu# Call sine. r4 = 0 implies sine. 5524573Szliu# 5624573Szliu movl $0,r4 5724573Szliu jsb libm$sincos 5824573Szliu# 5924573Szliu# Save sin(x) in r11/r10 . 6024573Szliu# 6124573Szliu movd r0,r10 6224573Szliu# 6324573Szliu# Call cosine. r4 = 1 implies cosine. 6424573Szliu# 6524573Szliu movq (sp)+,r0 6624573Szliu movq (sp)+,r2 6724573Szliu movl $1,r4 6824573Szliu jsb libm$sincos 6924573Szliu divd3 r0,r10,r0 7024573Szliu bispsw (sp)+ 7124573Szliu1: ret 72