chipd32.asm

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

ASM
992
字号
                                ; for calling from mem routines
        sub     esp, STACK_SIZE
        fdivp_sti 1, 0
        ret
__fdivp_sti_st    ENDP

__fdivrp_sti_st   PROC    NEAR
                                ; for calling from mem routines
        sub     esp, STACK_SIZE
        fdivrp_sti 1, 0
        ret
__fdivrp_sti_st   ENDP

        public  __fdiv_chk
        defpe __fdiv_chk
                                ; for calling from mem routines
        sub     esp, STACK_SIZE
        fdivrp_sti 1, 0
        ret
__fdiv_chk   ENDP

;
;  PRELIMINARY VERSIONS of the routines for register-memory
;  divide instructions
;

;;; FDIV_M32 - FDIV m32real FIX
;;
;;      Input : Value of the m32real in the top of STACK
;;
;;      Output: Result of FDIV in ST

        PUBLIC  __fdiv_m32
        defpe   __fdiv_m32

        push    eax                             ; save eax
        mov     eax, [esp + MEM_OPERAND]        ; check for
        and     eax, SINGLE_NAN                 ; NaN
        cmp     eax, SINGLE_NAN                 ;
        je      memory_divide_m32               ;

        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack                   ; is FP stack full?
        fld     dword ptr[esp + MEM_OPERAND]    ; load m32real in ST
        call    __fdivp_sti_st                    ; do actual divide
        pop     eax
        ret     4
spill_fpstack:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fld     dword ptr[esp + SPILL_MEM_OPERAND] ; load m32 real
        call    __fdivp_sti_st                    ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivrp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret     4
memory_divide_m32:
        fdiv    dword ptr[esp + MEM_OPERAND]    ; do actual divide
        pop     eax
        ret     4

__fdiv_m32        ENDP


;;; FDIV_M64 - FDIV m64real FIX
;;
;;      Input : Value of the m64real in the top of STACK
;;
;;      Output: Result of FDIV in ST

        PUBLIC  __fdiv_m64
        defpe   __fdiv_m64

        push    eax                             ; save eax
        mov     eax, [esp + MEM_OPERAND + 4]    ; check for
        and     eax, DOUBLE_NAN                 ; NaN
        cmp     eax, DOUBLE_NAN                 ;
        je      memory_divide_m64               ;

        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m64               ; is FP stack full?
        fld     qword ptr[esp + MEM_OPERAND]    ; load m64real in ST
        call    __fdivp_sti_st                    ; do actual divide
        pop     eax
        ret     8
spill_fpstack_m64:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp]                  ; save user's ST(1)
        fld     qword ptr[esp + SPILL_MEM_OPERAND] ; load m64real
        call    __fdivp_sti_st                    ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivrp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret     8

memory_divide_m64:
        fdiv    qword ptr[esp + MEM_OPERAND]    ; do actual divide
        pop     eax
        ret     8

__fdiv_m64        ENDP



;;; FDIVR_M32 - FDIVR m32real FIX
;;
;;      Input : Value of the m32real in the top of STACK
;;
;;      Output: Result of FDIVR in ST

        PUBLIC  __fdiv_m32r
        defpe   __fdiv_m32r
        push    eax                             ; save eax
        mov     eax, [esp + MEM_OPERAND]        ; check for
        and     eax, SINGLE_NAN                 ; NaN
        cmp     eax, SINGLE_NAN                 ;
        je      memory_divide_m32r              ;

        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m32r              ; is FP stack full?
        fld     dword ptr[esp + MEM_OPERAND]    ; load m32real in ST
        call    __fdivrp_sti_st                   ; do actual divide
        pop     eax
        ret     4
spill_fpstack_m32r:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fld     dword ptr[esp + SPILL_MEM_OPERAND] ; load m32 real
        call    __fdivrp_sti_st                   ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret     4
memory_divide_m32r:
        fdivr   dword ptr[esp + MEM_OPERAND]    ; do actual divide
        pop     eax
        ret     4

__fdiv_m32r     ENDP


