software: Added more and more
[pdp8.git] / sw / f4 / FRTSRC / atan2.ra
... / ...
CommitLineData
1/
2/
3/
4/ A T A N 2
5/ - - - - -
6/
7/SUBROUTINE ATAN2(Y,X)
8/
9/ VERSION 5A 4-27-77 PT
10/
11 SECT ATAN2
12 JA #ATAN2
13 TEXT +ATAN2 +
14ATN2XR, SETX XRATN2
15 SETB BPATN2
16BPATN2, FNOP
17 0
18 0
19XRATN2, F 0.0
20YCOR, F 0.0
21XCOR, F 0.0
22FPIAT2, 2 /PI
23 3110
24 3755
25ATPI, F 1.570796 /PI/2
26 ORG 10*3+BPATN2
27 FNOP
28 JA ATN2XR
29 0
30AT2RTN, JA .
31 BASE 0
32#ATAN2, STARTD
33 FLDA 10*3
34 FSTA AT2RTN
35 FLDA 0
36 SETX XRATN2
37 SETB BPATN2
38 BASE BPATN2
39 LDX 1,1
40 FSTA BPATN2
41 FLDA% BPATN2,1 /ADDR OF Y
42 FSTA YCOR
43 FLDA% BPATN2,1+ /ADDR OF X
44 FSTA XCOR
45 STARTF
46 FLDA% YCOR /GET Y - THE TAN
47 FSTA YCOR /SAV FOR A SECOND
48 LDX 1,2 /POSITIVE X
49 JEQ ATN0
50 JGT ATN1
51 LDX 0,2
52ATN1, FLDA% XCOR /GET X - THE QUADRAND
53 FSTA XCOR /+MOVE IT TO A SAFE PLACE
54 JEQ ATASP
55 FLDA YCOR /Y/X
56 FDIV XCOR
57 FSTA YCOR
58 EXTERN ATAN
59 JSR ATAN /CALL ATAN
60 JA .+4 /TAKE ARCTAN OF Y/X
61 JA YCOR
62 FSTA YCOR /SAVE IT AWAY
63 JGE A2 /SKIP IF 1 OR 3 Q
64 FADD FPIAT2 /ADD PI FOR 4TH Q
65 FSTA YCOR
66A2, JXN AT2RTN,2
67 FLDA YCOR
68 FSUB FPIAT2 /SUB PI FOR 2ND+3RD QUADS
69 JA AT2RTN
70ATASP, FLDA ATPI /X=0 MEANS +-PI/2
71 JXN ATNG,2
72 FNEG
73ATNG, JA AT2RTN
74ATN0, FLDA% XCOR
75 JLT POSX /IF X POS,ANS IS 0
76 FCLA
77 JA AT2RTN
78POSX, FLDA FPIAT2 /OTHERWISE,ANS IS PI
79 JA AT2RTN
80\f