e86sin.inc

来自「开放源码的编译器open watcom 1.6.0版的源代码」· INC 代码 · 共 445 行 · 第 1/2 页

INC
445
字号
            _quif ne                    ; - - quit if ON
            cmp   AH,1                  ; - - or flag == 1
            _quif e                     ; - - ...
          _admit                        ; - admit
;;                cosy = _EvalPoly( y*y, &_cospoly[index], 8 - index );
            push  AX                    ; - - save (i+1) & 2
            mov   AX,DI                 ; - - calc. temp = y * y
            mov   DX,DI                 ; - - ...
            lea   BX,cosy[BP]           ; - - ...
            call  __FLDM                ; - - ...
            mov   BX,index[BP]          ; - - get index
            mov   CX,8                  ; - - calc. 8 - index
            sub   CX,BX                 ; - - ...
            shl   BX,1                  ; - - calc. index * 10
            shl   BX,1                  ; - - ...
            add   BX,index[BP]          ; - - ...
            shl   BX,1                  ; - - ...
            lea   DX,__CosPoly[BX]; - - point to start of polynomial
            mov   BX,CX                 ; - - get the degree
            lea   AX,cosy[BP]           ; - - point to y*y
            mov   CX,AX                 ; - - point to cosy for result
            call  __Poly                ; - - evaluate polynomial
;;            }
            pop   AX                    ; - - restore (i+1) & 2
          _endguess                     ; - endguess

;;            if( (((i+1) & 2) == 0) || flag == 1 ) {
          _guess                        ; - guess
            cmp   AL,0                  ; - - quit if (1+1) & 2 == 0
            _quif e                     ; - - ...
            cmp   AH,1                  ; - - or flag == 1
            _quif e                     ; - - ...
          _admit                        ; - admit
;;                siny = _OddPoly( y, &_sinpoly[index], 8 - index );
            mov   AX,DI                 ; - - point to y
            mov   BX,index[BP]          ; - - get index
            mov   CX,8                  ; - - calc. 8 - index
            sub   CX,BX                 ; - - ...
            shl   BX,1                  ; - - calc. index * 10
            shl   BX,1                  ; - - ...
            add   BX,index[BP]          ; - - ...
            shl   BX,1                  ; - - ...
            lea   DX,__SinPoly[BX]; - - point to start of polynomial
            mov   BX,CX                 ; - - get the degree
            call  __OddPoly             ; - - evaluate polynomial
;;            }
          _endguess                     ; - endguess

;;        }
__endif1:; _endif                       ; endif
;;#if 0
;;        switch( i ) {
;;        case 0: sinx =   siny;  cosx =   cosy;  break;
;;        case 1: sinx =   cosy;  cosx =   siny;  break;
;;        case 2: sinx =   cosy;  cosx = - siny;  break;
;;        case 3: sinx =   siny;  cosx = - cosy;  break;
;;        case 4: sinx = - siny;  cosx = - cosy;  break;
;;        case 5: sinx = - cosy;  cosx = - siny;  break;
;;        case 6: sinx = - cosy;  cosx =   siny;  break;
;;        case 7: sinx = - siny;  cosx =   cosy;  break;
;;        }
;;#endif
;;        if( (i+1) & 2 ) {       /* if octants 1,2,5,6 */
;;            sinx = cosy;
;;        } else {                /* octants 0,3,4,7 */
;;            sinx = siny;
;;        }
        lea     SI,cosy[BP]             ; assume octants 0,3,4,7
        mov     BX,DI                   ; ...
        mov     AX,iflag[BP]            ; get i and flag
        inc     AL                      ; + 1
        and     AL,2                    ; & 2
        _if     ne                      ; if octants 1,2,5,6
          xchg  BX,SI                   ; - xchg siny and cosy
;         lea   BX,cosy[BP]             ; - sinx = cosy
;       _else                           ; else octants 0,3,4,7
;         mov   BX,DI                   ; - sinx = siny
        _endif                          ; endif

;;        if( i & 4 )     sinx = - sinx;  /* octants 4,5,6,7 */
        mov     CX,iflag[BP]            ; get i and flag
        test    CL,4                    ; if octants 4,5,6,7
        _if     ne                      ; then
          xor   byte ptr 9[BX],80h      ; - flip the sign bit
        _endif                          ; endif