;;; FDIVR_M64 - FDIVR m64real FIX
;;
;;      Input : Value of the m64real in the top of STACK
;;
;;      Output: Result of FDIVR in ST

        PUBLIC  __fdiv_m64r
        defpe   __fdiv_m64r
        push    eax                             ; save eax
        mov     eax, [esp + MEM_OPERAND + 4]    ; check for
        and     eax, DOUBLE_NAN                 ; NaN
        cmp     eax, DOUBLE_NAN                 ;
        je      memory_divide_m64r              ;

        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m64r              ; is FP stack full?
        fld     qword ptr[esp + MEM_OPERAND]    ; load m64real in ST
        call    __fdivrp_sti_st                   ; do actual divide
        pop     eax
        ret     8
spill_fpstack_m64r:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fld     qword ptr[esp + SPILL_MEM_OPERAND] ; load m64real
        call    __fdivrp_sti_st                   ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret     8
memory_divide_m64r:
        fdivr   qword ptr[esp + MEM_OPERAND]    ; do actual divide
        pop     eax
        ret     8


__fdiv_m64r       ENDP

comment ~******************************************************************
;;; FDIV_M16I - FDIV m16int FIX
;;
;;      Input : Value of the m16int in the top of STACK
;;
;;      Output: Result of FDIV in ST

        PUBLIC  FDIV_M16I
FDIV_M16I       PROC    NEAR
        push    eax                             ; save eax
        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m16i              ; is FP stack full?
        fild    word ptr[esp + MEM_OPERAND]     ; load m16int in ST
        call    __fdivp_sti_st                    ; do actual divide
        pop     eax
        ret
spill_fpstack_m16i:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fild    word ptr[esp + SPILL_MEM_OPERAND] ; load m16int
        call    __fdivp_sti_st                    ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivrp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret

FDIV_M16I       ENDP

;;; FDIV_M32I - FDIV m16int FIX
;;
;;      Input : Value of the m16int in the top of STACK
;;
;;      Output: Result of FDIV in ST

        PUBLIC  FDIV_M32I
FDIV_M32I       PROC    NEAR
        push    eax                             ; save eax
        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m32i              ; is FP stack full?
        fild    dword ptr[esp + MEM_OPERAND]    ; load m32int in ST
        call    __fdivp_sti_st                    ; do actual divide
        pop     eax
        ret
spill_fpstack_m32i:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fild    dword ptr[esp + SPILL_MEM_OPERAND] ; load m32int
        call    __fdivp_sti_st                    ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivrp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret


FDIV_M32I       ENDP


;;; FDIVR_M16I - FDIVR m16int FIX
;;
;;      Input : Value of the m16int in the top of STACK
;;
;;      Output: Result of FDIVR in ST

        PUBLIC  FDIVR_M16I
FDIVR_M16I      PROC    NEAR
        push    eax                             ; save eax
        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m16ir             ; is FP stack full?
        fild    word ptr[esp + MEM_OPERAND]     ; load m16int in ST
        call    __fdivrp_sti_st                   ; do actual divide
        pop     eax
        ret
spill_fpstack_m16ir:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fild    word ptr[esp + SPILL_MEM_OPERAND] ; load m16int
        call    __fdivrp_sti_st                   ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret


FDIVR_M16I      ENDP


;;; FDIVR_M32I - FDIVR m32int FIX
;;
;;      Input : Value of the m32int in the top of STACK
;;
;;      Output: Result of FDIVR in ST

        PUBLIC  FDIVR_M32I
FDIVR_M32I      PROC    NEAR
        push    eax                             ; save eax
        f_stsw  ax                              ; get status word
        and     eax, 3800h                      ; get top of stack
        je      spill_fpstack_m32ir             ; is FP stack full?
        fild    dword ptr[esp + MEM_OPERAND]    ; load m32int in ST
        call    __fdivrp_sti_st                   ; do actual divide
        pop     eax
        ret
spill_fpstack_m32ir:
        fxch
        sub     esp, SPILL_SIZE                 ; make temp space
        fstp    tbyte ptr[esp ]                 ; save user's ST(1)
        fild    dword ptr[esp + SPILL_MEM_OPERAND] ; load m32int
        call    __fdivrp_sti_st                   ; do actual divide
        fld     tbyte ptr[esp]                  ; restore user's ST(1)
                                                ;esp is adjusted by fdivp fn
        fxch
        add     esp, SPILL_SIZE
        pop     eax
        ret

FDIVR_M32I      ENDP
**********************************************************************~



_TEXT  ENDS

        end

⌨️ 快捷键说明

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