Annotation of coherent/b/lib/libm/i8087/atan287.m, revision 1.1.1.1

1.1       root        1: //////////
                      2: / libm 8087
                      3: / atan2(y, x)
                      4: //////////
                      5: 
                      6: #include "larges.h"
                      7: #include "ifno8087.h"
                      8: 
                      9:        .globl  atan2_
                     10:        .globl  atan
                     11:        .globl  cfcc87
                     12:        .globl  tstcc
                     13: 
                     14: //////////
                     15: / double
                     16: / atan2(y, x)
                     17: / double y, x;
                     18: //////////
                     19: 
                     20: y      =       RASIZE          / y arg offset
                     21: x      =       RASIZE+8        / x arg offset
                     22: 
                     23: atan2_:
                     24:        ifno8087(_atan2_)
                     25:        mov     bx, sp
                     26:        fdld    Pss y(bx)       / Load argument y.
                     27:        fdld    Pss x(bx)       / Load argument x.
                     28: 
                     29: atan2:                         / x, y
                     30:        Gcall   tstcc
                     31:        jne     1f              / Jump if x nonzero.
                     32:        fcompp                  / x = 0, compare 0 to y and pop x and y.
                     33:        Gcall   cfcc87
                     34:        fild    cs:minus1       / -1
                     35:        fldpi                   / pi, -1
                     36:        fscale                  / pi/2, -1
                     37:        fstp    st1             / pi/2
                     38:        jbe     0f              / 0 <= y, return pi/2.
                     39:        fchs                    / 0 > y, return -pi/2.
                     40: 
                     41: 0:     Gret
                     42: 
                     43: 1:     pushf                   / Save flags with sign of x.
                     44:        fld     st1             / y, x, y
                     45:        fdivr                   / y/x, y
                     46:        Gcall   atan            / atan(y/x), y
                     47:        popf                    / Restore flags.
                     48:        jb      2f              / x < 0, must adjust by pi.
                     49:        fstp    st1             / atan(y/x)
                     50:        Gret
                     51: 
                     52: 2:     fxch                    / y, atan(y/x)
                     53:        Gcall   tstcc
                     54:        fstp    st              / atan(y/x)
                     55:        fldpi                   / pi, atan(y/x)
                     56:        jae     3f              / y >= 0, add pi.
                     57:        fchs                    / y < 0, subtract pi.
                     58: 
                     59: 3:     fadd                    / atan(y/x) + pi
                     60:        Gret
                     61: 
                     62: / Data.
                     63: minus1:        .word   -1
                     64: 
                     65: / end of atan287.m

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.