# # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)atan.s 5.1 (Berkeley) 5/8/85 # # # double atan(arg1); -pi/2 < atan < pi/2 #double atan2(arg1,arg2); -pi< atan2=0 ret # .align 1 _atan2: .word 0x03c0 bispsw $0xe0 movd 4(ap),r0 # atan(arg1/arg2) movd 12(ap),r2 addd3 r0,r2,r4 cmpd r0,r4 jneq b1 tstd r0 jgeq b2 mnegd pio2,r0 ret b2: movd pio2,r0 ret # b1: tstd r2 jgeq b3 divd2 r2,r0 jleq b4 bsbb satan # arg1<0, arg2<0 subd2 pi,r0 ret b4: mnegd r0,r0 # arg1>0, arg2<0 bsbb satan subd3 r0,pi,r0 ret # b3: divd2 r2,r0 jleq b5 bsbb satan # arg1>0, arg2>0 ret b5: mnegd r0,r0 # arg1<0, arg2>0 bsbb satan mnegd r0,r0 ret # .globl satan satan: # range reduction on positive arg(r0) cmpd r0,sq2m1 jgeq c1 bsbb xatan rsb c1: cmpd r0,sq2p1 jleq c2 divd3 r0,$0d1.0e+0,r0 bsbb xatan subd3 r0,pio2,r0 rsb c2: addd3 $0d1.0e+0,r0,r2 subd2 $0d1.0e+0,r0 divd2 r2,r0 bsbb xatan addd2 pio4,r0 rsb # xatan: # compute arctan(r0) for:sqrt(2)-1