;;        if( flag == 1 ) {               /* if "tan" */
        cmp     CH,1                    ; if "tan"
        _if     e                       ; then
;;
;;            /* cos is out of phase with sin by 2 octants */
;;
;;            i += 2;
;;            if( (i+1) & 2 ) {       /* if octants 1,2,5,6 */
;;                cosx = cosy;
;;            } else {                /* octants 0,3,4,7 */
;;                cosx = siny;
;;            }
          add   CL,2                    ; - i += 2;
;         mov   BL,CL                   ; - calc. (i+1) & 2
;         inc   BL                      ; - ...
;         and   BL,2                    ; - ...
;         _if   ne                      ; - if octants 1,2,5,6
;           mov   EBX,cosy[EBP]         ; - - load cosy
;           mov   ECX,cosy+4[EBP]       ; - - ...
;           mov   SI,cosy+8[EBP]        ; - - ...
;         _else                         ; - else
;           mov   EBX,[EDI]             ; - - load siny
;           mov   ECX,4[EDI]            ; - - ...
;           mov   SI,8[EDI]             ; - - ...
;         _endif                        ; - endif
;;            if( i & 4 )     cosx = - cosx;  /* octants 4,5,6,7 */
          and   CL,4                    ; - if octants 4,5,6,7
          _if   ne                      ; - then
            xor   byte ptr 9[SI],80h    ; - - flip the sign
          _endif                        ; - endif
;;            if( cosx == 0.0 ) {
;;                errno = ERANGE;
;;                if( sinx > 0.0 )  return( HUGE_VAL );
;;                return( - HUGE_VAL );
;;            }
          _guess                        ; - guess
            mov   AX,[SI]               ; - - quit if cosx != 0
            or    AX,2[SI]              ; - - ...
            or    AX,4[SI]              ; - - ...
            or    AX,6[SI]              ; - - ...
            _quif ne                    ; - - ...
            mov    AX,8[SI]             ; - - ...
            shl    AX,1                 ; - - ...
            _quif ne                    ; - - ...
            mov   [DI],AX               ; - - set result to infinity
            mov   2[DI],AX              ; - - ...
            mov   4[DI],AX              ; - - ...
            mov   AX,8000h              ; - - ...
            mov   6[DI],AX              ; - - ...
            mov   AX,8[BX]              ; - - ...
            or    AX,7FFFh              ; - - ...
            mov   8[DI],AX              ; - - ...
          _admit                        ; - admit
;;            sinx = sinx/cosx;         /* calculate value of tan function */
            mov   AX,BX                 ; - - ...
            mov   DX,SI                 ; - - ...
            mov   BX,DI                 ; - - ...
            call  __FLDD                ; - - tan(x) = sin(x) / cos(x)
            mov   BX,DI                 ; - - ...
          _endguess                     ; - endguess
;;        }
        _endif                          ; endif
;;        if( exponent >= 28 ) {
;;            return( _matherr( PLOSS, func_name[flag], &x, &x, sinx ) );
;;        }
;;        return( sinx );
        cmp     BX,DI                   ; if result not in x
        _if     ne                      ; then
          mov   SI,BX                   ; - copy result to x
          lodsw                         ; - ...
          mov   [DI],AX                 ; - ...
          lodsw                         ; - ...
          mov   2[DI],AX                ; - ...
          lodsw                         ; - ...
          mov   4[DI],AX                ; - ...
          lodsw                         ; - ...
          mov   6[DI],AX                ; - ...
          lodsw                         ; - ...
          mov   8[DI],AX                ; - ...
        _endif                          ; endif

        mov     SP,BP                   ; clean up stack
        pop     DS                      ; restore address of result
        pop     DI                      ; ...
        pop     word ptr [DI]           ; copy value into result
        pop     word ptr 2[DI]          ; ...
        pop     word ptr 4[DI]          ; ...
        pop     word ptr 6[DI]          ; ...
        pop     word ptr 8[DI]          ; ...
        pop     BX                      ; restore registers
        pop     CX                      ; ...
        pop     DX                      ; ...
        pop     DI                      ; ...
        pop     BP                      ; restore EBP
        ret                             ; return
__sincos endp
;;    }
;;
;;
;;void sin( long double *x )
;;    {
;;        return _sincos( x, 0 );
        defp    __sin
        push    SI                      ; save registers
        sub     SI,SI                   ; indicate sin
        call    __sincos                ; evaluate sin
        pop     SI                      ; restore ESI
        ret                             ; return
__sin   endp
;;    }
;;
;;
;;void cos( long double *x )
;;    {
;;        return _sincos( x, 2 );
        defp    __cos
        push    SI                      ; save registers
        mov     SI,2                    ; indicate cos
        call    __sincos                ; evaluate cos
        pop     SI                      ; restore ESI
        ret                             ; return
__cos   endp
;;    }
;;
;;
;;void tan( long double *x )
;;    {
;;        return _sincos( x, 1 );
        defp    __tan
        push    SI                      ; save registers
        mov     SI,1                    ; indicate tan
        call    __sincos                ; evaluate tan
        pop     SI                      ; restore ESI
        ret                             ; return
__tan   endp
;;    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?