1# 2# Copyright (c) 1980 Regents of the University of California. 3# All rights reserved. The Berkeley software License Agreement 4# specifies the terms and conditions for redistribution. 5# 6# @(#)atan.s 5.1 (Berkeley) 05/08/85 7# 8# 9# double atan(arg1); -pi/2 < atan < pi/2 10#double atan2(arg1,arg2); -pi< atan2<pi 11#double arg1,arg2 12#method: range reduction to [sqrt(2)-1,sqrt(2)+1] 13# followed by Hart&Cheney ARCTN 5076 D=17.55 14# J. F. Jarvis August 8, 1978 15.globl _atan 16.globl _atan2 17.text 18.align 1 19_atan: 20 .word 0x03c0 21 bispsw $0xe0 22 movd 4(ap),r0 23 jgtr a1 24 mnegd r0,r0 # atan(arg1), arg1<0 25 bsbb satan 26 mnegd r0,r0 27 ret 28a1: bsbb satan # atan(arg1), arg1>=0 29 ret 30# 31.align 1 32_atan2: 33 .word 0x03c0 34 bispsw $0xe0 35 movd 4(ap),r0 # atan(arg1/arg2) 36 movd 12(ap),r2 37 addd3 r0,r2,r4 38 cmpd r0,r4 39 jneq b1 40 tstd r0 41 jgeq b2 42 mnegd pio2,r0 43 ret 44b2: movd pio2,r0 45 ret 46# 47b1: tstd r2 48 jgeq b3 49 divd2 r2,r0 50 jleq b4 51 bsbb satan # arg1<0, arg2<0 52 subd2 pi,r0 53 ret 54b4: mnegd r0,r0 # arg1>0, arg2<0 55 bsbb satan 56 subd3 r0,pi,r0 57 ret 58# 59b3: divd2 r2,r0 60 jleq b5 61 bsbb satan # arg1>0, arg2>0 62 ret 63b5: mnegd r0,r0 # arg1<0, arg2>0 64 bsbb satan 65 mnegd r0,r0 66 ret 67# 68.globl satan 69satan: # range reduction on positive arg(r0) 70 cmpd r0,sq2m1 71 jgeq c1 72 bsbb xatan 73 rsb 74c1: cmpd r0,sq2p1 75 jleq c2 76 divd3 r0,$0d1.0e+0,r0 77 bsbb xatan 78 subd3 r0,pio2,r0 79 rsb 80c2: addd3 $0d1.0e+0,r0,r2 81 subd2 $0d1.0e+0,r0 82 divd2 r2,r0 83 bsbb xatan 84 addd2 pio4,r0 85 rsb 86# 87xatan: # compute arctan(r0) for:sqrt(2)-1<r0<sqrt(2)+1 88# Hart&Cheney ARCTN 5076 is evaluated 89 movd r0,r8 90 muld3 r0,r0,r6 91 polyd r6,$4,pcoef 92 muld2 r0,r8 93 polyd r6,$4,qcoef 94 divd3 r0,r8,r0 95 rsb 96.data 97.align 2 98pcoef: 99 .double 0d0.1589740288482307048e+0 100 .double 0d0.66605790170092626575e+1 101 .double 0d0.40969264832102256374e+2 102 .double 0d0.77477687719204208616e+2 103 .double 0d0.44541340059290680319e+2 104qcoef: 105 .double 0d1.0e+0 106 .double 0d0.15503977551421987525e+2 107 .double 0d0.62835930511032376833e+2 108 .double 0d0.92324801072300974840e+2 109 .double 0d0.44541340059290680444e+2 110pio4: .double 0d0.78539816339744830961e+0 111pio2: .double 0d1.57079632679489661923e+0 112sq2p1: .double 0d2.41421356237309504880e+0 113sq2m1: .double 0d0.41421356237309504880e+0 114pi: .double 0d3.14159265358979323846e+0 115